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

后端 未结 5 2021
春和景丽
春和景丽 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-12 23:45

    Quick answer: XSLT is largely functional in nature, and imperative loops are not very functional.

    In general the based way to get the best out of XSLT is to use pattern matching as much as possible (xsl:apply-template rather than loops, ifs and call-template1).

    In the end, it is all about style, and will make little difference in short pieces of XSLT, but being more functional will help with longer/complex problems.

    1 Other than when creating functions which return values rather than modifying the output.

提交回复
热议问题