title: XSD specific elements in different position
body: <p>The problem I faced to is to build correct XSD schema for my XML </p>
  
  <p>I have the following XML: </p>
  
  <pre><code>&lt;VanToRoute&gt;
     &lt;VanId&gt;1111&lt;/VanId&gt;
     &lt;RouteNo&gt;1459&lt;/RouteNo&gt;
     &lt;RouteNo&gt;1458&lt;/RouteNo&gt;
     &lt;RouteNo&gt;2459&lt;/RouteNo&gt;
     &lt;RouteNo&gt;1THU&lt;/RouteNo&gt;
  &lt;/VanToRoute&gt;
  &lt;VanToRoute&gt;
     &lt;RouteNo&gt;2458&lt;/RouteNo&gt;
     &lt;VanId&gt;2222&lt;/VanId&gt;
     &lt;RouteNo&gt;1457&lt;/RouteNo&gt;
     &lt;RouteNo&gt;1NEW&lt;/RouteNo&gt;
     &lt;RouteNo&gt;2NEW&lt;/RouteNo&gt;
  &lt;/VanToRoute&gt;
  &lt;VanToRoute&gt;
     &lt;RouteNo&gt;1215&lt;/RouteNo&gt;
     &lt;RouteNo&gt;2457&lt;/RouteNo&gt;
     &lt;VanId&gt;2222&lt;/VanId&gt;
  &lt;/VanToRoute&gt;
  &lt;VanToRoute&gt;
     &lt;VanId&gt;4444&lt;/VanId&gt;    
     &lt;RouteNo&gt;2456&lt;/RouteNo&gt;
     &lt;RouteNo&gt;1100&lt;/RouteNo&gt;
     &lt;RouteNo&gt;2465&lt;/RouteNo&gt;
  &lt;/VanToRoute&gt;
  </code></pre>
  
  <p>So the key point is to have required field of VanId and Unbounded number of RouteNo. </p>
  
  <p>The main challenge is to set required fields with allowed placement of XML elements. </p>
  
  <p>What I've done so far:  </p>
  
  <pre><code> &lt;xs:element minOccurs="1" maxOccurs="unbounded" name="VanToRoute"&gt;
        &lt;xs:complexType&gt;
              &lt;xs:sequence&gt; 
                  &lt;xs:choice&gt; 
                       &lt;xs:element minOccurs="1" name="VanId" type="xs:unsignedshort" /&gt; 
                       &lt;xs:element minOccurs="1" name="RouteNo" type="xs:string" /&gt; 
                  &lt;/xs:choice&gt; 
                  &lt;xs:choice&gt;
                        &lt;xs:element minOccurs="1" name="RouteNo" type="xs:string" /&gt; 
                        &lt;xs:element minOccurs="1" name="VanId" type="xs:unsignedshort" /&gt; 
                  &lt;/xs:choice&gt; 
                  &lt;xs:sequence&gt;
                        &lt;xs:element minOccurs="0" maxOccurs="unbounded" name="RouteNo" type="xs:string" /&gt; 
                 &lt;/xs:sequence&gt; 
             &lt;/xs:sequence&gt; 
        &lt;/xs:complexType&gt;
   &lt;/xs:element&gt;  
  </code></pre>
  
  <p>But this solution is not correct for several reasons: </p>
  
  <ol>
  <li>It's allowed to have duplicated VanId which is not correct</li>
  <li>It's doesn't give the flexible to put VanId at the end of my list.</li>
  </ol>
  
  <p>My question is - if that even possible to somehow imitate logic I'd like to put into?</p>