[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: namespace URI of xmlns prefix

  • To: xml-dev@l...
  • Subject: Re: namespace URI of xmlns prefix
  • From: richard@i... (Richard Tobin)
  • Date: Mon, 18 Jul 2005 15:45:25 +0100 (BST)
  • Cc:
  • In-reply-to: <42D809F0.7050501@e...>
  • Organization: HCRC, University of Edinburgh

xmlns prefix
In article <42D809F0.7050501@e...> 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 
>xmlns="http://www.foo.com/some.namespace".
>
>- 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.