Definitive XML Schema
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0132886723
2nd edition, , Prentice Hall PTR.
Chapter 23: Versioning
Book examples
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> <xs:element name="size" type="SizeType" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="SizeType"> <xs:simpleContent> <xs:extension base="xs:integer"> <xs:attribute name="system" type="xs:token"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="size" type="SizeType" maxOccurs="3"/> <xs:element name="name" type="xs:string"/> <xs:element name="description" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="SizeType"> <xs:simpleContent> <xs:extension base="xs:positiveInteger"> <xs:attribute name="system" type="xs:token" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema>
<product> <number>557</number> <name>Short-Sleeved Linen Blouse</name> <size>0</size> <size>2</size> <size>4</size> <size>6</size> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="name" type="xs:string" minOccurs="0"/> <xs:element name="size" type="SizeType" maxOccurs="unbounded"/> <xs:element name="desc" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="SizeType"> <xs:simpleContent> <xs:extension base="xs:decimal"> <xs:attribute name="system" type="xs:token"/> <xs:attribute name="units" type="xs:token"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> <xs:element name="size" type="xs:integer" maxOccurs="unbounded"/> <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/> </xs:sequence> <xs:anyAttribute processContents="skip"/> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> <xs:element name="size" type="xs:integer" maxOccurs="unbounded"/> <xs:element name="desc" type="xs:string"/> <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/> </xs:sequence> <xs:attribute name="dept" type="xs:token"/> <xs:anyAttribute processContents="skip"/> </xs:complexType> </xs:schema>
<product dept="WMN"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> <size>0</size> <desc>Our best-selling shirt</desc> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
<product xmlns="http://datypic.com/prod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datypic.com/prod prod.xsd"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" xmlns:doc="http://datypic.com/doc" version="2.1"> <xs:element name="product" type="ProductType" doc:version="2.0"/> <xs:complexType name="ProductType" doc:version="2.0"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:element name="catalog" type="CatalogType" doc:version="2.1"/> <xs:complexType name="CatalogType" doc:version="2.1"> <xs:sequence> <xs:element name="catalog_id" type="xs:string"/> <xs:element ref="product" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
<product xmlns="http://datypic.com/prod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datypic.com/prod prod_2.1.xsd"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> <xs:attribute name="version"/> </xs:complexType> </xs:schema>
<product xmlns="http://datypic.com/prod" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datypic.com/prod prod.xsd" version="2.1"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod/2" targetNamespace="http://datypic.com/prod/2"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
<product xmlns="http://datypic.com/prod/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datypic.com/prod/2 prod.xsd"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://datypic.com/prod/2" targetNamespace="http://datypic.com/prod/2" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string"/> </xs:sequence> <xs:attribute name="version" type="xs:decimal"/> </xs:complexType> </xs:schema>
<product xmlns="http://datypic.com/prod/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datypic.com/prod/2 schemas/prod/2.1/prod.xsd" version="2.1"> <number>557</number> <name>Short-Sleeved Linen Blouse</name> </product>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="http://datypic.com/doc" version="2.1"> <xs:element name="product" type="ProductType"/> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer"/> <xs:element name="name" type="xs:string"/> <xs:choice> <xs:element name="color" type="xs:NMTOKEN"> <xs:annotation> <xs:documentation>Deprecated in favor of colorList.</xs:documentation> <xs:appinfo> <doc:deprecated>true</doc:deprecated> </xs:appinfo> </xs:annotation> </xs:element> <xs:element name="colorList" type="xs:NMTOKENS"/> </xs:choice> </xs:sequence> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"> <xs:element name="product" vc:minVersion="1.3"> <!-- a declaration that uses XML Schema 1.3 constructs --> </xs:element> <xs:element name="product" vc:minVersion="1.1" vc:maxVersion="1.3"> <!-- a declaration conformant to versions 1.1 and 1.2 --> </xs:element> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ext="http://example.org/extensions" xmlns:saxon="http://saxon.sf.net/"> <xs:element name="anyOrdinalDate" type="ext:ordinalDate"/> <xs:element name="recentOrdinalDate" type="OrdinalDateIn2011"/> <xs:simpleType name="OrdinalDateIn2011"> <xs:restriction base="ext:ordinalDate"> <xs:minInclusive value="2011-001"/> <xs:maxInclusive value="2011-365"/> </xs:restriction> </xs:simpleType> <xs:element name="size" type="SMLXSizeType"/> <xs:simpleType name="SMLXSizeType"> <xs:restriction base="xs:token"> <saxon:preprocess action="upper-case($value)"/> <xs:enumeration value="SMALL"/> <xs:enumeration value="MEDIUM"/> <xs:enumeration value="LARGE"/> <xs:enumeration value="EXTRA LARGE"/> </xs:restriction> </xs:simpleType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ext="http://example.org/extensions" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"> <xs:element name="anyOrdinalDate" type="ext:ordinalDate" vc:typeAvailable="ext:ordinalDate"/> <xs:element name="anyOrdinalDate" type="xs:string" vc:typeUnavailable="ext:ordinalDate"/> <xs:element name="recentOrdinalDate" type="OrdinalDateIn2011"/> <xs:simpleType name="OrdinalDateIn2011" vc:typeAvailable="ext:ordinalDate"> <xs:restriction base="ext:ordinalDate"> <xs:minInclusive value="2011-001"/> <xs:maxInclusive value="2011-365"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="OrdinalDateIn2011" vc:typeUnavailable="ext:ordinalDate"> <xs:restriction base="xs:string"> <xs:pattern value="2011-\d{3}"/> </xs:restriction> </xs:simpleType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"> <xs:element name="size" type="SMLXSizeType"/> <xs:simpleType name="SMLXSizeType" vc:facetAvailable="saxon:preprocess"> <xs:restriction base="xs:token"> <saxon:preprocess action="upper-case($value)"/> <xs:enumeration value="SMALL"/> <xs:enumeration value="MEDIUM"/> <xs:enumeration value="LARGE"/> <xs:enumeration value="EXTRA LARGE"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="SMLXSizeType" vc:facetUnavailable="saxon:preprocess"> <xs:restriction base="xs:token"/> </xs:simpleType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ext="http://example.org/extensions" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"> <xs:element name="astring" type="ShortString"/> <xs:simpleType name="ShortString"> <xs:restriction base="xs:string"> <ext:maxLengthWithoutWhitespace value="5" vc:facetAvailable="ext:maxLengthWithoutWhitespace"/> </xs:restriction> </xs:simpleType> </xs:schema>