एक्सएमएल स्कीमा प्रतिबंध तत्व
❮ पूर्ण XML स्कीमा संदर्भ
परिभाषा और उपयोग
प्रतिबंध तत्व एक सरल प्रकार, सरल सामग्री, या जटिल सामग्री परिभाषा पर प्रतिबंधों को परिभाषित करता है।
तत्व जानकारी
- मूल तत्व: सरल प्रकार, सरल सामग्री, जटिल सामग्री
वाक्य - विन्यास
<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>
(चिह्न घोषित करता है कि तत्व प्रतिबंध तत्व के अंदर शून्य या एक बार हो सकता है)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
base |
Required. Specifies the name of a built-in data type, simpleType element, or complexType element defined in this schema or another schema |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
उदाहरण 1
यह उदाहरण प्रतिबंध के साथ "आयु" नामक तत्व को परिभाषित करता है। आयु का मान 0 से कम या 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>
उदाहरण 2
यह उदाहरण "आरंभिक" नामक तत्व को भी परिभाषित करता है। "प्रारंभिक" तत्व प्रतिबंध के साथ एक साधारण प्रकार है। केवल स्वीकार्य मान a से 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>
उदाहरण 3
यह उदाहरण "पासवर्ड" नामक तत्व को परिभाषित करता है। "पासवर्ड" तत्व प्रतिबंध के साथ एक साधारण प्रकार है। मान न्यूनतम पांच वर्ण और अधिकतम आठ वर्ण होना चाहिए:
<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
यह उदाहरण प्रतिबंध का उपयोग करके एक जटिल प्रकार की परिभाषा दिखाता है। जटिल प्रकार "नॉर्वेजियन_कस्टमर" एक सामान्य ग्राहक जटिल प्रकार से लिया गया है और इसका देश तत्व "नॉर्वे" के लिए तय किया गया है:
<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>
❮ पूर्ण XML स्कीमा संदर्भ