I want to define a Schema for an XML where I can define an arrow by defining its head, fletching or both of them. How can I create a sequence with a limited number of inner items and limit at the same time the max occurences of each item type? My actual version does not detect when the arrow definition doesn't contain any elements:
<xs:element name="Arrow">
<xs:annotation>
<xs:documentation>Arrow with fletching, head or both.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="2">
<xs:element minOccurs="0" name="Fletching" maxOccurs="1">
</xs:element>
<xs:element minOccurs="0" name="Head" maxOccurs="1">
</xs:element>
</xs:sequence>
[...]
With this Schema I expect to validate:
<Arrow>
<Head/>
</Arrow>
<Arrow>
<Fletching/>
</Arrow>
<Arrow>
<Head/>
<Fletching/>
</Arrow>
as OK.
And
<Arrow/>
or
<Arror>
</Arrow>
as not OK.