XSD <anyAttribute> အကွက်တိုက်
- အရှေ့စာရင်း XSD <any>
- နောက်ပိုင်း စာရင်း XSD အကွက်တိုက် အစားပြု
<anyAttribute> အအုပ်အချုပ် သည် အယူအဆ မပြင်ဆင်ထားသော အချုပ်အချုပ် အမှတ်အသင်း ကို အပျက်အစီးပြုနိုင်သော အရာဖြစ်သည်။
<anyAttribute> အအုပ်အချုပ်
<anyAttribute> အအုပ်အချုပ် သည် အယူအဆ မပြင်ဆင်ထားသော အချုပ်အချုပ် အမှတ်အသင်း ကို အပျက်အစီးပြုနိုင်သော အရာဖြစ်သည်။
အမှတ်ပြုထားသော အကျယ်းအဖြင့် "family.xsd" အမည်ရှိ အယူအဆရှိ အယူအဆများ တစ်ခု မှ အချို့သော အစိတ်အပိုင်းများ ကို ပြသထားသည်။ ဤ "person" အအုပ်အချုပ် အတွက် အကြောင်းကြားချက် ကို ပြန်လိုက်သည်။ <anyAttribute> အအုပ်အချုပ် ကို အသုံးပြုလျှင် "person" အအုပ်အချုပ် အတွင်း အခြား အချုပ်အချုပ် အရာများ ကို အသုံးပြုနိုင်ပါသည်။
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> <xs:anyAttribute/> </xs:complexType> </xs:element>
ဤအခါ "gender" သွင်းစား ကို "person" အအုပ်အစု ကို ဖွံ့ဖြိုးပေးရန် ကျွန်တော်တို့ ကြိုးစားလျှက် ဖွံ့ဖြိုးပေးရပါသည်။ ဤ schema ဖော်ပြချက် ရေးသားသူ က "gender" သွင်းစား ကို ကြေညာခြင်း မရှိဘဲ ဖြစ်နေသေးသည်။
ဤ schema ဖော်ပြချက် အမှတ် "attribute.xsd" ကို ကြည့်ပါ:
<?xml version="1.0" encoding="ISO-8859-1"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.codew3c.com" xmlns="http://www.codew3c.com" elementFormDefault="qualified"> <xs:attribute name="gender"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="male|female"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:schema>
ဤ XML အမှတ် "Myfamily.xml" သည် မတူညီသော schema များ "family.xsd" နှင့် "attribute.xsd" မှ အသုံးပြုပါသည်:
<?xml version="1.0" encoding="ISO-8859-1"?> <persons xmlns="http://www.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://www.microsoft.com family.xsd http://www.codew3c.com attribute.xsd"> <person gender="female"> <firstname>Jane</firstname> <lastname>Smith</lastname> </person> <person gender="male"> <firstname>David</firstname> <lastname>Smith</lastname> </person>
上面这个 XML 文件是有效的,这是因为 schema "family.xsd" 允许我们向 "person" 元素添加属性。
<any> နှင့် <anyAttribute> ကို အကြောင်းကျမ်း ပြင်းထန်စွာ ပြုလုပ်နိုင်သည်။ အကြောင်းကျမ်း အချက်အလက် အသုံးပြုခြင်း ဖြင့် အကွက်တိုက် အချက်အလက် မပါဘဲ ပြင်းထန်စွာ ပေါင်းစပ်နိုင်သည်။
- အရှေ့စာရင်း XSD <any>
- နောက်ပိုင်း စာရင်း XSD အကွက်တိုက် အစားပြု