Best practice 1 : use templates in stead of < xsl:for-each > whenever you can (which is 99% of the cases)
(may I add MAINTAINABILITY as extra ingredient in the best practices, imho even the most important one)
For understanding xsl you realy need a bit of practice.
Not understanding what sth. is doing is very relative of course.
That goes doube for XSLT, since the xsl:for-each construct tends to be
for a novice, but is in fact
- less structured,
- less simple,
- less concise and
- a lot less maintainable
than templates, and only
- equaly readable (at best!!) for so. with a minimum of template experience.
NEVER, EVER USE THE < xsl:for-each > ELEMENT!
I admit, the title is somewhat
exaggerated, there do exist, I've been
told, cases in which a "xsl for each"
can have it's merits, but those cases
are very, very rare.
I once had to come up with a fairly
complicated xml/xslt client site in
less than a week, and used the
for-each element all over the place.
Now, several years later and, sort of,
wiser, I took my time and rewrote the
initial code, using only templates.
The code now is much much cleaner and
more adaptable.
Either you know this, or either you
should : < xsl:template > and < xsl:
apply-templates> are almost always the
way to go. If you are xsl-ing, and you
don't fully understand these tags,
stop your work now, learn them, get a
aha-erlebnis, and continue your work a
as a reborn (wo)man.