XSD <anyAttribute> အကွက်
- ပြီးလျှင် စာရင်း XSD <any>
- နောက်လိုက် စာရင်း XSD အကွက် ပြောင်းလဲ
<anyAttribute> အာအပ်ဆိုက် အာအပ်ဆိုက် သည် စည်းကြမ်းမှ အသုံးပြုခြင်း မရှိသေးသော အချက်အလက်များ ဖြင့် XML အချက်အလက်များ ဖြင့် ဖွင့်ပြနိုင်သော အရာကို ဖွင့်ပြနိုင်ပါသည်!
<anyAttribute> အာအပ်ဆိုက်
<anyAttribute> အာအပ်ဆိုက် အာအပ်ဆိုက် သည် စည်းကြမ်းမှ အသုံးပြုခြင်း မရှိသေးသော အချက်အလက်များ ဖြင့် XML အချက်အလက်များ ဖြင့် ဖွင့်ပြနိုင်သော အရာကို ဖွင့်ပြနိုင်ပါသည်!
အမျိုးပေါင်းအချက်အလက်တစ်ခုသည် "family.xsd" အမည်ရှိ အမြန်မာအမည်ရှိ XML စည်းကြမ်းမှ နောက်ထပ် အချို့သော အချက်အလက်များ ဖြစ်သည်။ အမြန်မာအမည်ရှိ "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">Jane Smith David Smith
上面这个 XML 文件是有效的,这是因为 schema "family.xsd" 允许我们向 "person" 元素添加属性。
ဒီ <any> နှင့် <anyAttribute> ပုံစံ မှာ ဖွဲ့စည်းထားသော ပြည့်မျှသော အခြေအနေ များ ကို ဖွဲ့စည်းထားပါသည်။ ဒီတို့ မှာ အခြေအနေ အသစ် အသုံးပြုနိုင်သည်။
- ပြီးလျှင် စာရင်း XSD <any>
- နောက်လိုက် စာရင်း XSD အကွက် ပြောင်းလဲ