[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: namespace URI of 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|