XML Schema restriction အအုပ်အဖွဲ့

အသုံးပြုခြင်း နှင့် အကျိုးသမား

restriction အအုပ်အဖွဲ့ သည် simpleType、simpleContent သို့မဟုတ် complexContent ကို အခြေခံ သတ်မှတ်ထားသော ကတိ ကို အစိုးရနိုင်သည်။

အအုပ်အဖွဲ့ သတင်း

ပေါ်ထားသည် တစ်ကြိမ်
အဖွဲ့ဝင် complexContent
ပါဝင်သည် group、all、choice、sequence、attribute、attributeGroup、anyAttribute

လိုက်နှိုင်း

<restriction
id=ID
base=QName
ဗီဇ
>
simpleType အတွက် ပါဝင်သော အချက်အလက်:
(annotation?,(simpleType?,(minExclusive|minInclusive| 
maxExclusive|maxInclusive|totalDigits|fractionDigits|
length|minLength|maxLength|enumeration|whiteSpace|pattern)*))
simpleContent အတွက် ပါဝင်သော အချက်အလက်:
(annotation?,(simpleType?,(minExclusive |minInclusive| 
maxExclusive|maxInclusive|totalDigits|fractionDigits|
(length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?, 
((attribute|attributeGroup)*,anyAttribute?))
complexContent အတွက် ပါဝင်သော အချက်အလက်:
(annotation?,(group|all|choice|sequence)?,
((attribute|attributeGroup)*,anyAttribute?))
</restriction>

(? အမှတ်သုံးစက္ခ ကို restriction အအုပ်အဖွဲ့၌ အဆိုပါ အအုပ်အဖွဲ့ ကို အပြီးအဝှမ်း သို့မဟုတ် တစ်ကြိမ် ပြီးနောက် ပေါ်ထားသည်။)

ဗီဇ ဖော်ပြ
id ရွေးချယ်နိုင်သည်။ အဆိုပါ အအုပ်အဖွဲ့၏ ကိုယ်တိုင်အမည်ပြုထားသော ID ကို အစိုးရနိုင်သည်။
base လိုအပ်သည်။ ထို schema တွင် (သို့မဟုတ် သတ်မှတ်ထားသော အမည်အရေးအသုံးပြုသော schema) တွင် အဆိုပါ ဗီဇကို ဒါကို အမည်ပြုထားသည်။
ဗီဇ ရွေးချယ်နိုင်သည်။ non-schema အမည်အရေးအသုံးပြုသော အခြား ဗီဇကို အစိုးရနိုင်သည်။

实例

例子 1

下面的例子定义了一个带有约束且名为 "age" 的元素。age 的值不能小于 0 或大于 100:


  
    
      
      
    
  

例子 2

本例定义了一个名为 "initials" 的元素。"initials" 元素是带有约束的简单类型。可接受的值是三个从 a 到 z 的大写或小写字母:


  
    
      
    
  

例子 3

本例定义了一个名为 "password" 元素。"password" 元素是带有约束的简单类型。值必须为最少 5 个字符且最多 8 个字符:


  
    
      
      
    
  

例子 4

本例展示了一个使用约束的复杂类型定义。复杂类型 "Chinese_customer" 从一个普通的 customer 复杂类型派生而来,其 country 元素的固定值是 "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: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"/>