[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Is xsl:for-each "syntactic sugar"?
On 7 May 2010, at 00:27 , Markus Karg wrote:
For several years, in fact, I consistently found that if I had a bug in a stylesheet that used for-each, recasting the for-each in terms of apply-templates with a special mode invariably removed the bug. In some cases, of course, I knew the bug was in the for-each, but in a few cases I had no idea where the bug was; since the bug went away when I eliminated the for-each, I inferred that it had been there. Perhaps this is just because I can never remember the difference between context node and current node, and so make mistakes. So I think my advice to XSLT authors would be: write the form which seems clearer to you. If unlike me you find for-each easy to understand and to write without bugs, then by all means use it! But if like me you find apply-templates natural and easy, then do not be frightened away from it by fears that XSLT processors may optimize it less well. It may be that (as Dimitre Novatchev suggests) for-each may run faster. And so if you run into performance problems, consider trying it. (But remember Jon Bentley's first rule of program optimization: don't do it until you know you need to do it.) YMMV, of course. -- **************************************************************** * C. M. Sperberg-McQueen, Black Mesa Technologies LLC * http://www.blackmesatech.com * http://cmsmcq.com/mib * http://balisage.net ****************************************************************
|
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
|