Although the XML 1.0 recommendation anticipated the need for XML
namespaces by noting that element type and attribute names should not
include colons, it did not actually support XML namespaces. Thus, XML
namespaces are layered on top of XML 1.0. In particular, any XML
document that uses XML namespaces is a legal XML 1.0 document and can
be interpreted as such in the absence of XML namespaces. For example,
consider the following document:
<google:A xmlns:google="http://www.google.org/">
<google:B google:C="bar"/>
</google:A>
If this document is processed by a namespace-unaware processor, that
processor will see two elements whose names are google: A and google:B.
The google:A element has an attribute named xmlns:google and the
google:B element has an attribute named google:C. On the other hand, a
namespace-aware processor will see two elements with universal names
{http://www.google.org}A and {http://www.google.org}B. The
{http://www.google.org}A does not have any attributes; instead, it has
a namespace declaration that maps the google prefix to the URI
http://www.google.org. The {http://www.google.org}B element has an
attribute named {http://www.google.org}C.
Needless to say, this has led to a certain amount of confusion. One
area of confusion is the relationship between XML namespaces and
validating XML documents against DTDs. This occurs because the XML
namespaces recommendation did not describe how to use XML namespaces
with DTDs. Fortunately, a similar situation does not occur with XML
schema languages, as all of these support XML namespaces. The other
main area of confusion is in recommendations and specifications such as
DOM and SAX whose first version predates the XML namespaces
recommendation. Although these have since been updated to include XML
namespace support, the solutions have not always been pretty due to
backwards compatibility requirements. All recommendations in the XML
family now support XML namespaces.
|
|