XML Schema complexType ÔªËØ

¶¨ÒåºÍÓ÷¨

complexType ÔªËØ¶¨Ò帴ÔÓÀàÐÍ¡£¸´ÔÓÀàÐ͵ÄÔªËØÊǰüº¬ÆäËûÔªËØºÍ/»òÊôÐ﵀ XML ÔªËØ¡£

ÔªËØÐÅÏ¢

³öÏÖ´ÎÊý Ôڼܹ¹ÄÚΪÎÞÏÞÖÆ£»ÔÚÔªËØÄÚΪһ´Î¡£
¸¸ÔªËØ element¡¢redefine¡¢schema
ÄÚÈÝ annotation¡¢simpleContent¡¢complexContent¡¢group¡¢all¡¢choice¡¢sequence¡¢attribute¡¢attributeGroup¡¢anyAttribute

Óï·¨

<complexType
id=ID 
name=NCName 
abstract=true|false 
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>

(annotation?,(simpleContent|complexContent|((group|all| 
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))

</complexType>

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

ÊôÐÔ

id

¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£

name

¿ÉÑ¡¡£¹æ¶¨ÔªËصÄÃû³Æ¡£

abstract

¿ÉÑ¡¡£¹æ¶¨ÔÚʵÀýÎĵµÖÐÊÇ·ñ¿ÉÒÔʹÓø´ÔÓÀàÐÍ¡£Èç¹û¸ÃֵΪ true£¬ÔòÔªËØ²»ÄÜÖ±½ÓʹÓøø´ÔÓÀàÐÍ£¬¶øÊDZØÐëʹÓôӸø´ÔÓÀàÐÍÅÉÉúµÄ¸´ÔÓÀàÐÍ¡£ ĬÈÏֵΪ false¡£

mixed

¿ÉÑ¡¡£¹æ¶¨ÊÇ·ñÔÊÐí×Ö·ûÊý¾Ý³öÏÖÔڸø´ÔÓÀàÐ͵Ä×ÓÔªËØÖ®¼ä¡£ ĬÈÏֵΪ false¡£

  • Èç¹û simpleContent ÔªËØÊÇ×ÓÔªËØ£¬Ôò²»ÔÊÐí mixed ÊôÐÔ¡£
  • Èç¹û complexContent ÔªËØÊÇ×ÓÔªËØ£¬Ôò¸Ã mixed ÊôÐԿɱ» complexContent ÔªËØµÄ mixed ÊôÐÔÖØÐ´¡£

block

¿ÉÑ¡¡£·ÀÖ¹¾ßÓÐÖ¸¶¨ÅÉÉúÀàÐ͵ĸ´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£¸ÃÖµ¿ÉÒÔ°üº¬ #all »òÕßÒ»¸öÁÐ±í£¬¸ÃÁбíÊÇ extension »ò restriction µÄ×Ó¼¯£º

  • extension - ·Àֹͨ¹ýÀ©Õ¹ÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£
  • restriction - ·Àֹͨ¹ýÏÞÖÆÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£
  • #all - ·ÀÖ¹ËùÓÐÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£

final

¿ÉÑ¡¡£·ÀÖ¹´Ó¸Ã complexType ÔªËØÅÉÉúÖ¸¶¨µÄÀàÐÍ¡£¸ÃÖµ¿ÉÒÔ°üº¬ #all »òÕßÒ»¸öÁÐ±í£¬¸ÃÁбíÊÇ extension »ò restriction µÄ×Ó¼¯¡£

  • extension - ·Àֹͨ¹ýÀ©Õ¹ÅÉÉú¡£
  • restriction - ·Àֹͨ¹ýÏÞÖÆÅÉÉú¡£
  • #all - ·ÀÖ¹ËùÓÐÅÉÉú£¨À©Õ¹ºÍÏÞÖÆ£©¡£

any attributes

¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈÎºÎÆäËûÊôÐÔ¡£

ʵÀý

Àý×Ó 1

ÏÂÃæµÄÀý×ÓÓµÓÐÒ»¸öÃûΪ "note" µÄ¸´ÔÓÀàÐÍÔªËØ£º

<xs:element name="note">
    <xs:complexType>
      <xs:sequence>
	<xs:element name="to" type="xs:string"/>
	<xs:element name="from" type="xs:string"/>
	<xs:element name="heading" type="xs:string"/>
	<xs:element name="body" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
</xs:element>

Àý×Ó 2

ÏÂÃæµÄÀý×ÓÖÐÓÐÒ»¸ö¸´ÔÓÀàÐÍ "fullpersoninfo"£¬Ëüͨ¹ýʹÓÃÈý¸ö²¹³äµÄÔªËØ (address¡¢city ºÍ country) ¶Ô¼Ì³ÐµÄÀàÐͽøÐÐÀ©Õ¹£¬ÓÉÁíÒ»¸ö¸´ÔÓÀàÐÍ "personinfo" ÅÉÉú¶øÀ´£º

<xs:element name="employee" type="fullpersoninfo"/>

<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="fullpersoninfo">
  <xs:complexContent>
    <xs:extension base="personinfo">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

ÔÚÉÏÃæµÄÀý×ÓÖУ¬ÉÏÃæµÄ "employee" ÔªËØ±ØÐ밴˳Ðò°üº¬ÏÂÁÐÔªËØ£º"firstname", "lastname", "address", "city" ÒÔ¼° "country"¡£

VUE