Like DTDs, schemas are another way to define the elements of an
XML document.
The following example shows a DTD and an equivalent Schema:
DTD:
Schema:
How do schemas differ from DTDs?
They use XML syntax.
You can define element and attribute data types.
You can define open content models.
They allow a slightly greater flexibility for defining
content models.
Schemas are likely to replace DTDs in the future.
To associate a schema to an XML document,
use the xmlns (XML namespace) attribute on the
document's root element:
<?xml version = "1.0"?>
<catalog xmlns="x-schema:schema3.xml">
Note: although namespaces are in fact only unique identifiers and
do not formally imply conformance to any schema or DTD,
IE5 uses this method to associate schemas to documents.
Schema files use XML syntax. They must begin with the
Schema tag:
<?xml version = "1.0"?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"> . . . schema definitions go here . . .
</Schema>
The xmlns attribute defines the namespace for schemas.
This simply means that the language for defining schemas is made up
of predefined tags, which belong to that namespace.