Shajirr
Shajirr

Reputation: 163

Is it possible to use inheritance in xsd with variable element order?

Is it possible to use inheritance in xsd with variable element order?

Basically, something like this does not work, since "all" is not allowed inside "extension":

<xs:complexType name="root">
    <xs:complexContent>
          <xs:all>
              <xs:element name="A" type="xs:string"/>
              <xs:element name="B" type="xs:string"/>
          </xs:all>
    </xs:complexContent>
</xs:complexType>

<xs:complexType name="extended">
    <xs:complexContent>
        <xs:extension base="root"> 
            <xs:all>
              <xs:element name="C" type="xs:string"/>
              <xs:element name="D" type="xs:string"/>
            </xs:all>
        </xs:extension>
    </xs:complexContent>
</xs:complexType>

The simplest solution would be just to use "sequence" instead of "all", but in my case this is not an option, since the element order is not guaranteed, so something like this:

<obj>
  <B/>
  <C/>
  <D/>
  <A/>
</obj>

will be invalid because of the wrong element order, but is should not be since all the elements are present.

Upvotes: 2

Views: 226

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

Your example is legal in XSD 1.1, which became a Recommendation last week. XSD 1.1 is implemented in Xerces and in Saxon.

Upvotes: 1

Related Questions