XML Tutorials - XML Schemas
Up to now, we've been looking almost exclusively at document
type definitions (DTDs) as a way of defining rules for an XML document.
Although this is an excellent method, there are a few problems with
DTDs. The most obvious problem is the fact that DTDs are written in
their own special text format, not in XML. It would make a great deal
of sense to create a document written in XML to define the rules of an
In the XHTML sample we discussed in tutorial 5, data types were not
that important—all the document content was of the string data
type. Often, however, you will have documents that contain several
different data types, and you will want to be able to validate these
data types. Unfortunately, DTDs are not designed for validating data
types or checking ranges of values. DTDs also do not understand
To solve these problems, schemas were invented. Unlike DTDs,
which have their own peculiar syntax, XML schemas are written in XML.
In addition to providing the information that DTDs offer, schemas allow
you to specify data types, use namespaces, and define ranges of values
for attributes and elements. In this tutorial, you'll learn about
XML schemas and how to use them in your XML documents. We'll look
at the XML schema data types and their categories and then explore how
to create simple and complex data types. Finally, we'll examine
namespaces used in XML schemas.
Table of content (tutorial index)