OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] namespace URI of xmlns prefix

[ Lists Home | Date Index | Thread Index ]

In article <42D809F0.7050501@engageinteractive.com> you write:

>So if a namespace declaration like 
>xmlns:foo="http://www.foo.com/some.namespace"; is made, and that 
>declaration is considered a type of attribute, then:

First of all, the declaration is certainly an attribute at the XML
level, but namespace-aware layers on top of XML generally treat it
specially, and remove the attribute before the application gets hold
of it.  In XPath and XSLT for example, namespace declarations do not
appear as attributes.

The XML Infoset separates attributes that are namespace declarations
from ordinary attributes, giving elements two properties [attributes]
and [namespace attributes].

>- the namespace prefix of the attribute is "xmlns"
>- the local name of the attribute is "foo"
>- the value of the attribute is "http://www.foo.com/some.namespace";
>But what is the namespace URI of the attribute? What namespace does the 
>prefix "xmlns" belong to?

The original Namespaces spec said

  The prefix xmlns is used only for namespace bindings and is not
  itself bound to any namespace name.

But in response (I believe) to a request from the DOM working group,
the namespace http://www.w3.org/2000/xmlns/ was defined for it.  The
XML Infoset uses this namespace name for namespace attributes, but not
all interfaces use it; in particular SAX doesn't.

>And then you have default namespace declarations, such as 
>- the namespace prefix of the attribute is an empty string: ''

The "prefix" value for unprefixed attributes varies between
interfaces.  The XML Infoset says it "has no value".  Most APIs
represent it as an empty string "" or null.

>- the local name of the attribute is "xmlns"
>- the value of the attribute is "http://www.foo.com/some.namespace";
>And I presume in this case, the namespace URI would be an empty string?

According to the XML Infoset, the namespace URI is 
http://www.w3.org/2000/xmlns/ in this case too.

>I'm asking because I'm unsure how a DOM method like getAttributeNS is 
>supposed to deal with namespace declarations.

If you want a definitive answer for a particular API such as the DOM,
consult that interface's documentation, or possibly your implementation's
source code...

-- Richard


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS