differences between for-each and templates in xsl?

前端 未结 7 692
你的背包
你的背包 2020-12-03 10:48

Both xsl:for-each and xsl:template are used to retrieve nodes from xml in an xsl stylesheet. But what is the fundamental difference between them? P

7条回答
  •  旧时难觅i
    2020-12-03 11:36

    These are to complete different XSLT instructions.

    More than push vs. pull style, this is more like iteration vs. recursion.

    xsl:for-each is an iterator instruction with all the benefits and constrains of iteration in a stateless declarative paradigm: a good processor should not polute the call stack.

    xsl:apply-templates is a general recursion instruction. General in the sense that it's more powerful than xsl:call-template: you "throw" the selected nodes to the pattern matching mechanism, a truly "dynamic function invocation".

提交回复
热议问题