Pages

Tuesday, May 17, 2016

Ref and Type in XML Schema

Ref is used to refer to another XML element.


<xsd:element name="Product">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="ProductName" type="xsd:string" />
            <xsd:element ref="Customer" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
<xsd:element name="Customer">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="FullName" type="xsd:string" />
            <xsd:element name="Age" type="xsd:string" />
            <xsd:element name="Age" type="xsd:occupation" />
       </xsd:sequence>
    </xsd:complexType>
</xsd:element>


Type is used to refer to a complexType, simpleType or a built-in type.


<xsd:element name="Product">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="ProductName" type="xsd:string" />
            <xsd:element name="Customer" type="Cust" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

    <xsd:complexType name="Cust" >
        <xsd:sequence>
            <xsd:element name="FullName" type="xsd:string" />
            <xsd:element name="Age" type="xsd:string" />
            <xsd:element name="Age" type="xsd:occupation" />
       </xsd:sequence>
    </xsd:complexType>

No comments:

Post a Comment