Definitive XML Schema
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0130655678
1st edition, , Prentice Hall PTR.
Chapter 2: A quick tour of XML Schema
Book examples
<product effDate="2001-04-02"> <number>557</number> <size>10</size> </product>
<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>
<size>10</size> <comment>Runs large.</comment> <availableSizes>10 large 2</availableSizes>
<size system="US-DRESS">10</size> <comment>Runs <b>large</b>.</comment> <availableSizes><size>10</size><size>2</size></availableSizes>
<system="US-DRESS">availableSizes="10 large 2"
<xsd:element name="size"> <xsd:simpleType> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="2"/> <xsd:maxInclusive value="18"/> </xsd:restriction> </xsd:simpleType> </xsd:element>
<size system="US-DRESS">10</size> <product> <number>557</number> <size>10</size> </product> <letter>Dear <custName>Priscilla Walmsley</custName>...</letter> <color value="blue"/>
<xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:integer"/> <xsd:choice minOccurs="0" maxOccurs="3"> <xsd:element name="size" type="SizeType"/> <xsd:element name="color" type="ColorType"/> </xsd:choice> <xsd:any namespace="##other"/> </xsd:sequence> <xsd:attribute name="effDate" type="xsd:date"/> </xsd:complexType>
<xsd:complexType name="ShirtType"> <xsd:complexContent> <xsd:extension base="ProductType"> <xsd:sequence> <xsd:element name="color" type="ColorType"/> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID" use="required"/> </xsd:extension> </xsd:complexContent> </xsd:complexType>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/prod" xmlns:prod="http://example.org/prod"> <xsd:element name="product" type="prod:ProductType"/> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:integer"/> <xsd:element name="size" type="prod: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>
<prod:product xmlns:prod="http://example.org/prod" effDate="2001-04-02"> <number>557</number> <size>10</size> </prod:product>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/ord" targetNamespace="http://example.org/ord"> <xsd:include schemaLocation="moreOrderInfo.xsd"/> <xsd:import namespace="http://example.org/prod" schemaLocation="productInfo.xsd"/> <!--...--> </xsd:schema>
<prod:product xmlns:prod="http://example.org/prod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.org/prod prod.xsd" effDate="2001-04-02"> <number>557</number> <size>10</size> </prod:product>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:doc="http://example.org/doc"> <xsd:element name="product" type="ProductType"> <xsd:annotation> <xsd:documentation xml:lang="en" source="http://example.org/prod.html#product"> <doc:description>These elements represent a product. </doc:description> </xsd:documentation> </xsd:annotation> </xsd:element> </xsd:schema>