Definitive XML Schema
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0130655678
1st edition, , Prentice Hall PTR.
Chapter 20: Naming considerations
Book examples
<product> <prodNumber>557</prodNumber> <prodName>Short-Sleeved Linen Blouse</prodName> <prodSize sizeSystem="US-DRESS">10</prodSize> </product>
<product> <number>557</number> <name>Short-Sleeved Linen Blouse</name> <size system="US-DRESS">10</size> </product>
<letter>Dear <custName>Priscilla Walmsley</custName>, Unfortunately, we are out of stock of the <prodName>Short-Sleeved Linen Blouse</prodName> in size <prodSize>10</prodSize> that you ordered...</letter>
<ord:order xmlns:ord="http://example.org/ord" xmlns:prod="http://example.org/prod"> <ord:number>123ABBCC123</ord:number> <ord:items> <prod:product> <prod:number>557</prod:number> </prod:product> </ord:items> </ord:order>
<ord:order xmlns:ord="http://example.org/ord"> <number>123ABBCC123</number> <items> <product> <number>557</number> </product> </items> </ord:order>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:prod="http://example.org/prod" xmlns="http://example.org/ord" targetNamespace="http://example.org/ord" elementFormDefault="qualified"> <xsd:import schemaLocation="prod.xsd" namespace="http://example.org/prod"/> <xsd:element name="order" type="OrderType"/> <xsd:complexType name="OrderType"> <xsd:sequence> <xsd:element name="number" type="OrderNumType"/> <xsd:element name="items" type="prod:ItemsType"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespace="http://example.org/prod" elementFormDefault="qualified"> <xsd:complexType name="ItemsType"> <xsd:sequence maxOccurs="unbounded"> <xsd:element name="product" type="ProductType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<order xmlns="http://example.org/ord"> <number>123ABBCC123</number> <items> <product> <number>557</number> </product> </items> </order>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespace="http://example.org/prod"> <xsd:attribute name="global" type="xsd:string"/> <xsd:element name="size" type="SizeType"/> <xsd:complexType name="SizeType"> <xsd:attribute ref="global"/> <xsd:attribute name="unqual" form="unqualified"/> <xsd:attribute name="qual" form="qualified"/> <xsd:attribute name="unspec"/> </xsd:complexType> </xsd:schema>
<prod:size prod:global="x" unqual="x" prod:qual="x" unspec="x"/>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/all" targetNamespace="http://example.org/all" elementFormDefault="qualified"> <xsd:include schemaLocation="prod.xsd"/> <xsd:include schemaLocation="cust.xsd"/> <xsd:element name="order" type="OrderType"/> <xsd:complexType name="OrderType"> <xsd:sequence> <xsd:element name="customer" type="CustomerType"/> <xsd:element name="items" type="ItemsType"/> </xsd:sequence> </xsd:complexType> <!--...--> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/all" targetNamespace="http://example.org/all" elementFormDefault="qualified"> <xsd:complexType name="ItemsType"> <xsd:sequence maxOccurs="unbounded"> <xsd:element name="product" type="ProductType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/all" targetNamespace="http://example.org/all" elementFormDefault="qualified"> <xsd:complexType name="CustomerType"> <xsd:sequence> <xsd:element name="name" type="CustNameType"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="CustNameType"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema>
<order xmlns="http://example.org/all" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.org/all ord.xsd"> <customer> <name>Priscilla Walmsley</name> </customer> <items> <product> <number>557</number> </product> </items> </order>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:prod="http://example.org/prod" xmlns:cust="http://example.org/cust" xmlns="http://example.org/ord" targetNamespace="http://example.org/ord" elementFormDefault="qualified"> <xsd:import schemaLocation="prod.xsd" namespace="http://example.org/prod"/> <xsd:import schemaLocation="cust.xsd" namespace="http://example.org/cust"/> <xsd:element name="order" type="OrderType"/> <xsd:complexType name="OrderType"> <xsd:sequence> <xsd:element name="customer" type="cust:CustomerType"/> <xsd:element name="items" type="prod:ItemsType"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/prod" targetNamespace="http://example.org/prod" elementFormDefault="qualified"> <xsd:complexType name="ItemsType"> <xsd:sequence maxOccurs="unbounded"> <xsd:element name="product" type="ProductType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/cust" targetNamespace="http://example.org/cust" elementFormDefault="qualified"> <xsd:complexType name="CustomerType"> <xsd:sequence> <xsd:element name="name" type="CustNameType"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="CustNameType"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema>
<order xmlns="http://example.org/ord" xmlns:prod="http://example.org/prod" xmlns:cust="http://example.org/cust" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.org/ord ord.xsd"> <customer> <cust:name>Priscilla Walmsley</cust:name> </customer> <items> <prod:product> <prod:number>557</prod:number> </prod:product> </items> </order>
<order xmlns="http://example.org/ord" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.org/ord ord.xsd"> <customer> <name xmlns="http://example.org/cust">Priscilla Walmsley</name> </customer> <items> <product xmlns="http://example.org/prod"> <number>557</number> </product> </items> </order>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://example.org/ord" targetNamespace="http://example.org/ord" elementFormDefault="qualified"> <xsd:include schemaLocation="prod.xsd"/> <xsd:include schemaLocation="cust.xsd"/> <xsd:element name="order" type="OrderType"/> <xsd:complexType name="OrderType"> <xsd:sequence> <xsd:element name="number" type="xsd:string"/> <xsd:element name="items" type="ItemsType"/> </xsd:sequence> </xsd:complexType> <!--...--> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:complexType name="ItemsType"> <xsd:sequence maxOccurs="unbounded"> <xsd:element name="product" type="ProductType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element name="number" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xsd:complexType name="CustomerType"> <xsd:sequence> <xsd:element name="name" type="CustNameType"/> </xsd:sequence> </xsd:complexType> <xsd:simpleType name="CustNameType"> <xsd:restriction base="xsd:string"/> </xsd:simpleType> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="ProductType"> <xsd:sequence> <xsd:element ref="number"/> <xsd:element name="name" type="xsd:string"/> <xsd:element ref="size"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="SizeType"> <xsd:simpleContent> <xsd:extension base="xsd:integer"> <xsd:attribute name="system" type="xsd:string"/> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:element name="product" type="ProductType"/> <xsd:element name="number" type="xsd:string"/> <xsd:element name="size" type="SizeType"/> </xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="produit" substitutionGroup="product"/> <xsd:element name="numéro" substitutionGroup="number"/> <xsd:element name="taille" substitutionGroup="size"/> </xsd:schema>
<produit> <numéro>557</numéro> <name>Short-Sleeved Linen Blouse</name> <taille system="US-DRESS">10</taille> </produit>