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 Document¡£Õâ¾ÍÉæ¼°µ½XML×Ö·û´®ºÍXml DocumentµÄת»»ÎÊÌ⣬˵°×ÁËÕâÊǸöºÜ¼òµ¥µÄÎÊÌ⣬±¾Îľ͸÷ÖÖXML½âÎöÆ÷·Ö±ðÁоÙÈçÏ£¬ÒÔ·½±ã×Ô¼º½ñºó²éÔÄ¡£
Ò»¡¢Ê¹ÓÃ×îÔʼµÄjavax.xml.parsers£¬±ê×¼µÄjdk api
// ×Ö·û´®×ªXML
String xmlStr = "......";
S ......
C#¶ÁÈ¡XML×ÊÁÏ
Ò» C#¶ÁÈ¡XML×ÊÁÏ
À©³ä±ê¼ÇÓïÑÔXML£¨eXtensible Markup Language£©£¬ÊÇÓÉWÈýC»ú¹ØÖƶ©µÄ¡£×öΪÓÃÒÔ´úÌæHTMLÓïÑÔµÄÒ»ÖÖÐÂʽµÄ±ê¼ÇÓïÑÔ£¬XMLÄÚ²¿ÓÐןܶà¸ù±¾»ù×¼£¬XMLÄËÊǾ¹ýÓëÕâЩÏà¸É»ù×¼µØ×éºÏ£¬Ó¦ÓÃÓÚ¿Æѧ¼ÆËã¡¢µç×Ó³ö°æ¡¢¶àýÌåϵÌåÀý×÷ºÍµç×ÓÉÌÎñµÄ¡£C££×÷ΪһÖÖÐÂʽµÄ³ÌÐòÓïÑÔ£¬ÊÇ.Net¹¹¼ÜµÄÒ»¸öÖ ......
<?xml version="1.0" encoding="UTF-8"?>
<root>
<person id="1">
<username >xiaoma</username>
<password>xiaoma</password>
</person>
<person id="2">
<username>manager</username> ......
protected void Button1_Click(object sender, EventArgs e)
{
//Ϊresponse(star)½Úµã ºÍ Cabins(f) cabin½Úµã·Ö±ðÌí¼Ó¸ö
&nbs ......