D A T Y P I C
home
services
books
Overview
Table of Contents
Sample Chapter
Examples
1. Intro
2. Quick tour
3. Namespaces
4. Include/Import
5. Instances
6. Annotations
7. Element Decls
8. Attribute Decls
9. Simple types
10. Regexes
11. Union/List types
12. Built-in types
13. Complex types
14. Type derivation
15. Groups
16. Subst. groups
17. ID constraints
18. Redefines
19. DTDs topics
20. Naming
21. Extensibility
Errata
about
Definitive XML Schema

Definitive XML Schema

Priscilla Walmsley (pwalmsley@datypic.com)
1st edition (December 7, 2001)
Prentice Hall PTR; ISBN: 0130655678
Amazon.com
Buy at 30% off list price


Chapter 12: Built-in simple types


Book Examples

Example 12-1. Invalid non-unique IDs

<order orderID="A123">
  <customer custID="A123">...</customer>
</order>


Example 12-2. Illegal duplication of ID attributes

<xsd:complexType name="CustType">
  <xsd:attribute name="id" type="xsd:ID" use="required"/>
  <xsd:attribute name="custSSN" type="xsd:ID" use="required"/>
</xsd:complexType>


Example 12-3. Illegal attribute declarations

<xsd:attribute name="id" type="xsd:ID" fixed="A123"/>
<xsd:attribute name="id" type="xsd:ID" default="A123"/>


Example 12-4. Using IDREF

<xsd:element name="quote">
  <xsd:complexType>
    <!--content model-->
    <xsd:attribute name="ref" type="xsd:IDREF"/>
  </xsd:complexType>
</xsd:element>
<xsd:element name="footnote">
  <xsd:complexType>
    <!--content model-->
    <xsd:attribute name="id" type="xsd:ID" use="required"/>
  </xsd:complexType>
</xsd:element>
<quote ref="fn1">...</quote>
<footnote id="fn1">...</footnote>


Example 12-5. Using an unparsed entity

<xsd:element name="picture">
  <xsd:complexType>
    <xsd:attribute name="location" type="xsd:ENTITY"/>
  </xsd:complexType>
</xsd:element>
<!--...-->
<!DOCTYPE catalog [
<!NOTATION jpeg SYSTEM "JPG">
<!ENTITY prod557 SYSTEM "prod557.jpg" NDATA jpeg>
<!ENTITY prod563 SYSTEM "prod563.jpg" NDATA jpeg>
]>

<catalog>
  <product>
    <number>557</number>
    <picture location="prod557"/>
  </product>
  <product>
    <number>563</number>
    <picture location="prod563"/>
  </product>
</catalog>


Example 12-6. Using ENTITIES

<xsd:element name="pictures">
  <xsd:complexType>
    <xsd:attribute name="location" type="xsd:ENTITIES"/>
  </xsd:complexType>
</xsd:element>
<!DOCTYPE catalog [
<!NOTATION jpeg SYSTEM "JPG">
<!ENTITY prod557a SYSTEM "prod557a.jpg" NDATA jpeg>
<!ENTITY prod557b SYSTEM "prod557b.jpg" NDATA jpeg>
]>

<catalog>
  <product>
    <number>557</number>
    <pictures location="prod557a prod557b"/>
  </product>
</catalog>