Namespaces
For reasons of interoperability, organizations may agree to use only certain tags. These tag sets are called XML applications. Examples are:
Namespaces have two purposes in XML:
- To distinguish between elements and attributes from different vocabularies with different meaning and that happen to share the same name. As an example, consider this XML document. Several elements (title, author, year) have been overloaded with different meanings in different parts of the document. This is not semantically correct. Moreover, this may cause problems for validation, rendering, querying and more. For instance, the element author has different types in different places of the document.
- To group all the related elements and attributes from a single XML application together so that software can recognize them. As an example, consider this XML document. It mixes two XML applications: XHTML and MathML. They need to be rendered in different ways. How can a browser recognize them?
In both cases the solution is to use different namespaces for different XML applications.