Re: [xsl] RE:"*NEVER* use for-each"

Subject: Re: [xsl] RE:"*NEVER* use for-each"
From: "David Rigby" <D.A.Rigby@xxxxxxxxxxxxxx>
Date: Tue, 27 Feb 2001 21:11:27 -0000
The 'don't use xsl:for-each' beginner's rule sounds like extremely sound
advice to me.  I don't count myself as a massive expert in XSLT - I can
acomplish what I need to well, but I don't use it all day every day.  When I
started my current post I was confronted with tons of horrible stylesheets
written by new XSLT users
composed of long lists of for-each statements that could easily reduce down
to a few templates and a couple of calls to apply-template.  I think the
main problem when initially learning XSLT is that there's a big risk of
folks from procedural programming backgrounds (e.g. most of us) simply using
what appears most familiar, and hence xsl:for-each, xsl:if.  I did this at
first too, and the big problem is that using for-each very early on hinders
learning about the uses of the default template behaviour.  As soon as I got
out of the habit of xsl:for-each, my XSLT became more concise, elegant and
more easily modifiable.  That isn't to say that for-each doesn't have its
place, of course, but I think a warning to beginners to not simply fall into
using for-each without a good understanding of the fundamentals of XSLT is
good advice indeed and I thank whoever first suggested it!

----- Original Message -----
From: Chris Bayes <Chris@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, February 27, 2001 8:45 PM
Subject: RE: [xsl] RE:"*NEVER* use for-each"

> Sorry if I was a bit short but he did prove me right. His next question
> "[xsl] how do you redefine a variable".
> I am not saying never use <xsl:for-each> in xslt just that it is a
> "beginners rule". IMHO people learn xslt faster the sooner they get the
> of templates and stop thinking in a procedural way.
> Maybe <xsl:for-each> is faster to start with but there is a lot of
> <xsl:for-each> spaghetti out there bloated by loads of code to get round
> problems that just naturally fall out of using templates.
> Ciao Chris
> XML/XSL Portal
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread