Chapter 01: Schemas: An introductionΒΆ
Schema
<!--Definitive XML Schema by Priscilla Walmsley (c) 2012 Prentice Hall PTR -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="product" type="ProductType"/>
<xsd:complexType name="ProductType">
<xsd:sequence>
<xsd:element name="number" type="xsd:integer"/>
<xsd:element name="size" type="SizeType"/>
</xsd:sequence>
<xsd:attribute name="effDate" type="xsd:date"/>
</xsd:complexType>
<xsd:simpleType name="SizeType">
<xsd:restriction base="xsd:integer">
<xsd:minInclusive value="2"/>
<xsd:maxInclusive value="18"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
XML Document
<product effDate="2001-04-02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="chapter01.xsd">
<number>557</number>
<size>10</size>
</product>
xsData XML Document
<?xml version='1.0' encoding='UTF-8'?>
<product effDate="2001-04-02">
<number>557</number>
<size>10</size>
</product>
xsData JSON
{
"number": 557,
"size": 10,
"eff_date": "2001-04-02"
}
Samples Source
Definitive XML Schema by Priscilla Walmsley (c) 2012 Prentice Hall PTR