Imagine a technology that offered you all the power of a DTD without the associated unpleasantness of those strange symbols and arcane commands. Sounds too good to be true? Say hello to XML Schema.
In case you're new to the whole XML scene, I'll first take a couple of minutes to explain where schemas fit in.
You probably already know that XML is a toolkit to describe data; it allows document authors to "mark up" textual data with descriptive tags, thereby adding value to the data and making it more useful to the applications that process it. XML also offers document authors a way to enforce certain grammatical rules on an XML document via DTDs, or Document Type Definitions, which specify a structure and format for an XML document to be considered valid.
However, DTDs suffer from two glaring problems. First, they're not terribly user-friendly - creating a DTD requires a working knowledge of a bunch of arcane commands and constructs, and the end result is usually hard to read and understand. Second, although DTDs are designed to impose a structure on XML data, they are themselves not written in XML.
In order to address these two issues, and also to lay the groundwork for the next generation of XML data validation, the W3C created the XML Schema Working Group to create a new schema language for XML data validation.
A "schema", as the name suggests, is a blueprint for a specific class of XML document. It lays down rules for the types of elements and attributes allowed within an XML document, the types of values that accompany such elements, and the order and occurrence of these elements. It also addresses a number of issues which cannot be handled by the current generation of DTDs: datatyping (including the ability to derive new datatypes from existing ones), inheritance, grouping, and database linkage.
Specific XML documents (referred to by the Working Group as "document instances") can be linked to a schema and validated against the rules contained within it. The XML Schema specification specifies the process by which document instances and schemas are linked together, and a number of tools are now available to perform this validation.
Unlike DTDs, XML Schemas are constructed using standard XML syntactical rules, immediately making them easier to read, understand and maintain.