Re: [xsl] The identity transform and attributes

Subject: Re: [xsl] The identity transform and attributes
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 21 Jan 2008 19:33:23 +0000
On 21/01/2008, David Carlisle <davidc@xxxxxxxxx> wrote:
> select="child::foo selects the parent of the current node,
>  match="child::foo" asks if that node is the child of anything.
> So unless you find it surprising that something can both have a parent
> and be a parent, I'm not sure what is surprising here?

Well when you put it like that...  :)

The bit I found non-intuitive (note the past tense now...) was that a
match pattern can be only attribute:: or child::  something that
doesn't get talked about much.

For example:

apply-templates select="parent::foo"


template match="foo"

That looks fine - I'm happy with that.  "foo" on its own looks right.
But when you realise that the match pattern is actually:

template match="child::foo" gets a bit harder to understand why it's like that.  If you say
it as "foo that is a child of some node" then it makes slightly easier
to comprehend.  And then when you think about it, all elements are
children of either another element, or the root node (correct?) it
makes sense that child:: is the default.

I think.


Andrew Welch

Current Thread