Home
XML namespaces
Namespaces are used when there is a requirement for elements and attributes of the same name to take on a different meaning depending on the context in which they are used. For instance, an element called TITLE would have a different meaning, depending on whether it was present within a PERSON element or within a BOOK element. In the case of the PERSON element, it would be something that is placed in front of a person's name, such as Mr. or Dr. In the case of a BOOK element, it would be the title of the book, such as Programming Guide.
If both elements, PERSON and BOOK, have to be defined in the same document, for example, in a library entry that associates a book with its author, a mechanism is required to distinguish between the two so that the correct semantics apply when the TITLE element is used in the document.
Namespaces provide this mechanism by allowing a namespace and an associated prefix to be defined. Elements that use a specific namespace prefix are said to be present in that namespace and have the meaning defined for them in the namespace. The prefix is separated from the element name by a colon character. In our example TITLE would be defined in two different namespace. One namespace would be concerned with elements relevant to holding information about books and the other namespace would be concerned with elements storing information about people. Example start tags for the elements might be <book:TITLE> and <people:TITLE>.
Detailed information about XML namespaces can be found at:
http://www.w3.org/TR/REC-xml-names/
ibm.com/redbooks