I've read the XSD specification but I'm still confused. Is an empty choice valid in XSD? I mean, with a simple choice with no attributes declared, is mandatory to have either element "a" or element "b", or can it be empty?
<xs:complexType name="ChoiceType">
<xs:choice>
<xs:element name="a" type="type_a"/>
<xs:element name="b" type="type_b"/>
</xs:choice>
</xs:complexType>
Yes, the element governed by an xsd:choice can be empty, if minOccurs="0" is used:
minOccurs="0" can be on the xsd:choice itself.minOccurs="0" can be on all of the children.Related answer: An xsd:choice itself can be empty and would indicate that the element being defined must be empty.
Finally, note that in your example, no, one of a or b must be present because the default for minOccurs is 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With