Re: [xsl] Problem with xsl:template using XSLT 1.0

Subject: Re: [xsl] Problem with xsl:template using XSLT 1.0
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 4 Dec 2007 12:08:55 +0000
On 04/12/2007, David Carlisle <davidc@xxxxxxxxx> wrote:
> <xsl:apply-templates select="some-nodes[@id=current()/@id]"/>
> for example can't so easily be moved down on to the match.

Good point - that's also a good example to highlight what I was
thinking earlier - when it comes to maintaining a stylesheet is it
nicer to have:

<xsl:template match="some-nodes[@id = $someID]">...

or just

<xsl:template match="some-nodes">

...where the filter is done at select time?  The intended use for the
template is much more explicit in the former - when you edit that
template in the future you know it doesn't get applied to all
<some-nodes/>, and you won't be left scratching your head wondering
why the template hasn't fired.

I guess you can do it in both places - it kind of fits with the 2.0
philosophy of being as restrictive as possible.

> Looking down my stylesheets I seem to use both ways (and for-each (and
> more and more, for-each-group) in about equal measure.

Yep, I would say I do a mix of them all too, for no particular reason.

Andrew Welch

Current Thread