[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: <xsl:apply-templates> or <xsl:for-each> ??
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 22 Mar 2002 11:54:51 -0500
use of xsl apply templates
[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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.