What's so bad about xsl:for-each?

后端 未结 5 1981
春和景丽
春和景丽 2021-01-12 23:35

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

5条回答
  •  太阳男子
    2021-01-13 00:06

    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.

提交回复
热议问题