XML Schema unique ÔªËØ
¶¨ÒåºÍÓ÷¨
unique ÔªËØÖ¸¶¨ÊôÐÔ»òÔªËØÖµ£¨»òÕßÊôÐÔ»òÔªËØÖµµÄ×éºÏ£©ÔÚÖ¸¶¨·¶Î§ÄÚ±ØÐëÊÇΨһµÄ¡£ ¸ÃÖµ±ØÐëΨһ»òΪÁã¡£
unique ÔªËØ±ØÐ밴˳Ðò°üº¬ÏÂÁÐÔªËØ£º
selector ÔªËØ
selector ÔªËØ°üº¬ XPath ±í´ïʽ£¬Ö¸¶¨Ò»¸öÔªËØ¼¯£¬ÔÚÆäÖÐÓÉ field ÔªËØÖ¸¶¨µÄÖµ±ØÐëΨһ¡£
±ØÐëÓÐÒ»¸öÇÒÖ»ÓÐÒ»¸ö selector ÔªËØ¡£
field ÔªËØ
ÿһ¸ö field ÔªËØ¾ù°üº¬Ò»¸ö XPath ±í´ïʽ£¬Ö¸¶¨¶ÔÓÚÓÉ selector ÔªËØÖ¸¶¨µÄÔªËØ¼¯¶øÑÔ±ØÐëΨһµÄÖµ£¨ÊôÐÔ»òÔªËØÖµ£©¡£
Èç¹ûÓжà¸ö field ÔªËØ£¬Ôò field ÔªËØµÄ×éºÏ±ØÐëÊÇΨһµÄ¡£ ÔÚ´ËÇé¿öÏ£¬µ¥¸ö field ÔªËØµÄÖµ¶ÔÓÚÑ¡¶¨ÔªËز»Ò»¶¨ÊÇΨһµÄ£¬µ«ËùÓÐ×ֶεÄ×éºÏ±ØÐëÊÇΨһµÄ¡£
±ØÐëÓÐÒ»¸ö»ò¶à¸ö field ÔªËØ¡£
ÔªËØÐÅÏ¢
| ³öÏÖ´ÎÊý | Ò»´Î |
| ¸¸ÔªËØ | element |
| ÄÚÈÝ | annotation¡¢field¡¢selector |
Óï·¨
<unique id=ID name=NCName any attributes > (annotation?,(selector,field+)) </unique>
£¨? ·ûºÅÉùÃ÷ÔÚ unique ÔªËØÖиÃÔªËØ¿É³öÏÖÁã´Î»òÒ»´Î¡££©
| ÊôÐÔ | ÃèÊö |
|---|---|
| id | ¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£ |
| name | ±ØÐ衣Ϊ¸ÃÔªËØÖ¸¶¨Ãû³Æ¡£ |
| any attributes | ¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈÎºÎÆäËûÊôÐÔ¡£ |
ʵÀý
Àý×Ó 1
±¾ÀýÊÇÒ»¸öºÏ²¢ÁËÁ½¸ö¼òµ¥ÀàÐ͵ļòµ¥ÀàÐÍ£º
<xs:element name="jeans_size">
<xs:simpleType>
<xs:union memberTypes="sizebyno sizebystring" />
</xs:simpleType>
</xs:element>
<xs:simpleType name="sizebyno">
<xs:restriction base="xs:positiveInteger">
<xs:maxInclusive value="42"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="sizebystring">
<xs:restriction base="xs:string">
<xs:enumeration value="small"/>
<xs:enumeration value="medium"/>
<xs:enumeration value="large"/>
</xs:restriction>
</xs:simpleType>