Definitive XML Schema
Priscilla Walmsley (pwalmsley@datypic.com)
ISBN: 0132886723
2nd edition, , Prentice Hall PTR.
Chapter 18: Redefining and overriding schema components
Book examples
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"/> </xs:simpleType> <xs:element name="size" type="DressSizeType"/> <xs:element name="color" type="xs:string"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod"> <xs:redefine schemaLocation="prod1.xsd"> <xs:simpleType name="DressSizeType"> <xs:restriction base="DressSizeType"> <xs:minInclusive value="2"/> <xs:maxInclusive value="16"/> </xs:restriction> </xs:simpleType> </xs:redefine> <xs:element name="newSize" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="18"/> </xs:restriction> </xs:simpleType> <xs:element name="size" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:simpleType name="DressSizeType"> <xs:restriction base="DressSizeType"> <xs:minInclusive value="2"/> </xs:restriction> </xs:simpleType> </xs:redefine> <xs:element name="newSize" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer"/> <xs:element name="name" type="xs:string"/> <xs:element name="size" type="xs:integer"/> </xs:sequence> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:complexType name="ProductType"> <xs:complexContent> <xs:extension base="ProductType"> <xs:sequence> <xs:element name="color" type="xs:string"/> </xs:sequence> <xs:attribute name="effDate" type="xs:date"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:redefine> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:element name="description" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:group> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:element name="description" type="xs:string"/> </xs:sequence> </xs:group> </xs:redefine> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:element name="description" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:group> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:group ref="DescriptionGroup"/> <xs:element name="notes" type="xs:string"/> </xs:sequence> </xs:group> </xs:redefine> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import namespace="http://www.w3.org/XML/1998/namespace"/> <xs:attributeGroup name="IdentifierGroup"> <xs:attribute name="id" type="xs:ID" use="required"/> <xs:attribute name="version" type="xs:decimal"/> <xs:attribute ref="xml:lang"/> </xs:attributeGroup> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:attributeGroup name="IdentifierGroup"> <xs:attribute name="id" type="xs:ID" use="required"/> <xs:attribute name="version" type="xs:integer"/> </xs:attributeGroup> </xs:redefine> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:import namespace="http://www.w3.org/XML/1998/namespace"/> <xs:attributeGroup name="IdentifierGroup"> <xs:attribute name="id" type="xs:ID" use="required"/> <xs:attribute name="version" type="xs:decimal"/> <xs:attribute ref="xml:lang"/> </xs:attributeGroup> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:redefine schemaLocation="prod1.xsd"> <xs:attributeGroup name="IdentifierGroup"> <xs:attributeGroup ref="IdentifierGroup"/> <xs:attribute name="effDate" type="xs:date"/> </xs:attributeGroup> </xs:redefine> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"/> </xs:simpleType> <xs:element name="size" type="DressSizeType"/> <xs:element name="color" type="xs:string"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod"> <xs:override schemaLocation="prod1.xsd"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"> <xs:minInclusive value="2"/> <xs:maxInclusive value="16"/> </xs:restriction> </xs:simpleType> </xs:override> <xs:element name="newSize" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="18"/> </xs:restriction> </xs:simpleType> <xs:element name="size" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:override schemaLocation="prod1.xsd"> <xs:simpleType name="DressSizeType"> <xs:restriction base="xs:integer"> <xs:minInclusive value="2"/> <xs:maxInclusive value="18"/> </xs:restriction> </xs:simpleType> </xs:override> <xs:element name="newSize" type="DressSizeType"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer"/> <xs:element name="name" type="xs:string"/> <xs:element name="size" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:override schemaLocation="prod1.xsd"> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:string"/> <xs:element name="name" type="xs:string"/> <xs:element name="color" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:override> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="description" type="xs:string"/> <xs:attribute name="version" type="xs:decimal"/> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:override schemaLocation="prod1.xsd"> <xs:element name="description" type="DescriptionType"/> <xs:attribute name="version" type="xs:string" default="1.0"/> </xs:override> <xs:complexType name="DescriptionType"> <xs:sequence> <xs:element name="source" type="xs:string"/> <xs:element name="content" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:element name="description" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:group> <xs:attributeGroup name="IdentifierGroup"> <xs:attribute name="id" type="xs:ID" use="required"/> <xs:attribute name="version" type="xs:decimal"/> </xs:attributeGroup> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:override schemaLocation="prod1.xsd"> <xs:group name="DescriptionGroup"> <xs:sequence> <xs:element name="description" type="xs:string"/> </xs:sequence> </xs:group> <xs:attributeGroup name="IdentifierGroup"> <xs:attribute name="effDate" type="xs:date"/> <xs:attribute name="id" type="xs:ID"/> </xs:attributeGroup> </xs:override> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="name" type="xs:string" minOccurs="0"/> <xs:element name="size" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="ShirtType"> <xs:complexContent> <xs:extension base="ProductType"> <xs:sequence> <xs:element name="color" type="xs:integer"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="RestrictedProductType"> <xs:complexContent> <xs:restriction base="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer" minOccurs="0"/> <xs:element name="size" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:override schemaLocation="prod1.xsd"> <xs:complexType name="ProductType"> <xs:sequence> <xs:element name="number" type="xs:integer"/> <xs:element name="name" type="xs:string"/> <xs:element name="color" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:override> </xs:schema>