title: XSD - how to allow elements in any order any number of times?
body: <p>I am trying to create an XSD, and trying to write the definition with the following requirement:</p>
  
  <ul>
  <li>Allow child element specified to appear any number of times (0 to unbounded)</li>
  <li>Allow child elements to be in any order</li>
  </ul>
  
  <p>I looked around and found various solutions like <a href="http://social.msdn.microsoft.com/Forums/en/xmlandnetfx/thread/decedc59-b991-4e2f-b2cf-41ac139f734f" rel="noreferrer">this</a>:</p>
  
  <pre><code>&lt;xs:element name="foo"&gt;
    &lt;xsl:complexType&gt;
      &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt;
        &lt;xs:element name="child1" type="xs:int"/&gt;
        &lt;xs:element name="child2" type="xs:string"/&gt;
      &lt;/xs:choice&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>But from what I understand xs:choice still only allows single element selection. Hence setting the MaxOccurs to unbounded  like this should only mean that "any one" of the child elements can appear multiple times. Is this accurate? </p>
  
  <p>If above solution is incorrect, how can I achieve what I stated above in my requirement?</p>
  
  <p><strong>EDIT</strong>: What if the requirement is as follows?</p>
  
  <ul>
  <li>Element child1 child2 can appear any
  number of times (0 to unbounded)</li>
  <li>Elements to be in any order</li>
  <li>Elements child3 and child4 should appear exactly once.</li>
  </ul>
  
  <p>For example, 
  this xml is valid:</p>
  
  <pre><code>&lt;foo&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;child3&gt; value &lt;/child3&gt;
  &lt;child2&gt; value &lt;/child2&gt;
  &lt;child4&gt; value &lt;/child4&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;/foo&gt;
  </code></pre>
  
  <p>but this is not (missing child3)</p>
  
  <pre><code>&lt;foo&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;child2&gt; value &lt;/child2&gt;
  &lt;child4&gt; value &lt;/child4&gt;
  &lt;child1&gt; value &lt;/child1&gt;
  &lt;/foo&gt;
  </code></pre>