Definitive XML Schema

Definitive XML Schema

(pwalmsley@datypic.com)

ISBN: 0132886723

2nd edition, , Prentice Hall PTR.

Chapter 11: Built-in simple types

Book examples

Example 11-1. Extensible mixed content
<xs:complexType name="TextType" mixed="true">
  <xs:sequence>
    <xs:any namespace="##any" processContents="lax"
            minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
  <xs:attribute ref="xml:lang"/>
</xs:complexType>
Example 11-2. Invalid nonunique IDs
<order orderID="A123">
  <customer custID="A123">...</customer>
</order>
Example 11-3. Illegal duplication of ID attributes (version 1.0)
<xs:complexType name="CustType">
  <xs:attribute name="id" type="xs:ID"/>
  <xs:attribute name="custID" type="xs:ID"/>
</xs:complexType>
Example 11-4. Illegal attribute declarations (version 1.0)
<xs:attribute name="id" type="xs:ID" fixed="A123"/>
<xs:attribute name="custID" type="xs:ID" default="C00000"/>
Example 11-5. Using IDREF
Schema:
<xs:element name="quote">
  <xs:complexType>
    <!--content model-->
    <xs:attribute name="ref" type="xs:IDREF"/>
  </xs:complexType>
</xs:element>
<xs:element name="footnote">
  <xs:complexType>
    <!--content model-->
    <xs:attribute name="id" type="xs:ID" use="required"/>
  </xs:complexType>
</xs:element>
Instance:
<quote ref="fn1">...</quote>
<footnote id="fn1">...</footnote>
Example 11-6. Using IDREFS
Schema:
<xs:element name="quote">
  <xs:complexType>
    <!--content model-->
    <xs:attribute name="refs" type="xs:IDREFS"/>
  </xs:complexType>
</xs:element>
<xs:element name="footnote">
  <xs:complexType>
    <!--content model-->
    <xs:attribute name="id" type="xs:ID" use="required"/>
  </xs:complexType>
</xs:element>
Instance:
<quote refs="fn1 fn2">...</quote>
<footnote id="fn1">...</footnote>
<footnote id="fn2">...</footnote>
Example 11-7. Using an unparsed entity
Schema:
<xs:element name="picture">
  <xs:complexType>
    <xs:attribute name="location" type="xs:ENTITY"/>
  </xs:complexType>
</xs: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 11-8. Using ENTITIES
Schema:
<xs:element name="pictures">
  <xs:complexType>
    <xs:attribute name="location" type="xs:ENTITIES"/>
  </xs:complexType>
</xs: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 11-9. 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> equals <IDREF>abc</IDREF>

Example 11-10. 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 11-11. 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