Datypic Logo
Definitive XML Schema

Definitive XML Schema

Priscilla Walmsley (pwalmsley@datypic.com)

1st edition (December 7, 2001)

Prentice Hall PTR; ISBN: 0130655678

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
Schema:
<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>
Instance:
<quote ref="fn1">...</quote>
<footnote id="fn1">...</footnote>
Example 12-5. Using an unparsed entity
Schema:
<xsd:element name="picture">
  <xsd:complexType>
    <xsd:attribute name="location" type="xsd:ENTITY"/>
  </xsd:complexType>
</xsd:element>
<!--...-->
Instance:
<!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
Schema:
<xsd:element name="pictures">
  <xsd:complexType>
    <xsd:attribute name="location" type="xsd:ENTITIES"/>
  </xsd:complexType>
</xsd:element>
Instance:
<!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>
Example 12-7. Equality based on type definition hierarchy

<integer>2</integer> does not equal <string>2</string>

<integer>2</integer> equals <positiveInteger>2</positiveInteger>

<string>abc</string> equals <NCName>abc</NCName>

<string>abc</string> does not equal <QName>abc</QName>

<IDREFS>abc</IDREFS> does not equal <IDREF>abc</IDREF>

Example 12-8. Equality based on equivalent lexical representations

<integer>2</integer> equals <integer>02</integer>

<integer>2</integer> equals <positiveInteger>02</positiveInteger>

<string>2</string> does not equal <string>02</string>

<boolean>true</boolean> equals <boolean>1</boolean>

<hexBinary>0fb8</hexBinary> equals <hexBinary>0FB8</hexBinary>

<time>13:20:00-05:00</time> equals <time>12:20:00-06:00</time>

Example 12-9. Equality based on whitespace normalization

<string> a </string> does not equal <token> a </token>

<string>a</string> equals <token> a </token>

<token>a</token> equals <token> a </token>

Datypic XML Schema Services