http://www.topologi.com/public/Schtrn_XSD

Hi Torsten,

> I am trying to have a mixture of ordered and unordered elements:
>
> <root>
>   <seq1/>
>   <seq2/>
>   <unordered2/>
>   <unordered1/>
> </root>
>
> So what IMHO would make sense would be:
>
>   <xs:element name="root">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:sequence>
>           <xs:element name="seq1"/>
>           <xs:element name="seq2"/>
>         </xs:sequence>
>         <xs:all>
>           <xs:element name="unordered1"/>
>           <xs:element name="unordered2"/>
>         </xs:all>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
>
> But obviously this does not work.
> What is the proposed way to express such a schema?

How about wrapping the unordered content in an extra element:

<root>
  <seq1/>
  <seq2/>
  <unordered>
    <unordered2/>
    <unordered1/>
  </unordered>
</root>

  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="seq1"/>
        <xs:element name="seq2"/>
        <xs:element name="unordered">
          <xs:complexType>
            <xs:all>
              <xs:element name="unordered1"/>
              <xs:element name="unordered2"/>
            </xs:all>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

If this doesn't work (or the suggestion by Mark) you have to move to
RELAX-NG which can define this without problem or use embedded
Schematron rules in your W3C XML Schema (see [1])

Cheers,
/Eddie

[1] http://www.topologi.com/public/Schtrn_XSD/Paper.html


>
>
> Any help appreciated!
> --
> Torsten

Received on Tuesday, 11 June 2002 20:06:07 UTC