RE: Confusion on XPath Grammar concerning attribute axis

These expressions are all perfectly legal, and all return an empty
node-set (in XPath 1.0) or an empty sequence (in XPath 2.0). It's
perfectly OK to ask for all the children of an attribute node, or all
the text nodes on the attribute axis, the system will just tell you that
there aren't any.
 
In 2.0, if you have static typing enabled, a path expression that will
always return an empty sequence can be reported as an error.
 
Generally it's not a good idea for the grammar of a language to enforce
semantic rules. Asking for sqrt(-1) should be a semantic error rather
than a syntactic one, and the same goes for these constructs.
 
Michael Kay
 

-----Original Message-----
From: www-xpath-comments-request@w3.org
[mailto:www-xpath-comments-request@w3.org] On Behalf Of Kirmse, Daniel
Sent: 15 January 2004 16:27
To: 'www-xpath-comments@w3.org'
Subject: Confusion on XPath Grammar concerning attribute axis



Hi,

I wonder what this expression means:

(1) /foo/@attr/bar

or what this one here means:

(2) /foo/@text()

ad (1):

This expression seems to be perfectly within the range of the grammar,
but I cannot understand what it means. Well /foo/@attr takes me to the
attribute "attr" of node "foo". But what does /bar do on this context?

ad(2):

Well this looks like a text() test on the attribute axis of foo. But
what is the meaning of that?



Thanks for any answers and hints!

Cheers,

Daniel

Received on Friday, 16 January 2004 10:06:44 UTC