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