[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] or ??


Subject: RE: [xsl] <xsl:apply-templates> or <xsl:for-each> ??
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 21 Mar 2002 14:29:05 -0000

> 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

<xsl:for-each> (also called "pull processing") only works if you know
exactly the structure of the XML that your stylesheet is going to process.

But <xsl:apply-templates> is far more flexible. It defines rules for
processing each kind of element wherever it occurs. This makes the
stylesheet more resilient to changes in the source document structure, and
better able to deal with semi-structured information where elements may
occur in many different places. It also enables you to build up a library of
template rules that can be re-used for many different transformations of
many different document types.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


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



Current Thread
Keywords
xml