XML Namespace
XML Namespace
XML Namespace
XML namespace is a simple collection of names, such as the names of the elements and
attributes allocated in the XML document.
It allows each element and attribute in a document to be placed in a different namespace
mapped to a particular URI (Uniform Resource Identifier) which is used to define a
unique name for the namespace.
It helps to avoid element name conflict.
Purposes
To distinguish between elements and attributes from different vocabularies with different
meanings and that happen to share the same name.
To group all the related elements and attributes from different from a single XML
application together so that software can easily recognize them.
Two types
Prefixed Namespace
xmlns:prefix_name=“URI”
Default Namespace
xmlns=“URI”
Problem in prefix
There is a drawback to the prefix approach of the namespaces in xml document. The
reason for prefixing an element in an xml document is to prevent it from being duplicated.
However, if the prefixes are not unique, the original problem of duplication would still
exist.
To solve this problem, each namespace prefix is added to a uniform resource identifier or
URI that uniquely identifies the namespace.
URI is a series of characters used to differentiate names . To guarantee name uniqueness
in any xml documents that the company creates, the documents are associated with their
namespace.
xmlns attrribute