How to enforce ordering without using xsd:sequence?
<p>I am writing a rule engine where user can specify rules in any sequence but once specified, they are executed in same order as configured.  Something like this</p>

<pre><code>&lt;RuleEngine&gt;
     &lt;Rule1 ..&gt;
     &lt;Rule2 ..&gt;
     &lt;Rule3 ...&gt;
&lt;/RuleEngined&gt;
</code></pre>

<p>(Execution : <code>Rule1</code>-><code>Rule2</code>-><code>Rule3</code>) </p>

<p>OR like this </p>

<pre><code>&lt;RuleEngine&gt;
     &lt;Rule3 ..&gt;
     &lt;Rule1 ..&gt;
     &lt;Rule2 ...&gt;
&lt;/RuleEngine&gt;
</code></pre>

<p>(Execution : <code>Rule3</code>-><code>Rule1</code>-><code>Rule2</code>)</p>

<p>I am writing a schema for this and am not able to get desired result with <code>xsd:all</code> or <code>xsd:sequence</code>. If I use <code>xsd:all</code> it will allow flexibility for user but will NOT preserve order in code while parsing. </p>

<pre><code>    &lt;xs:element name="RuleEngine"&gt;
      &lt;xs:complexType&gt;
         &lt;xs:all&gt;
               &lt;xs:element ref="Rule1" ..
               &lt;xs:element ref="Rule2" ..
               &lt;xs:element ref="Rule3" ..
         &lt;/xs:all&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
</code></pre>

<p>I can't use <code>xsd:sequence</code> either, else it will prevent users from specifying Rules in the order of their choice, though in CODE it will let developer know the order.</p>

<pre><code>    &lt;xs:element name="RuleEngine"&gt;
      &lt;xs:complexType&gt;
         &lt;xs:sequence&gt;
               &lt;xs:element ref="Rule1" ..
               &lt;xs:element ref="Rule2" ..
               &lt;xs:element ref="Rule3" ..
         &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
</code></pre>

<p>I read few threads e.g. <a href="https://stackoverflow.com/questions/2911919/is-there-a-way-to-enforce-preserve-order-of-xml-elements-in-an-xml-schema">thread1</a> , <a href="https://stackoverflow.com/questions/3325247/xml-validation-with-xsd-how-to-avoid-caring-about-the-sequence-of-the-elements">thread2</a> and it seems there is no direct way out with XML/XSD for this. You can either enforce order OR not enforce it, can't have both like I am dreaming :)
One not-so-preferred option is to use "all" and enforce user to put an numeric ID along with the rule, as a hint for code to sort out rules before execution.
Other tedious one is to migrate onto <a href="http://Boost%20Property%20Tree" rel="nofollow noreferrer">Boost Property Tree</a></p>

<p>Any suggestion if I can achieve desired behavior with existing framework?</p>