This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: RE:"*NEVER* use for-each"
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] RE:"*NEVER* use for-each"
- From: "Ben Robb" <b dot robb at cscape dot com>
- Date: Tue, 27 Feb 2001 17:37:25 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
- thread-index: AcCg4Z4/0VKzKxhFTTS8C5/4awIkggAAC2jw
- Thread-Topic: [xsl] RE:"*NEVER* use for-each"
Basically, for-each breaks the natural programming model of templates,
which, while slightly odd to most programmers coming in from
html/asp/javascript, makes sense when you actually understand what is
going on in the background of the process.
for-each is only really useful to do things out of the ordinary... for
most cases, where you want to process an XML document once and have
another XML document pop out of the other side, using templates will
mean shorter, more generic code, which keeps the size of your document
down and allows for reuse of code. for-each will produce identical
output, but, while it is easier to read in the first place, it relies
much more on knowing the structure of the input document in detail...
something that is not always an option. Templates, particularly
"catch-all" templates (match="*" for example), allow for unstructured
data to be inputted.
Also, it is the only way forward if you want to do any kind of recursive
processing.
It is a little harsh to say "never" use for-each - I do sometimes;
however, I tend to stick to templates for most cases.
Does that make sense? I'm in the middle of my 5th server install of the
day, so probably not *grin*
Ben
-----Original Message-----
From: Alexey Gokhberg [mailto:alexei@bluewin.ch]
Sent: 27 February 2001 17:17
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] RE:"*NEVER* use for-each"
FINLEY, Mike wrote:
>
> As a beginner, who has just used for-each to solve a problem, why
should I
> never use it?
>
I would also like to know the answer ...
Alexey Gokhberg,
XSLT implementer
Unicorn Enterprises SA
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list