Subject: Re: Grouping simple flat structure
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 17 Mar 2008 15:16:16 +0000
|
On 17/03/2008, Ian Proudfoot <ian.proudfoot@xxxxxxxxxxx> wrote:
> Thank you Andrew. I was not aware of the sibling recursion template.
> As I was already using the basic identity transform template, I replaced it
> with the modified version, but now some elements are not being copied to the
> output. Should it be possible to swap these two templates without re-working
> other templates?
Not really because a node that doesn't apply-templates to it's
following sibling will stop the recursion, whereas using the standard
identity the following sibling will get processed because of the
existing apply-templates call that was made from its parent.
For example:
<foo>
<bar/>
<baz/>
<bar/>
</foo>
with a no-op template for baz:
<xsl:template match="baz"/>
Here using the standard identity template both <bar>s will get
processed because of the <xsl:apply-templates/> call when the context
node was <foo>.
However using sibling recursion only the first <bar> is processed from
<foo>, then <baz/> then it stops, so using sibling recursion every
template has a responsibility to process its following sibling.
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
|