XML Schema°ïÖúÎĵµ3
XML Schema attributeGroup ÔªËØ
¶¨ÒåºÍÓ÷¨
attributeGroup ÔªËØÓÃÓÚ¶ÔÊôÐÔÉùÃ÷½øÐÐ×éºÏ£¬ÕâÑùÕâЩÉùÃ÷¾ÍÄܹ»ÒÔ×éºÏµÄÐÎʽºÏ²¢µ½¸´ÔÓÀàÐÍÖС£
ÔªËØÐÅÏ¢
³öÏÖ´ÎÊý
ÎÞÏÞÖÆ
¸¸ÔªËØ
attributeGroup¡¢complexType¡¢schema¡¢restriction (simpleContent)¡¢extension (simpleContent)¡¢restriction (complexContent)¡¢extension (complexContent)
ÄÚÈÝ
annotation¡¢attribute¡¢attributeGroup¡¢anyAttribute
Óï·¨
<attributeGroup
id=ID
name=NCName
ref=QName
any attributes
>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>
£¨? ·ûºÅÉùÃ÷ÔÚ attributeGroup ÔªËØÖУ¬ÔªËؿɳöÏÖÁã´Î»òÒ»´Î£¬* ·ûºÅÉùÃ÷ÔªËØ¿É³öÏÖÁã´Î»ò¶à´Î¡££©
ÊôÐÔ
ÃèÊö
id
¿ÉÑ¡¡£¹æ¶¨¸ÃÔªËØµÄΨһµÄ ID¡£
name
¿ÉÑ¡¡£¹æ¶¨ÊôÐÔ×éµÄÃû³Æ¡£name ºÍ ref ÊôÐÔ²»ÄÜͬʱ³öÏÖ¡£
ref
¿ÉÑ¡¡£¹æ¶¨¶ÔÖ¸¶¨µÄÊôÐÔ×éµÄÒýÓá£name ºÍ ref ÊôÐÔ²»ÄÜͬʱ³öÏÖ¡£
any attributes
¿ÉÑ¡¡£¹æ¶¨´øÓÐ non-schema ÃüÃû¿Õ¼äµÄÈÎºÎÆäËûÊôÐÔ¡£
ʵÀý
<xs:attributeGroup name="personattr">
<xs:attribute name="attr1" type="string"/>
<xs:attribute name="attr2" type="integer"/>
</xs:attributeGroup>
<xs:complexType name="person">
<xs:attributeGroup ref="personattr"/>
</xs:complexType>
ÉÏÃæµÄÀý×Ó¶¨ÒåÁËÒ»¸öÃûΪ "personattr" µÄÊôÐÔ×飬ÔÚÃûΪ "person" µÄ¸´ÔÓÀàÐÍÖÐʹÓá£
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
maxOccu
Ïà¹ØÎĵµ£º
(Ò») ÏȽ²Ò»ÏÂXMLÖеÄÎïÊâ×Ö·û£¬ÊÖ¶¯ÌîдʱעÒâһϡ£
×Ö·û ×Ö·ûʵÌå
& ......
XML¶¨Ò壺Óɱê¼Ç¼°ÆäËù±ê¼ÇµÄÄÚÈݹ¹³ÉµÄÎı¾Îļþ¡£
XML×÷ÓãºÓÃÀ´ÃèÊöÊý¾ÝµÄ½á¹¹£¬ÓÐЧ·ÖÀëÊý¾ÝµÄ½á¹¹ºÍ±íʾ£¬¿ÉÒÔ×÷ΪÊý¾Ý½»»»µÄ±ê×¼¸ñʽ¡£
XMLÌØµã£º1¡¢¿ÉÒÔ×Ô¶¨Òå±ê¼Ç£¬±ê¼ÇÃû³ÆÊǶÔËù±ê¼ÇµÄÊý¾ÝÄÚÈݺ¬ÒåµÄ³éÏ󣬶ø²»ÊÇÊý¾ÝµÄÏÔʾ¸ñʽ¡£
&n ......
C#
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/Config/User_yhlx_Jb.xml"));
DataView dv = ds.Tables[0].DefaultView;
//dv.RowFilter = "State=0";
this.DropDownList1.DataSource = dv;
this.DropDownList1.DataTextField = "text";
this ......
protected void Button1_Click(object sender, EventArgs e)
{
//Ϊresponse(star)½Úµã ºÍ Cabins(f) cabin½Úµã·Ö±ðÌí¼Ó¸ö
&nbs ......
XML Schema ²Î¿¼ÊÖ²á
XSD ÔªËØ
ÔªËØ
½âÊÍ
all
¹æ¶¨×ÓÔªËØÄܹ»ÒÔÈÎÒâ˳Ðò³öÏÖ£¬Ã¿¸ö×ÓÔªËØ¿É³öÏÖÁã´Î»òÒ»´Î¡£
annotation
annotation ÔªËØÊÇÒ»¸ö¶¥²ãÔªËØ£¬¹æ¶¨ schema µÄ×¢ÊÍ¡£
any
ʹ´´×÷Õß¿ÉÒÔͨ¹ýδ±» schema ¹æ¶¨µÄÔªËØÀ´À©Õ¹ XML Îĵµ¡£
anyAttribute
Ê ......