Re: [xsl] xsl:for-each vs. xsl:apply-templates

Subject: Re: [xsl] xsl:for-each vs. xsl:apply-templates
From: Dimtre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 11 Nov 2004 22:43:12 +1100
On Wed, 10 Nov 2004 12:53:35 -0500, Wendell Piez
<wapiez@xxxxxxxxxxxxxxxx> wrote:
> Hi Osman,
> 
> Always use xsl:apply-templates, unless you see that this requires you to
> create a new mode that will be used once only, in which case you can use
> xsl:for-each instead as "syntax sugar".
> 
> It's not quite that simple, but almost ... 

I strongly agree...

xsl:apply-templates is much richer and deeper than xsl:for-each, even
simply because we don't know what code will be applied on the nodes of
the selection -- in the general case this code will be different for
different nodes of the node-list. Also, the code that will be applied
can be written way after the xsl:apply templates was written and by
people that do not know the original author.

Cheers,
Dimitre.

P.S. Don't know why this reminds me of a statement someone made on
xml-dev that XQuery was a "superset of XSLT 2.0" ... ??

Current Thread