title: How to create a schema for an unordered list of XML nodes, with occurrence constraints
body: <p>Given an XML layout like this, I'm trying to create a XSD schema to validate it.</p>
  
  <pre><code>&lt;RootNode&gt;
    &lt;ChildA /&gt;
    &lt;ChildC /&gt;
    &lt;ChildB /&gt;
    &lt;ChildB /&gt;
    &lt;ChildA /&gt;
  &lt;/RootNode&gt;
  </code></pre>
  
  <p>The requirements are as follows:</p>
  
  <ul>
  <li>ChildA, ChildB and ChildC may occur <strong>in any order</strong>. (<code>&lt;xs:sequence&gt;</code> unsuitable)</li>
  <li>ChildA is <strong>mandatory</strong> but may occur multiple times.</li>
  <li>ChildB is optional and may occur multiple times.</li>
  <li>ChildC is optional and may occur <strong>once only</strong>.</li>
  </ul>
  
  <p>The technique I usually use to create an unordered list of nodes is to use a <code>&lt;xs:choice maxOccurs="unbounded"&gt;</code> with each possible node in the list, however, I am unable to create the <code>minOccurs="1"</code> constraint on ChildA and the <code>maxOccurs="1"</code> contraint on ChildC. (The # of occurances of the choice takes precedence over those of the elements here).</p>
  
  <pre><code>&lt;xs:element name="RootNode"&gt;
    &lt;xs:complexType&gt;
      &lt;xs:choice minOccurs="1" maxOccurs="unbounded"&gt;
        &lt;xs:element name="ChildA" minOccurs="1"/&gt;
        &lt;xs:element name="ChildB" /&gt;
        &lt;xs:element name="ChildC" maxOccurs="1"/&gt;
      &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>