Schemas and Namespaces

One of the big ideas behind schemas was to allow XML processors to validate documents that use namespaces (which DTDs have a problem with). Toward that end, the <schema> element has a new attribute: targetNamespace.

The targetNamespace attribute specifies the namespace the schema is targeted to (that is, intended for). This means that if an XML processor is validating a document and is checking elements in a particular namespace, it will know what schema to check based on the schema's target namespace. That's the idea behind target namespaces—you can indicate what namespace a schema is targeted to so that an XML processor can determine which schema(s) to use to validate a document. For an example using the targetNamespace ...

Get Real World XML now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.