Search code examples
xmlxsdxsd-validationxml-validation

Explain this xs:simpleContent / xs:extension XSD pattern?


Here's what I have, and I don't understand what it does:

<xs:element name="T1RXXXXG2S" type="StrColumn" nillable="true" minOccurs="0" maxOccurs="9999"/>

where

<xs:complexType name="StrColumn">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="ROWNUM" type="rowInt" use="required"/>
            </xs:extension>
        </xs:simpleContent>
</xs:complexType>

and

<xs:simpleType name="rowInt">
        <xs:restriction base="xs:int">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="999999"/>
        </xs:restriction>
</xs:simpleType>

Can somebody explain to me what does this extension do here and how it works?


Solution

  • According to your XSD fragments, a T1RXXXXG2S element must have string content and an attribute, ROWNUM, with an integer value in the range of 1 to 999999, inclusive on both ends.

    The rarely used nillable="true" attribute on the T1RXXXXG2S element declaration means that T1RXXXXG2S may appear with an xsi:nil="true" attribute.