restriction

XML Schema restriction elementi


❮ To‘liq XML Schema ma’lumotnomasi

Ta’rif va qo‘llanilishi

restriction elementi simpleType, simpleContent yoki complexContent ta’rifi uchun cheklovlarni aniqlaydi.

Element haqida ma’lumot

  • Ota elementlar: simpleType, simpleContent, complexContent

Sintaksis

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

(? belgisi element restriction elementi ichida nol yoki bir marta kelishi mumkinligini bildiradi)

Atribut Tavsif
id Ixtiyoriy. Element uchun noyob ID belgilaydi
base

Majburiy. Ushbu yoki boshqa sxemada aniqlangan o‘rnatilgan ma’lumot tipi, simpleType elementi yoki complexType elementining nomini belgilaydi

any attributes Ixtiyoriy. Sxemaga oid bo‘lmagan nomlar fazosidagi boshqa har qanday atributlarni belgilaydi

1-misol

Bu misol cheklovga ega "age" nomli elementni aniqlaydi. age qiymati 0 dan kichik yoki 100 dan katta bo‘lishi MUMKIN EMAS:

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

Bu misol ham "initials" nomli elementni aniqlaydi. "initials" elementi cheklovga ega oddiy tipdir. Yagona ruxsat etilgan qiymat — a dan z gacha bo‘lgan KICHIK YOKI KATTA harflardan UCHTASI:

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

Bu misol "password" nomli elementni aniqlaydi. "password" elementi cheklovga ega oddiy tipdir. Qiymat kamida besh va ko‘pi bilan sakkiz belgidan iborat bo‘lishi kerak:

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

Bu misolda restriction yordamida murakkab tip ta’rifi ko‘rsatilgan. "Norwegian_customer" murakkab tipi umumiy customer murakkab tipidan hosil qilingan va uning country elementi "Norway" qiymatiga qat’iy belgilab qo‘yilgan:

<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="Norwegian_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="Norway"/>       </xs:sequence>     </xs:restriction>   </xs:complexContent> </xs:complexType>


❮ To‘liq XML Schema ma’lumotnomasi

W3Schools Pathfinder

Yutuqlaringizni kuzating – bu bepul!