XML Schema 参考手册 完整 XML Schema 参考手册 The choice element of XML Schema allows only one of the elements contained in the declaration to appear in the containing element. 父元素: Group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent) (? Symbol declaration in the choice element, the element can appear zero or once, and the* symbol declares that the element can appear zero or more times. ) Attribute Description Id Optional. Specifies the unique ID of the element. MaxOccurs Optional. Specifies the maximum number of times an choice element can appear in the parent element. The value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum number of times, use the string “unbounded”. The default value is 1. MinOccurs Optional. Specifies the minimum number of times an choice element can appear in the parent element. The value can be an integer greater than or equal to zero. To specify that the any group is optional, set this property to zero. The default value is 1. Any attributes Optional. Specifies any other attributes with the non-schema namespace. The above example defines that the “person” element must contain either a “employee” element or a “member” element.Definition and usage ¶
Element information ¶
Grammar ¶
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
*any attributes*
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
Example 1 ¶
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>