Subject: Re: [xsl] // expanding to descendant-or-self::node() From: Evan Lenz <evan@xxxxxxxxxxxx> Date: Wed, 17 Sep 2008 08:48:34 -0700 |
I think it only implies that if you're used to misinterpreting "//". ;-)Really - even though it implies attributes are descendants and that the attribute axis is available from node()s?
It looks like:More precisely, it expands to /descendant-or-self::node()/ That trailing slash makes it syntactically invalid on its own, whereas descendant-or-self::node() is a valid expression in its own right.
/foo/bar
expands to
/child:foo/child:bar
so // had to expand to
descendant-of-self::node()
so //@* works as a side-effect of that - a happy accident if you like.Actually, it's precisely the reason // is defined the way it is: so that //@* will work (and the less common //namespace::*). So it's really a special design concession rather than a happy accident. :-) I'm not aware of and can't think of any reason why "//" is defined the way it is other than so that //@* will work. Can you think of any?
I wonder how we should approach //@* - is it less effective thanI think I see what you're getting at. The expression //@*, because of the way the shorthand expands, "unnecessarily" traverses nodes that would never have attributes of their own (document node, text nodes, comments, and processing instructions). And you're wondering if all those dead ends might make the evaluation less efficient than evaluating //*/@*. I'm not an implementor, but I think you'll find that any processor worth its salt will have optimized //@* and probably "//" in general, rather than literally expanding it and going from there. In fact, //*/@* is probably optimized too, since you can tell by looking at the expression that it will only ever return attributes and there's no need to traverse nodes that don't have attributes.
//*/@* because it gets non-element nodes, or does it come under the
category of those things to leave to the processor.
It remind me of the identity template - calling apply-templates when
matching an attribute - no big deal, but not exactly good either.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] // expanding to descendan, Andrew Welch | Thread | RE: [xsl] // expanding to descendan, Michael Kay |
Re: [xsl] Tag movement in XML, Wendell Piez | Date | Re: [xsl] // expanding to descendan, Evan Lenz |
Month |