A schema is a model for describing the structure of information. An XML schema is an XML language that defines a class of XML documents and describes the possible arrangement of tags and text in a valid document. Schemas can be the basis for machine validation of document structure. An "instance" of a schema is an XML document that meets the constraints of that schema. As an XML schema may describe another XML schema, it can be, somewhat confusingly, referred to as an instance of a schema.
The W3C Schema Recommendation language uses namespaces and reconstructs and refines the capabilities found in XML 1.0 DTDs (see Chapter 4). Schemas, unfortunately, do not fully replace DTDs. DTDs are a lower-level mechanism. According to the fundamental definition of XML 1.0 [XML], the parsing of XML input for an application automatically invokes any DTD present. Even nonvalidating parsers must pay attention to the internal subset DTD and implement entities and default values.
Trying to condense 400 pages of the formal specification into this chapter would be a losing battle. Instead, the goal here is to selectively cover only enough material to enable the reader to understand the schema constructs used in this book and a little more for background. Many features are not covered here, but are described more fully in the recommendation [Schema].
This chapter uses the following namespace for XML Schema elements and attributes:
All schemas have, as their root, the element "schema" in that namespace.
Section 5.2 covers the basics of the schema simpleType and complexType constructs. Section 5.3 actually specifies elements and attributes with these type constructs. In Section 5.4, we consider how schemas work with namespaces [Names]. A few miscellaneous aspects are left for Section 5.5.