XML Schema restriction 元素 -> XML Schema restriction na elemento

定义和用法 -> Paglilingkod at paggamit

restriction 元素定义对 simpleType、simpleContent 或 complexContent 定义的约束。 -> Ang restriction na elemento ay nagbibigay-kahulugan ng mga pagpipigil na tinukoy sa simpleType, simpleContent o complexContent.

元素信息 -> Impormasyon ng elemento

出现次数 -> Beses ng paglabas 一次 -> Isa beses
父元素 -> Ama-elemento complexContent -> completeContent
内容 -> Naglalaman group、all、choice、sequence、attribute、attributeGroup、anyAttribute -> group, all, choice, sequence, attribute, attributeGroup, anyAttribute

语法 -> Pagkakasusuri

<restriction -> <restriction
id=ID -> id=ID
base=QName -> base=QName
anumang attributes
> -> >
Content for simpleType: -> Naglalaman para sa simpleType:
(annotation?,(simpleType?,(minExclusive|minInclusive| -> (annotation?,(simpleType?,(minExclusive|minInclusive| 
maxExclusive|maxInclusive|totalDigits|fractionDigits| -> maxExclusive|maxInclusive|totalDigits|fractionDigits|
length|minLength|maxLength|enumeration|whiteSpace|pattern)*)) -> length|minLength|maxLength|enumeration|whiteSpace|pattern)*))
Content for simpleContent: -> Naglalaman para sa simpleContent:
(annotation?,(simpleType?,(minExclusive |minInclusive| -> (annotation?,(simpleType?,(minExclusive|minInclusive| 
maxExclusive|maxInclusive|totalDigits|fractionDigits| -> maxExclusive|maxInclusive|totalDigits|fractionDigits|
(length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?, -> ((length|minLength|maxLength|enumeration|whiteSpace|pattern)*)?, 
((attribute|attributeGroup)*,anyAttribute?)) -> ((attribute|attributeGroup)*,anyAttribute?))
Content for complexContent: -> Naglalaman para sa complexContent:
(annotation?,(group|all|choice|sequence)?,) -> (annotation?,(group|all|choice|sequence)?,)
((attribute|attributeGroup)*,anyAttribute?)) -> ((attribute|attributeGroup)*,anyAttribute?))
</restriction>

(? 符号声明在 restriction 元素中该元素可出现零次或一次。) -> (? Ang simbolo ay ipinahayag sa restriction na elemento kung anuman ang elemento ay maaaring lumabas nang walang beses o isang beses lamang.)

属性 Paglalarawan
id Opisyal. Tumutukoy sa tanging ID ng elemento.
base Mahalaga. Tumutukoy sa pangalan ng inumin na binigay na built-in data type, simpleType o complexType na elemento sa schema (o anumang ibang schema na tinukoy ng ibang namespace).
anumang attributes Opisyal. Tumutukoy sa anumang iba pang attribute na may non-schema na pangalan ng namespace.

Halimbawa

Mga halimbawa 1

Ang halimbawa na ito ay naglilinaw ng isang elemento na may pangalan na "age" na may pagbabawal. Ang halaga ng age ay hindi dapat mababa sa 0 o higit sa 100:

<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>

Mga halimbawa 2

Ang paglilinaw nito ay isang elemento na may pangalan na "initials". Ang elemento na "initials" ay isang simple type na may pagbabawal. Ang mga pinapayagan na halaga ay tatlong may oras na malalaking o maliit na titik mula sa a hanggang z:

<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>

Mga halimbawa 3

Ang paglilinaw nito ay isang elemento na may pangalan na "password". Ang elemento na "password" ay isang simple type na may pagbabawal. Ang halaga ay dapat maging hindi bababa sa 5 at hindi higit sa 8 na mga character:

<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>

Mga halimbawa 4

Ang pagpapakita nito ay isang kumplikadong tipong tala gamit ang pagbabawal. Ang kumplikadong tipong tala na "Chinese_customer" ay nagmula sa isang pangkaraniwang kumplikadong tipong tala na customer, ang walang kahalagang halaga ng elemento na "country" ay "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>