Ignore order of elements using xs:extension
- by Peter Lang
How can I design my xsd to ignore the sequence of elements?
<root> <a/> <b/> </root>
<root> <b/> <a/> </root>
I need to use extension for code generation reasons, so I tried the following using all:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.example.com/test"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:t="http://www.example.com/test" >
    <xs:complexType name="BaseType">
        <xs:all>
            <xs:element name="a" type="xs:string" />
        </xs:all>
    </xs:complexType>
    <xs:complexType name="ExtendedType">
        <xs:complexContent>
            <xs:extension base="t:BaseType">
                <xs:all> <!-- ERROR -->
                    <xs:element name="b" type="xs:string" />
                </xs:all>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:element name="root" type="t:ExtendedType"></xs:element>
</xs:schema>
This xsd is not valid though, the following error is reported at <!-- ERROR -->:
  cos-all-limited.1.2: An all model group must appear in a particle with {min occurs} = {max occurs} = 1, and that particle must be part of a pair which constitutes the {content type} of a complex type definition.
Documentation of cos-all-limited.1.2 says:
  1.2 the {term}  property of a particle with {max occurs}=1 which is part of a pair which constitutes the {content type}  of a complex type definition.
I don't really understand this (neither xsd nor English native speaker :) ).
Am I doing the wrong thing, am I doing the right thing wrong, or is there no way to achieve this?
Thanks!