Let's start our explanation of XSDL by introducing a sample schema definition.
The sample XSDL definition in Example 22-2 demonstrates some of the most important features of the language. Example 22-1 shows a document that conforms to that schema.
Example 22-1. Poem document
<?xml version="1.0"?> <poem xmlns="http://www.poetry.net/poetns" publisher="Boni and Liveright" pubyear="1922"> <title>The Waste Land</title> <picture href="pic1.gif"/> <verse>April is the cruellest month, breeding</verse> <verse>Lilacs out of the dead land</verse> </poem>
The schema defines a poem element type that consists of a title element followed by a picture and one or more verse elements. The poem element type has two optional attributes: publisher and pubyear.
The picture element type's required href attribute is declared with a type of xsd:anyURI, which indicates that the value of href must have a URI datatype.
There are several notable characteristics of the syntax:
Perhaps the most obvious is that a schema definition is represented as an XML document.
There is a dependency on namespaces, which are heavily utilized.[1] The schema element declares the prefix xsd for names defined in XML Schema and poem for names that are defined within this schema definition.
[1] Namespaces are discussed in Chapter 16, "Namespaces", on page 376.
There is a built-in syntax that can be used to declare datatypes: the type attribute. Actually, it is used for more than datatypes; it is arguably the most important concept in XSDL, as we'll soon see.