I hear time and time again about how you should avoid the use of XSLT for-each. That it\'s your inner imperative programming demon that should be banished.
What\'s
It is the use of a for-each
to call templates that is discouraged, not the widespread use of for-each
, per se. Even the Muenchian method of grouping relies on xsl:key
constructs with xsl:for-each
loops.
The idea of writing good XSLT is that the structure of your XML should dictate what templates are matched and then applied. Therefore, whenever possible, use apply-templates
to select the nodes, rather than applying a select using for-each
.