Re: [xsl] <xsl:apply-templates> or <xsl:for-each> ??

Subject: Re: [xsl] <xsl:apply-templates> or <xsl:for-each> ??
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 22 Mar 2002 11:54:51 -0500
[Laura Jenkins]

> I am really very much confused regarding when you make use of
> <xsl:apply-templates> and when you make use of <xsl:for-each>
> since i come from a programming background, it makes more sence for me to
> use <xsl:for-each> as I can imagine each node that is processed in a loop
.
> But technically <xsl:apply-templates> seems to be doing the same job.
> can some one advice me as to when exactly do we make use of
> <xsl:apply-templates> and when <xsl:for-each> is best used??
>
> and are there any any advantages/disadvantages of using apply-templates or
> for-each
>

Besides what Mike Kay said, xsl:for-each changes the context and
xsl:apply-templates does not.  Sometimes you have to change the context.
For example, suppose you use a second xml file as a lookup table and want to
apply a key to it.  You have to change the context to be the root of the
lookup table so you can apply the key, but you don't want to change the
overall context outside the lookup.  That's a good place to use
xsl:for-each.

Cheers,

Tom P


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread