XML Schema restriction အပ်ခုံး
အသုံးပြု နှင့် ပြောဆို
restriction အပ်ခုံး အချက် သည် simpleType、simpleContent သို့မဟုတ် complexContent အချက် အသုံးပြုသည့် ကန့်သတ်ချက် ကို ကြေညာသည်。
အအုပ်ချုပ်
ဖြစ်ပေါ် | တစ်ကြိမ် |
အဖွဲ့အစည်း | complexContent |
အသုံးပြု | group、all、choice、sequence、attribute、attributeGroup、anyAttribute |
ပုံစံ
<restriction id=ID base=QName any attributes > Content for simpleType: (annotation?,(simpleType?,(minExclusive|minInclusive| maxExclusive|maxInclusive|totalDigits|fractionDigits| length|minLength|maxLength|enumeration|whiteSpace|pattern)*)) Content for simpleContent: (annotation?,(simpleType?,(minExclusive |minInclusive| maxExclusive|maxInclusive|totalDigits|fractionDigits| (length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?, ((attribute|attributeGroup)*,anyAttribute?)) Content for complexContent: (annotation?,(group|all|choice|sequence)?, ((attribute|attributeGroup)*,anyAttribute?)) </restriction>
(? သတ်မှတ်သည့် အမှတ်အသား restriction အပ်ခုံး တွင် အရာတွေ ဖြစ်နိုင် သော်လည်း မပါဘဲ သို့မဟုတ် တစ်ကြိမ် ဖြစ်နိုင်)
အချက် | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
base | 必需。规定在该 schema(或由指定的命名空间指示的其他 schema)中定义的内建数据类型、simpleType 或 complexType 元素的名称。 |
any attributes | အတွက် အရာများ အသုံးပြုခြင်း များ အတွက် အသုံးပြုသော အခြား အသုံးပြုမှု အသုံးပြုသော အခြား အခြေခံ အမှတ်အသား ကို အသုံးပြုသည် |
အမှတ်
အမှတ် 1
ဤအကြောင်းကို လေ့လာသော အမှတ်အသား "age" ကို အသုံးပြုသည်။ "age" အမှတ်အသား က အချက်အလက် ပါဝင်သော အမှတ်အသား ဖြစ်သည်။ အရာများ အသုံးပြုခြင်း မှာ အကြမ်းတက် ၀ မှ ၁၀၀ အထိ ဖြစ်သည်
<xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element>
အမှတ် 2
ဤအကြောင်းကို လေ့လာသော အမှတ်အသား "initials" ကို အသုံးပြုသည်။ "initials" အမှတ်အသား က အချက်အလက် ပါဝင်သော အမှတ်အသား ဖြစ်သည်။ အချက်အလက် အရာများ အတွက် အခွင့်ပြု အကြမ်းတက် အသင်း အချက်အလက် အတွက် အခွင့်ပြု ဖြစ်သည်
<xs:element name="initials"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/> </xs:restriction> </xs:simpleType> </xs:element>
အမှတ် 3
ဤအကြောင်းကို လေ့လာသော အမှတ်အသား "password" ကို အသုံးပြုသည်။ "password" အမှတ်အသား က အချက်အလက် ပါဝင်သော အမှတ်အသား ဖြစ်သည်။ အရာများ အသုံးပြုခြင်း မှာ အကြမ်းတက် ၅ လုပ်အချက် မှ ၈ လုပ်အချက် အထိ ဖြစ်သည်
<xs:element name="password"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:minLength value="5"/> <xs:maxLength value="8"/> </xs:restriction> </xs:simpleType> </xs:element>
အမှတ် 4
ဤအကြောင်းကို လေ့လာသော ပြောင်းလဲထားသော အပြဿာဗိုင်း အမှတ်အသား ကို ပြသည်။ ပြဿာဗိုင်း အမှတ်အသား "Chinese_customer" က ပုံမှန် ပြဿာဗိုင်း အမှတ်အသား "customer" မှ တည်ပြီး နိုင်ငံ အအုပ်အုပ်ချုပ်ရေး အရာများ အတွက် အချက်အလက် အပြင် အရာများ ဖြစ်သည်။ နိုင်ငံ အအုပ်အုပ်ချုပ်ရေး အရာများ အချက်အလက် အရာများ မှာ "China" ဖြစ်သည်
<xs:complexType name="customer"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="Chinese_customer"> <xs:complexContent> <xs:restriction base="customer"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:element name="country" type="xs:string" fixed="China"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>