[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: RE:"*NEVER* use for-each"
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! David ----- Original Message ----- From: Chris Bayes <Chris@xxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, February 27, 2001 8:45 PM Subject: RE: RE:"*NEVER* use for-each" > Sorry if I was a bit short but he did prove me right. His next question was > " 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 idea > 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 > http://www.bayes.co.uk/xml > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|