The eXtensible Markup Language (XML)

XML Namespaces

The development of data models and vocabularies is of fundamental importance in XML applications.  XML supports reuse and sharing of data models and vocabularies.

In order to reuse data models and vocabularies, it is important that XML support segmenting problems into logical and managable domains.  Then applications must be able to reference and use models and vocabularies as required.  Two issues immediately present themselves:

What naming convention should be used for referencing these models and vocabularies?

How are collisions between multiple models and vocabularies prevented or handled?

For example, the Toysco example in the previous section has both names of customers and names of products.  Both the problem of naming and the problem of collisions are addressed by the Namespaces Recommendation (January 1999).

An XML Namespace is a collection or group of names, usually sharing a context, that is identified by a globally unique name.  The naming convention uses Universal Resource Identifiers (URI), but indirectly through an alias so as to adhere to the XML name syntax.

For example,

<Chapter xmlns='http://www.wrox.com/bookdefs/BookContent.dtd'>

or

<Toysco xmlns:Per='urn:ProXML2e:www.wrox.com/Persons' xmlns:Inv='urn:ProXML2e:www.wrox.com/Invoices' >

In the first case, the Chapter attribute establishes a default namespace.  In the second case, the attributes establish two namespace prefixes that can be used in the following way anywhere within the scope of the Toysco element:

<Per:Name>...</Per:Name>
<Inv:Name>...</Inv:Name>

The default namespace or a previously established namespace can be overridden by another assignment in a sub-element.

XML Base

The XML Base attribute establishes a base identifier for linking other data.  For example, in the following XML

<Catalog xml:base="http://www.wrox.com/">
<Logo xml:base="/logos/">
<Image source="Wrox.png" />
</Logo>
</Catalog>

the image would be at "http://www.wrox.com/logos/Wrox.png".