Re: [xsl] The identity transform and attributes

Subject: Re: [xsl] The identity transform and attributes
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 21 Jan 2008 17:30:23 +0100
David Carlisle wrote:
What's however still beyond me (and maybe I missed it on this afternoon's very interesting thread) is why @* uses the combined syntax of * (element) and @ (attribute),

No, * doesn't mean element it means "principal node kind" which is element on all axes except attribute: (where it's attribute and namespace:: (ehere it is namespace) this pricipal node kind stuff is introduced (I assume) just to give a ratinale for @* to mean whet it means, but the particular formulation has the effect that self:: axis could only be used with difficulty on attribute nodes in XSLT 1 and still in xslt 2 it isn't as natural as one might like.

(i.e., node() is supposed to be "any" node imo, but this is arguably not true as it does not include attribute nodes),

yes it does include attribute nodes,


attribute::node() and self::node() both select attribute nodes.
node() on its own is short for child::node() which does not select
attribute nodes because there are never any attributes in the child
axis, it is teh child axis that does not include attributes, not the
node() node test.

That's a great insight. Sometimes knowing how to write something is one thing, knowing why it is the way it is (and in this sense, understand the default axis) makes it clearer, brighter and, most importantly, understandable.


Thanks,
Abel

PS: what worries me is that I've received this kind of lecture before and apparently it does not really sink in, even though I feel I have quite an understanding about XSLT. Ah well, next year perhaps ;)

Current Thread