About XML Namespaces
An XML namespace is a Uniform Resource Indicator (URI). A URI can be either a Uniform Resource Locator (URL) or a Uniform Resource Name (URN) that is uniquely associated with an element or attribute name.
Namespaces can:
- Uniquely identify element and attribute names so that there is no data confusion when the names are transmitted. If two or more organizations use the same element or attribute names in their XML documents, when they transmit those documents outside of the organization, the names can collide.
- Provide context for element and attribute names.
Namespaces are not required. However, for documents that are transmitted outside of the organization or in large organizations where similar names might be used by different departments, they are invaluable.
Here is an example of a namespace declaration for the element order:
<order xmlns=’uuid.12345...67890’ />
If a namespace is declared for an element, any subordinate elements or attributes inherit that namespace by default. However, a subordinate element or attribute can have a separate namespace defined for it.
Here are examples of namespace declarations for an element and a subordinate element:
<order xmlns=’uuid.12345...67890’ >
<number xmlns=’uuid.09876...54321, />
</order>
For more information, see About Namespace Prefixes.