RE: KindTest for namespaces

> However, writing it inline gives the impression that it could be 
> matched as an attribute, such as $alt/@xmlns:metric. From what I 
> understand, this is not the case. So count($alt/attribute()) would 
> return 0, but count($alt/node()) would return 1. If this is the case, 
> then it seems to be an omission not to have a namespace kind test 
> (especially when there is one for every other kind of node).

You can retrieve namespace nodes using the namespace axis,
count(namespace::*) will return the number of namespace nodes. But we have
deprecated the namespace axis in XPath 2.0 because we want implementations
to have maximum freedom in how they represent the information that modelled
formally in the Data Model using namespace nodes. In XQuery, and in XPath
2.0 if the namespace axis is not provided, there is no expression that
returns a namespace node.

There is no need for a KindTest for namespace nodes, because they are found
only on the namespace axis, so looking for all nodes on the namespace axis
works fine.
> 
> I can see no other way to do such matching/resolving other than using 
> get-in-scope-namespaces then resolving each prefix.

get-in-scope-namespaces() was indeed provided as a replacement for the
namespace axis. It provides the information that's needed (the set of
namespace prefix/uri pairs for each element) without imposing semantics that
aren't needed (namespace nodes have distinct identity, they have parents,
they have an ordering in document order).

Michael Kay

Received on Monday, 6 October 2003 18:18:16 UTC