XML Schema choice ÔªËØ

¶¨ÒåºÍÓ÷¨

XML Schema µÄ choice ÔªËØ½öÔÊÐí°üº¬ÔÚ <choice> ÉùÃ÷ÖеÄÔªËØÖ®Ò»³öÏÖÔÚ°üº¬ÔªËØÖС£

ÔªËØÐÅÏ¢

³öÏÖ´ÎÊý ÔÚ group ºÍ complexType ÔªËØÖÐΪһ´Î£»ÆäËûΪÎÞÏÞÖÆ¡£
¸¸ÔªËØ group¡¢choice¡¢sequence¡¢complexType¡¢restriction (simpleContent)¡¢extension (simpleContent)¡¢restriction (complexContent)¡¢extension (complexContent)
ÄÚÈÝ annotation¡¢any¡¢choice¡¢element¡¢group¡¢sequence

Óï·¨

<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>

(annotation?,(element|group|choice|sequence|any)*)

</choice>

£¨? ·ûºÅÉùÃ÷ÔÚ choice ÔªËØÖУ¬ÔªËؿɳöÏÖÁã´Î»òÒ»´Î£¬* ·ûºÅÉùÃ÷ÔªËØ¿É³öÏÖÁã´Î»ò¶à´Î¡££©

ÊôÐÔ ÃèÊö
id ¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£
maxOccurs ¿ÉÑ¡¡£¹æ¶¨ choice ÔªËØÔÚ¸¸ÔªËØÖпɳöÏÖµÄ×î´ó´ÎÊý¡£¸ÃÖµ¿ÉÒÔÊÇ´óÓÚ»òµÈÓÚÁãµÄÕûÊý¡£Èô²»Ïë¶Ô×î´ó´ÎÊýÉèÖÃÈκÎÏÞÖÆ£¬ÇëʹÓÃ×Ö·û´® "unbounded"¡£ ĬÈÏֵΪ 1¡£
minOccurs ¿ÉÑ¡¡£¹æ¶¨ choice ÔªËØÔÚ¸¸ÔªËØÖпɳöÏÖµÄ×îС´ÎÊý¡£¸ÃÖµ¿ÉÒÔÊÇ´óÓÚ»òµÈÓÚÁãµÄÕûÊý¡£ÈôÒªÖ¸¶¨¸Ã any ×éÊÇ¿ÉÑ¡µÄ£¬Ç뽫´ËÊôÐÔÉèÖÃΪÁã¡£ ĬÈÏֵΪ 1¡£
any attributes ¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈÎºÎÆäËûÊôÐÔ¡£

ʵÀý

<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>

ÉÏÃæµÄÀý×Ó¶¨Òå "person" ÔªËØ±ØÐë°üº¬Ò»¸ö "employee" ÔªËØ»òÒ»¸ö "member" ÔªËØ¡£

VUE