XSD အညွှန်းကိန်း များ
အညွှန်းများပါရှိသော စာရွက်စာတမ်းများတွင် အစိတ်အပိုင်းများကို မည်သို့အသုံးပြုရမည်ကို ကျွန်ုပ်တို့ ထိန်းချုပ်နိုင်သည်။
အညွှန်းများ
ညွှန်ကိန်းခုနစ်ခုရှိသည်။
မှာယူမှု အညွှန်းများ-
- အားလုံး
- ရွေးချယ်မှု
- တစ်ဆက်တည်း
ဖြစ်ပွားမှုအညွှန်းများ-
- အများဆုံးဖြစ်ပွားသည်။
- ဖြစ်ပေါ်ခြင်း
အုပ်စုအညွှန်းများ-
- အဖွဲ့နာမည်
- attributeGroup အမည်
အမိန့်ညွှန်းကိန်းများ
အမှာစာညွှန်းကိန်းများကို ဒြပ်စင်များ၏ အစီအစဥ်ကို သတ်မှတ်ရန် အသုံးပြုသည်။
အညွှန်းအားလုံး
<all> ညွှန်ပြချက်သည် ကလေးဒြပ်စင်များသည် မည်သည့်အစီအစဥ်တွင်မဆို ပေါ်လာနိုင်သည်ကို သတ်မှတ်ပေးပြီး ကလေးဒြပ်စင်တစ်ခုစီသည် တစ်ကြိမ်သာ ဖြစ်ပေါ်ရပါမည်-
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
မှတ်ချက်- <all> ညွှန်ကိန်းကို အသုံးပြုသည့်အခါ သင်သည် <minOccurs> အညွှန်းကိန်းကို 0 သို့မဟုတ် 1 သို့ သတ်မှတ်နိုင်ပြီး <maxOccurs> အညွှန်းကိန်းကို 1 ဟုသာ သတ်မှတ်နိုင်သည် (<minOccurs> နှင့် <maxOccurs> ကို နောက်ပိုင်းတွင် ဖော်ပြပါမည်)။
ရွေးချယ်မှုအညွှန်း
<choice> ညွှန်ကိန်းသည် ကလေးဒြပ်စင်တစ်ခု သို့မဟုတ် အခြားအရာတစ်ခု ဖြစ်ပေါ်လာနိုင်သည်ဟု သတ်မှတ်သည်-
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>
Sequence Indicator
<sequence> ညွှန်ပြချက်သည် ကလေးဒြပ်စင်များသည် သီးခြားအစီအစဥ်တစ်ခုတွင် ပေါ်လာရမည်ဟု သတ်မှတ်သည်-
<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:complexType>
</xs:element>
ဖြစ်ပွားမှုအညွှန်းကိန်းများ
ဒြပ်စင်တစ်ခု မည်မျှဖြစ်ပွားနိုင်သည်ကို သတ်မှတ်ရန် ပေါ်ပေါက်မှုအညွှန်းများကို အသုံးပြုသည်။
မှတ်ချက်- "Order" နှင့် "Group" ညွှန်ကိန်းများအားလုံး (မည်သည့်၊ မဆို၊ ရွေးချယ်မှု၊ အတွဲ၊ အဖွဲ့အမည်နှင့် အဖွဲ့ရည်ညွှန်းချက်) အတွက် maxOccurs နှင့် minOccurs အတွက် မူရင်းတန်ဖိုးမှာ 1 ဖြစ်သည်။
maxOccurs အညွှန်း
<maxOccurs> ညွှန်ကိန်းသည် ဒြပ်စင်တစ်ခု ဖြစ်ပေါ်နိုင်သည့် အများဆုံးအကြိမ်အရေအတွက်ကို သတ်မှတ်သည်-
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string" maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
</xs:element>
အထက်ဖော်ပြပါ ဥပမာတွင် "child_name" ဒြပ်စင်သည် အနည်းဆုံးတစ်ကြိမ် (minOccurs အတွက် မူရင်းတန်ဖိုးမှာ 1) နှင့် "လူ" ဒြပ်စင်တွင် အများဆုံး ဆယ်ဆအထိ ဖြစ်နိုင်ကြောင်း ဖော်ပြသည်။
minOccurs အညွှန်း
<minOccurs> ညွှန်ကိန်းသည် ဒြပ်စင်တစ်ခုဖြစ်ပေါ်လာနိုင်သည့် အနည်းဆုံးအကြိမ်အရေအတွက်ကို သတ်မှတ်သည်-
<xs:element name="person">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string"
maxOccurs="10" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
အထက်ဖော်ပြပါ ဥပမာတွင် "child_name" ဒြပ်စင်သည် အနည်းဆုံး သုညကြိမ်နှင့် "လူ" ဒြပ်စင်တွင် အများဆုံး ဆယ်ဆအထိ ဖြစ်နိုင်ကြောင်း ဖော်ပြသည်။
အကြံပြုချက်- ဒြပ်စင်တစ်ခုအား အကြိမ်ရေ အကန့်အသတ်မရှိ ပေါ်လာစေရန် ခွင့်ပြုရန် maxOccurs="unbounded" ကြေညာချက်ကို အသုံးပြုပါ-
အလုပ်နမူနာ
"Myfamily.xml" ဟုခေါ်သော XML ဖိုင်တစ်ခု-
<?xml version="1.0" encoding="UTF-8"?>
<persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="family.xsd">
<person>
<full_name>Hege Refsnes</full_name>
<child_name>Cecilie</child_name>
</person>
<person>
<full_name>Tove Refsnes</full_name>
<child_name>Hege</child_name>
<child_name>Stale</child_name>
<child_name>Jim</child_name>
<child_name>Borge</child_name>
</person>
<person>
<full_name>Stale Refsnes</full_name>
</person>
</persons>
အထက်ဖော်ပြပါ XML ဖိုင်တွင် "persons" ဟု အမည်ပေးထားသော အမြစ်ဒြပ်စင်တစ်ခု ပါရှိသည်။ ဤအမြစ်ဒြပ်စင်အတွင်းတွင် ကျွန်ုပ်တို့သည် "လူ" ဒြပ်စင်သုံးခုကို သတ်မှတ်ပေးထားသည်။ "လူ" ဒြပ်စင်တစ်ခုစီတွင် "ful_name" ဒြပ်စင်တစ်ခုစီပါရှိရမည်ဖြစ်ပြီး ၎င်းတွင် "child_name" ဒြပ်စင်ငါးခုအထိ ပါဝင်နိုင်သည်။
ဤသည်မှာ schema ဖိုင် "family.xsd" ဖြစ်သည်-
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string"
minOccurs="0" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
အုပ်စုအညွှန်းများ
ဆက်စပ်ဒြပ်စင်အစုများကို သတ်မှတ်ရန် အုပ်စုအညွှန်းများကို အသုံးပြုသည်။
ဒြပ်စင်အုပ်စုများ
အုပ်စုများကို ဤကဲ့သို့သော အုပ်စုကြေငြာချက်ဖြင့် Elements အုပ်စုများကို သတ်မှတ်သည်-
<xs:group name="groupname">
...
</xs:group>
အဖွဲ့ကြေငြာချက်အတွင်း အားလုံးကို၊ ရွေးချယ်မှု သို့မဟုတ် အတွဲလိုက်ဒြပ်စင်တစ်ခုကို သင်သတ်မှတ်ရပါမည်။ အောက်ဖော်ပြပါ ဥပမာသည် တိကျသော sequence တွင် ဖြစ်ပေါ်လာရမည့် ဒြပ်စင်အုပ်စုတစ်စုကို သတ်မှတ်ပေးသည့် "persongroup" ဟုခေါ်သော အုပ်စုကို အဓိပ္ပါယ်ဖွင့်ဆိုသည်-
<xs:group name="persongroup">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="birthday" type="xs:date"/>
</xs:sequence>
</xs:group>
အဖွဲ့တစ်ခုကို သင်သတ်မှတ်ပြီးနောက်၊ ၎င်းကို ဤကဲ့သို့သော အခြားအဓိပ္ပါယ်ဖြင့် ကိုးကားနိုင်သည်-
<xs:group name="persongroup">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="birthday" type="xs:date"/>
</xs:sequence>
</xs:group>
<xs:element name="person" type="personinfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:group ref="persongroup"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
ရည်ညွှန်းချက်အုပ်စုများ
Attribute အုပ်စုများကို ဤကဲ့သို့သော attributeGroup ကြေငြာချက်ဖြင့် သတ်မှတ်သည်-
<xs:attributeGroup name="groupname">
...
</xs:attributeGroup>
အောက်ဖော်ပြပါ ဥပမာသည် "personattrgroup" ဟု အမည်ပေးထားသော အရည်အချင်းအုပ်စုတစ်ခုကို သတ်မှတ်ဖော်ပြသည်-
<xs:attributeGroup name="personattrgroup">
<xs:attribute name="firstname" type="xs:string"/>
<xs:attribute name="lastname" type="xs:string"/>
<xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>
အရည်အချင်းအုပ်စုတစ်ခုကို သင်သတ်မှတ်ပြီးနောက်၊ ၎င်းကို ဤကဲ့သို့သော အခြားအဓိပ္ပါယ်ဖွင့်ဆိုချက်ဖြင့် ကိုးကားနိုင်သည်-
<xs:attributeGroup name="personattrgroup">
<xs:attribute name="firstname" type="xs:string"/>
<xs:attribute name="lastname" type="xs:string"/>
<xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>
<xs:element name="person">
<xs:complexType>
<xs:attributeGroup ref="personattrgroup"/>
</xs:complexType>
</xs:element>