Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I create a schema which requires certain elements, allows others, and is order-agnostic?
    text
    copied!<p>I want to create an XML schema that contains the following:</p> <pre><code>&lt;xs:complexType name="Record"&gt; &lt;!--required elements--&gt; &lt;xs:element name="RecordTag" type="xs:string" minOccurs="1" maxOccurs="1" /&gt; &lt;xs:element name="RecordSize" type="xs:string" minOccurs="1" maxOccurs="1" /&gt; &lt;xs:element name="RecordSection" type="xs:string" minOccurs="1" maxOccurs="1" /&gt; &lt;!--optional elements--&gt; &lt;xs:element name="RecordName" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordType" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordValue" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordDefault" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordComment" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordURL" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="Condition" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="Master" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordCurrent" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;xs:element name="RecordId" type="xs:string" minOccurs="0" maxOccurs="1" /&gt; &lt;/xs:complexType&gt; </code></pre> <p>As you can tell by the comments, I want the top three elements to be required, and the rest are optional. The schema should allow for the elements to appear in any order.</p> <p>Now, if I use the <code>&lt;xs:sequence&gt;</code> indicator, the order is enforced, which I don't want. If I use the <code>&lt;xs:all&gt;</code> indicator, then the schema requires all the elements to appear, even if the <code>minOccurs</code> value is set to <code>0</code>.</p> <p>Is there some other indicator that I can use to accomplish my task?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload