XML Schema schema ÔªËØ
¶¨ÒåºÍÓ÷¨
schema ÔªËØ¶¨Òå schema µÄ¸ùÔªËØ¡£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý | Ò»´Î |
¸¸ÔªËØ | £¨ÎÞ¸¸ÔªËØ£© |
ÄÚÈÝ | include¡¢import¡¢annotation¡¢redefine¡¢attribute¡¢attributeGroup¡¢element¡¢group¡¢notation¡¢simpleType¡¢complexType |
Óï·¨
<schema id=ID attributeFormDefault=qualified|unqualified elementFormDefault=qualified|unqualified blockDefault=(#all|list of (extension|restriction|substitution)) finalDefault=(#all|list of (extension|restriction|list|union)) targetNamespace=anyURI version=token xmlns=anyURI any attributes > ((include|import|redefine|annotation)*,(((simpleType|complexType| group|attributeGroup)|element|attribute|notation),annotation*)*) </schema>
ÊôÐÔ
id
¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£
attributeFormDefault
¿ÉÑ¡¡£Ôڸà schema µÄÄ¿±êÃüÃû¿Õ¼äÖÐÉùÃ÷µÄÊôÐÔµÄÐÎʽ¡£¸ÃÖµ±ØÐëÊÇÏÂÁÐ×Ö·û´®Ö®Ò»£º "qualified" »ò "unqualified"¡£ ĬÈÏֵΪ "unqualified"¡£
- "unqualified" ָʾÎÞÐëͨ¹ýÃüÃû¿Õ¼äǰ׺ÏÞ¶¨Ä¿±êÃüÃû¿Õ¼äµÄÊôÐÔ¡£
- "qualified" ָʾ±ØÐëͨ¹ýÃüÃû¿Õ¼äǰ׺ÏÞ¶¨Ä¿±êÃüÃû¿Õ¼äµÄÊôÐÔ¡£
elementFormDefault
¿ÉÑ¡¡£Ôڸà schema µÄÄ¿±êÃüÃû¿Õ¼äÖÐÉùÃ÷µÄÔªËØµÄÐÎʽ¡£¸ÃÖµ±ØÐëÊÇÏÂÁÐ×Ö·û´®Ö®Ò»£º "qualified" »ò "unqualified"¡£ ĬÈÏֵΪ "unqualified"¡£
- "unqualified" ָʾÎÞÐëͨ¹ýÃüÃû¿Õ¼äǰ׺ÏÞ¶¨Ä¿±êÃüÃû¿Õ¼äµÄÔªËØ¡£
- "qualified" ָʾ±ØÐëͨ¹ýÃüÃû¿Õ¼äǰ׺ÏÞ¶¨Ä¿±êÃüÃû¿Õ¼äµÄÔªËØ¡£
blockDefault
¿ÉÑ¡¡£¹æ¶¨ÔÚÄ¿±êÃüÃû¿Õ¼äÖÐ element ºÍ complexType ÔªËØÉ쵀 block ÊôÐÔµÄĬÈÏÖµ¡£block ÊôÐÔ·ÀÖ¹¾ßÓÐÖ¸¶¨ÅÉÉúÀàÐ͵ĸ´ÔÓÀàÐÍ£¨»òÔªËØ£©±»ÓÃÀ´´úÌæ¼Ì³ÐµÄ¸´ÔÓÀàÐÍ£¨»òÔªËØ£©¡£¸ÃÖµ¿ÉÒÔ°üº¬ #all »òÕßÒ»¸öÁÐ±í£¬¸ÃÁбíÊÇ extension¡¢restriction »ò substitution µÄ×Ó¼¯£º
- extension - ·Àֹͨ¹ýÀ©Õ¹ÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£
- restriction - ·Àֹͨ¹ýÏÞÖÆÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£
- substitution - ·ÀÖ¹ÔªËØµÄÌæ»»¡£
- #all - ·ÀÖ¹ËùÓÐÅÉÉúµÄ¸´ÔÓÀàÐͱ»ÓÃÀ´Ìæ´ú¸Ã¸´ÔÓÀàÐÍ¡£
finalDefault
¿ÉÑ¡¡£¹æ¶¨Ôڸüܹ¹µÄÄ¿±êÃüÃû¿Õ¼äÖÐ element¡¢simpleType ºÍ complexType ÔªËØµÄ final ÊôÐÔµÄĬÈÏÖµ¡£final ÊôÐÔ·ÀÖ¹ element¡¢simpleType »ò complexType ÔªËØµÄÖ¸¶¨µÄÅÉÉúÀàÐÍ¡£¶ÔÓÚ element ºÍ complexType ÔªËØ£¬¸ÃÖµ¿ÉÒÔ°üº¬ #all »òÒ»¸öÁÐ±í£¬¸ÃÁбíÊÇ extension »ò restriction µÄ×Ó¼¯¡£ ¶ÔÓÚ simpleType ÔªËØ£¬¸ÃÖµ»¹¿ÉÒÔ°üº¬ list ºÍ union£º
- extension - ĬÈÏÇé¿öÏ£¬¸Ã schema ÖеÄÔªËØ²»ÄÜͨ¹ýÀ©Õ¹ÅÉÉú¡£½öÊÊÓÃÓÚ element ºÍ complexType ÔªËØ¡£
- restriction - ·Àֹͨ¹ýÏÞÖÆÅÉÉú¡£
- list - ·Àֹͨ¹ýÁбíÅÉÉú¡£½öÊÊÓÃÓÚ simpleType ÔªËØ¡£
- union - ·Àֹͨ¹ýÁªºÏÅÉÉú¡£½öÊÊÓÃÓÚ simpleType ÔªËØ¡£
- #all - ĬÈÏÇé¿öÏ£¬¸Ã schema ÖеÄÔªËØ²»ÄÜͨ¹ýÈκη½·¨ÅÉÉú¡£
targetNamespace
¸Ã schema µÄÃüÃû¿Õ¼äµÄ URI ÒýÓ᣻¹¿ÉÒÔ·ÖÅä¸ÃÃüÃû¿Õ¼äµÄǰ׺¡£Èç¹ûûÓзÖÅäÈκÎǰ׺£¬Ôò¸ÃÃüÃû¿Õ¼äµÄ schema ×é¼þ¿ÉÒԺͷÇÏÞ¶¨µÄÒýÓÃÒ»ÆðʹÓá£
version
¿ÉÑ¡¡£¹æ¶¨ schema µÄ°æ±¾¡£
xmlns
¹æ¶¨ÔÚ´Ë schema ÖÐʹÓõÄÒ»¸ö»ò¶à¸öÃüÃû¿Õ¼äµÄ URI ÒýÓá£Èç¹ûûÓзÖÅäǰ׺£¬¸ÃÃüÃû¿Õ¼äµÄ schema ×é¼þ¿ÉÓëδÏÞÖÆµÄÒýÓÃʹÓá£
any attributes
¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈÎºÎÆäËûÊôÐÔ¡£
ʵÀý
Àý×Ó 1
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="values" type="xs:string"> </xs:schema>
Àý×Ó 2
ÔÚ±¾ÀýÖУ¬http://www.w3.org/2001/XMLSchema ÃüÃû¿Õ¼äÖÐ schema ×é¼þ (element name, type) ÊÇδÏÞÖÆµÄ£¬¶ø http://www.w3school.com.cn/w3schoolschema (mystring) ÊÇͨ¹ý wsc ǰ׺ÏÞÖÆµÄ£º
<?xml version="1.0"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:wsc="http://www.w3school.com.cn/w3schoolschema"> <element name="fname" type="wsc:mystring"/> </schema>