Using the XML Schema

Example 40.5.  An XML Schema is an XML document
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <!-- schema -->

</xsd:schema>

Example 40.6.  Annotations are a Possibility
<xsd:annotation>
    <xsd:appinfo>
        <!-- Any number of ... -->
        Application information, verbal
    </xsd:appinfo>
    <xsd:documentation>
        <!-- Any number of ... -->
        Documentation
    </xsd:documentation>
    <para>
        <!-- Any element not in xsd: -->
        Grammer for a booklist
    </para>
</xsd:annotation>

Example 40.7.  Declare Root Element
    <xsd:element name="booksCanon" type="bookListType"/>

Type in this case is home made, but could otherwise be any xsd defined type

String types
string, normalizedString
Byte/binary
Boolean, unsignedByte, hexBinary, …
Integer types
integer, int, unsignedInt, positiveInteger, …
Other number types
decimal, double, float
Date, time, etc.
time, date, dateTime, duration, …

Example 40.8.  Declare Simple Type

Simple type to be used several times in schema

<xsd:simpleType name="currency">
    <xsd:restriction base="xsd:string">
        <xsd:enumeration value="US$"/>
        <!-- a number of possible values -->
    </xsd:restriction>
</xsd:/simpleType>

Example 40.9.  Declare Complex Type A

Complex because it may contain elements. Please notice the way elements are defined.

<xsd:complexType name="booklistType">
    <xsd:sequence>
        <xsd:element name="book" type="bookType" minOccurs="0"
                maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:/complexType>

Example 40.10.  Declare Complex Type B

Complex because it may contain elements. Please notice, again, element definitions, and attribute ditto. Attributes may be grouped and referenced as a group.

<xsd:complexType name="bookType">
    <xsd:sequence>
        <xsd:element name="title" type="xsd:string"/>
        <!-- a number of elements to form the sequence -->
    </xsd:sequence>
    <xsd:attribute name="ref" type="xsd:string"/>
    <!-- a number of attributes -->
</xsd:/complexType>