A namespace must always be declared in an element that contains the
region where it will be used. This is done with an attribute of the
form
xmlns:prefix=URL,
where prefix is the namespace prefix to be
used (in this case, graph:) and
URL is a unique identifier in the form of
a URL or other resource identifier. Outside of the scope of this
element, the namespace is not recognized.
Besides keeping two like-named element types or attribute types
apart, namespaces serve a vital function in helping an XML processor
format a document. Sometimes the change in namespace indicates that
the default formatter should be replaced with a kind that handles a
specific kind of data, such as the graph in the example. In other
cases, a namespace is used to
"bless" markup instructions to be
treated as meta-markup, as in the case of XSLT.
Namespaces are emerging as a useful part of the XML tool set.
However, they can raise a problem when DTDs are used. DTDs, as we
will explain later, may contain declarations that restrict the kinds
of elements that can be used to finite sets. However, it can be
difficult to apply namespaces to DTDs, which have no special facility
for resolving namespaces or knowing that elements and attributes that
fall under a namespace (beyond the ever-present default one) are
defined according to some other XML application.
It's difficult to know this information partly
because the notion of namespaces was added to XML long after the
format of DTDs, which have been around since the SGML days, was set
in stone. Therefore, namespaces can be incompatible with some DTDs.
This problem is still unresolved, though not because of any lack of
effort in the standards community.