XML namespace

This MedLibrary.org supplementary page on XML namespace is provided directly from the open source Wikipedia as a service to our readers. Please see the note below on authorship of this content, as well as the Wikipedia usage guidelines. To search for other content from our encyclopedia supplement, please use the form below:

XML namespaces are used for providing uniquely named elements and attributes in an XML instance. They are defined by a W3C recommendation called Namespaces in XML. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a namespace then the ambiguity between identically named elements or attributes can be resolved.

A simple example would be to consider an XML instance that contained references to a customer and an ordered product. Both the customer element and the product element could have a child element "ID_number". References to the element ID_number would therefore be ambiguous unless the two identically named but semantically different elements were brought under namespaces that would differentiate them.

Namespace declaration

A namespace is declared using the reserved XML attribute xmlns, the value of which must be a Internationalized Resource Identifier (IRI), usually a Uniform Resource Identifier (URI) reference.

For example:

xmlns="http://www.w3.org/1999/xhtml"

Note, however, that the URI is not actually read as an online address; it is simply treated by an XML parser as a string. For example, the document at http://www.w3.org/1999/xhtml itself does not contain any code. It simply describes the XHTML namespace to human readers. Using a URI (such as "http://www.w3.org/1999/xhtml") to identify a namespace, rather than a simple string (such as "xhtml"), reduces the possibility of different namespaces using duplicate identifiers.

It is also possible to map namespaces to prefixes in namespace declarations. For example:

xmlns:xhtml="http://www.w3.org/1999/xhtml"

In this case, any element or attribute names that start with the prefix "xhtml:" are considered to be in the XHTML namespace.

See also

Wikipedia content modification information:

  • This page was last modified on 18 November 2008, at 09:04.

Wikipedia Authorship and Review

Wikipedia content provided here is not reviewed directly by MedLibrary.org. Wikipedia content is authored by an open community of volunteers and is not produced by or in any way affiliated with MedLibrary.org.

Wikipedia Usage Guidelines

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article on "XML namespace".

The URL for this specific entry is:

All Wikipedia text is available under the terms of the GNU Free Documentation License. (See Copyrights for details). Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.