I have a root element <a>
and its children <b>, <c>, <d>
Here's what I need:
- the child elements can appear in any order
- just 1
<b>
- more than 1
<c>
- 0 or 1
<d>
For example:
<a>
<c />
<b />
<c />
<d />
</a>
And here is my XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="a">
<xs:complexType>
<xs:choice>
<xs:element name="b" />
<xs:element name="c" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="d" minOccurs="0" maxOccurs="1"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
But the minOccurs
and maxOccurs
in xs:element
may not work. When I run the example, I got an error:
Element
<b>
is not allowed at this location under element<a>
.
How can I fix this?