XML Schema simpleType ÔªËØ

¶¨ÒåºÍÓ÷¨

simpleType ÔªËØ¶¨ÒåÒ»¸ö¼òµ¥ÀàÐÍ£¬¹æ¶¨Óë¾ßÓд¿Îı¾ÄÚÈݵÄÔªËØ»òÊôÐÔµÄÖµÓйصÄÐÅÏ¢ÒÔ¼°¶ÔËüÃǵÄÔ¼Êø¡£

ÔªËØÐÅÏ¢

³öÏÖ´ÎÊý ÎÞÏÞÖÆ
¸¸ÔªËØ attribute¡¢element¡¢list¡¢restriction (simpleType)¡¢schema¡¢union
ÄÚÈÝ annotation¡¢list¡¢restriction (simpleType)¡¢union

Óï·¨

<simpleType
id=ID
name=NCName
any attributes
>

(annotation?,(restriction|list|union))

</simpleType>

(? ·ûºÅÉùÃ÷ÔªËØ¿ÉÔÚ simpleType ÔªËØÖгöÏÖÁã´Î»òÒ»´Î¡£)

ÊôÐÔ ÃèÊö
id ¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£
name

ÀàÐÍÃû³Æ¡£ ¸ÃÃû³Æ±ØÐëÊÇÔÚ XML ÃüÃû¿Õ¼ä¹æ·¶Öж¨ÒåµÄÎÞðºÅÃû³Æ (NCName)¡£

Èç¹ûÖ¸¶¨£¬¸ÃÃû³ÆÔÚËùÓÐ simpleType ºÍ complexType ÔªËØÖ®¼ä±ØÐëÊÇΨһµÄ¡£

Èç¹û simpleType ÔªËØÊÇ schema ÔªËØµÄ×ÓÔªËØ£¬ÔòΪ±ØÑ¡ÏÔÚÆäËûʱºòÔòÊDz»ÔÊÐíµÄ¡£

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

ʵÀý

Àý×Ó 1

±¾ÀýÉùÃ÷ "age" ÔªËØÊÇÒ»¸ö´øÓÐÔ¼ÊøµÄ¼òµ¥ÀàÐÍ¡£age µÄÖµ²»ÄÜСÓÚ 0 »ò´óÓÚ 100£º

<xs:element name="age">
  <xs:simpleType>
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="100"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>
VUE