namespace axis interpretation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

namespace axis interpretation

minoru.tomisaka.zh

Intuitively, XPath expression //namespace:foo selects "the namespace nodes
with same namespace URI bound to the prefix foo by the given namespace
context", in corresponding to the interpretation of the element's node test.

For example, considering that the XML document:
<e xmlns="http://foo" xmlns:bar="http://bar" />

given namespace context: { xmlns:foo="http://foo" }
XPath expression: //namespace::foo
select, in my consideration:
nodeset: { xmlns="http://foo" }

given namespace context: { xmlns:bar="http://zoo" }
XPath expression: //namespace::bar
select, in my consideration:
nodeset: {} (empty nodeset)


On the other hand, XPath spec http://www.w3.org/TR/xpath describes:
* In section 2.3, a node test is true if the node has the equivalent
  expanded-name and,
* In section 5.4, a namespace node has an expanded-name: the local part
  is the namespace prefix (this is empty if the namespace node is for the
  default namespace); the namespace URI is always null.

My straightfoward interpretation of the above are:
* The QName of foo in //namespace:foo is foo, its expanded-name is
  {<null>}foo and,
* The QName of xmlns="http://foo" is xmlns, its expanded-name is
  {<null>}<""> and, so that,

given namespace context: { xmlns:foo="http://foo" }
XPath expression: //namespace::foo
select
nodeset: {} (empty nodeset)

given namespace context: { xmlns:bar="http://zoo" }
XPath expression: //namespace::bar
select, regardless of the namespace context,
nodeset: { xmlns:bar="http://bar" }

It seems that XPath expression //namespace:foo selects "the namespace
nodes with the bound prefix foo regardless of the namespace context".


But, the latter interpretation seems that any XPath cannot select the
default namespace declaration xmlns="..."
Possibly, is the correct notation of the namespace axis //namespace::xmlns
or //namespace::xmlns:foo ??? If this notation is legal, it seems to select
the default namespace declaration xmlns="..."

I'm confusing. The former or latter interpretation, which is correct ?

Thanks for your comment.