XML Schema elemento scelta
Definizione e utilizzo
L'elemento di scelta dello schema XML è consentito solo a contenere in
Informazioni elemento
- elemento padre: gruppo, scelta, sequenza, complexType , restrizione (sia simpleContent e complexContent), estensione (sia simpleContent e complexContent)
grammatica
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
(? Sign dichiara che l'elemento scelta, l'elemento può verificarsi zero o una volta, * segno dichiara che l'elemento può verificarsi zero o più volte.)
属性 | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
maxOccurs | 可选。规定 choice 元素在父元素中可出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。 默认值为 1。 |
minOccurs | 可选。规定 choice 元素在父元素中可出现的最小次数。该值可以是大于或等于零的整数。若要指定该 any 组是可选的,请将此属性设置为零。 默认值为 1。 |
any attributes | 可选。规定带有 non-schema 命名空间的任何其他属性。 |
esempio 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>
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>
Esempi di suddetta definizione di elemento "persona" devono contenere un elemento "dipendente" o un elemento di "membro".
XML completo Schema di riferimento