కోర్సు సిఫార్సులు:

XML Schema restriction మూలకం

నిర్వచనం మరియు వినియోగం

restriction మూలకం సిమ్పల్‌టైప్, simpleContent లేదా complexContent నిర్వచించిన పరిమితిని నిర్వచిస్తుంది.

మూలకం సమాచారం ప్రావీణ్యం
ఒకసారి ఉండటం పైభాగం మూలకం
complexContent కంటెంట్

group, all, choice, sequence, attribute, attributeGroup, anyAttribute

వివరణ
<restriction
id=ID
ఏదైనా అంశాలు
base=QName
>
(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>

(? సింబోల్ రిస్ట్రిక్షన్ మూలకంలో ఈ మూలకం ఎక్కువగా లేదా ఒకసారి ఉండవచ్చు.)

అంశాలు వివరణ
id ఎంపికలు. ఈ మూలకం యొక్క ప్రత్యేకమైన ID ను నిర్ధారిస్తుంది.
బేస్ అనివార్యం. ఈ స్కీమా (లేదా తెలుపబడిన నామకపద్ధతి ద్వారా ఇతర స్కీమా) లో నిర్వచించబడిన ప్రాథమిక డేటా రకం, simpleType లేదా complexType మూలకాల పేరును నిర్ధారిస్తుంది.
ఏదైనా అంశాలు ఎంపికలు. నాణ్యతా స్కీమా నామకపద్ధతి లేని ఏదైనా ఇతర అంశాలను నిర్ధారిస్తుంది.

ఉదాహరణ

ఉదాహరణ 1

ఈ ఉదాహరణలో "age" పేరుతో ఒక పరిమితితో కూడిన "age" మూలకుడు నిర్వచించబడింది. age విలువలు 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

ఈ ఉదాహరణలో "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" మూలకుడు పరిమితితో కూడినది. విలువలు కనీసం 5 అక్షరాలు మరియు గరిష్టంగా 8 అక్షరాలు ఉండాలి:

<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 క్లిష్టమైన రకం నుండి ఉద్భవించింది, దాని 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: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>