Sunday, December 11, 2011

XSD: elements in arbitrary order

my situation is that I have child elements which can occur repeatedly in any order:

<root>
 <a>bla</a>
 <b>bli</b>
 <b>blo</b>
 <a>blu</a>
 <a>ble</a>
</root>

Googling around I find this solution:

<xs:complextype mixed="true" name="p">
 <xs:choice maxoccurs="unbounded" minoccurs="0">
  <xs:element name="a">
  <xs:element name="b">
 </xs:element></xs:element>
</xs:choice>
</xs:complextype>


 it seems to work pretty well...

my wish is that XSD contained a native construct like "anyorder", similar to "sequence" or "choice" or "all"

No comments: