XML शेमा extension एलेमेंट

परिभाषा और उपयोग

extension एलेमेंट simpleType या complexType एलेमेंट को विस्तार करता है。

एलेमेंट जानकारी

उपस्थिति बार एक बार
माता एलेमेंट complexContent
विषय annotation, attribute, attributeGroup, anyAttribute, choice, all, sequence, group

व्याकरण

<extension
id=ID 
base=QName
कोई भी गुण
>
(annotation?,((group|all|choice|sequence)?,
((attribute|attributeGroup)*,anyAttribute?)))
</extension>
गुण वर्णन
id वैकल्पिक। इस एलेमेंट के अद्वितीय ID को निर्धारित करता है。
base अनिवार्य। बैनर डेटा टाइप, simpleType या complexType एलेमेंट के नाम को निर्धारित करता है。
xml:lang वैकल्पिक। सामग्री में इस्तेमाल किए जाने वाले भाषा को निर्धारित करता है。

एक्सटेंशन एलेमेंट के अंदर ? संकेतक घोषणा किया गया है, यह एलेमेंट केवल एक बार या एक बार नहीं हो सकता है, * संकेतक इस एलेमेंट को शून्य बार या कई बार हो सकता है।

उदाहरण

उदाहरण 1

इस उदाहरण में, एक मौजूदा simpleType को एक अटैचमेंट के द्वारा विस्तारित किया जाता है:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="size">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small" />
    <xs:enumeration value="medium" />
    <xs:enumeration value="large" />
  </xs:restriction>
</xs:simpleType>
<xs:complexType name="jeans">
  <xs:simpleContent>
    <xs:extension base="size">
      <xs:attribute name="sex">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="male" />
            <xs:enumeration value="female" />
          </xs:restriction>
        </xs:simpleType>
      </xs:attribute>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>
</xs:schema>

उदाहरण 2

इस उदाहरण में तीन एलीमेंटों को जोड़कर, एक मौजूदा complexType एलीमेंट को विस्तारित किया जाता है:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
  <xs:complexContent>
    <xs:extension base="personinfo">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>
</xs:schema>