Databases Reference
In-Depth Information
One way of implementing its corresponding schema would be to design it to mirror
the XML, for example:
<xsd:elementname="shipTo">
<xsd:complexType>
<xsd:sequence>
<xsd:elementname="name">
<xsd:complexType>
<xsd:sequence>
<xsd:elementname="title"type="xsd:string"/>
<xsd:elementname="firstName"type="xsd:string"/>
<xsd:elementname="lastName"type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:elementname="address">
<xsd:complexType>
<xsd:sequence>
<xsd:elementname="line1"type="xsd:string"/>
<xsd:elementname="line2"type="xsd:string"/>
<xsd:elementname="city"type="xsd:string"/>
<xsd:elementname="state"type="xsd:string"/>
<xsd:elementname="zip"type="xsd:string"/>
<xsd:elementname="country"type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Using this approach, only the
shipTo
element is declared globally and thus is
reusable; no other elements or types either within this schema or another schema
can make use of the elements or types declared inside the
shipTo
element.
Another way of defining the schema would be as shown in the following
code snippet:
<xsd:elementname="shipTo">
<xsd:complexType>
<xsd:sequence>
<xsd:elementref="name"/>
<xsd:elementref="address/>
</xsd:sequence>
</xsd:complexType>