title: How to use <xs:all> when complexType needs to be extended in XML Schema?
body: <p>I need to create an XSD schema of a list of items:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;xs:element name="Items"&gt;
  &lt;xs:complexType&gt;
  &lt;xs:sequence&gt;
      &lt;xs:element name="Item" minOccurs="0" maxOccurs="unbounded" type="Item" /&gt;
  &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  </code></pre>
  
  <p>Each item has a name and an id, but the order of these elements is unknown and can vary for each item. So I use <code>&lt;xs:all&gt;</code> like this:</p>
  
  <pre><code>&lt;xs:complexType name="Item"&gt;
      &lt;xs:all&gt;
          &lt;xs:element name="Name" type="xs:string"/&gt;
          &lt;xs:element name="ID" type="xs:integer"/&gt;
      &lt;/xs:all&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>This works. However, I have 3 kinds of items. Each item has an additional element:</p>
  
  <ul>
  <li>itemA: can have 0-unbound "fish" elements</li>
  <li>itemB: can have 0-1 "vegetable" elements</li>
  <li>itemC: has exactly 2 "fruit" elements</li>
  </ul>
  
  <p>None of the elements have attributes, and the items don't need to be extended further.</p>
  
  <p>I tried using extension but, you can't use <code>&lt;xs:all&gt;</code> in the parent and then extend.</p>
  
  <p>Then I tried making one superItem, where an item can have a choice of either fish, vegetables or fruits but you can't use choice inside <code>&lt;xs:all&gt;</code>.</p>
  
  <p>How can I use extension with <code>&lt;xs:all&gt;</code>, or can I create a workaround to not have the fixed order of elements that sequence requires? In the real code, my item and subtype of items have many more elements than the ones shown above, so doing a choice between all possible permutations is not feasible.</p>