XSLT迭代或递归性能

XSLT迭代或递归性能

本文介绍了XSLT迭代或递归性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人使用各种库迭代地或递归地测量运行 类似 XSL转换的性能?我对Java库最感兴趣,但也欢迎其他建议。

Has anyone measured the performance of running similar XSL transformations iteratively or recursively using various libraries? I'm most curious about Java libraries, but other suggestions are welcome too.

迭代示例(有效, 假设那个 // * 可能与该示例的很多元素匹配,但对XSLT的精神不是真实:

Example for iteration (valid, assuming that //* probably matches quite a few elements for the example, but not "true" to the "spirit" of XSLT):

<xsl:for-each select="//*[position() &lt;= string-length(MyData/MyValue)]">
  <someTags>
    <xsl:value-of select="substring(MyData/MyValue, position(), 1)"/>
  </someTags>
</xsl:for-each>

递归示例(纯粹,但对同一任务非常冗长):

Example for recursion (pure, but quite verbose for the same task):

<xsl:template match="data/node">
  <xsl:call-template name="for-each-character">
    <xsl:with-param name="data" select="."/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="for-each-character">
  <xsl:param name="data"/>
  <xsl:if test="string-length($data) &gt; 0">
    <someTags>
      <xsl:value-of select="substring($data,1,1)"/>
    </someTags>
    <xsl:call-template name="for-each-character">
      <xsl:with-param name="data" select="substring($data,2)"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

这两个例子都来自这个问题:

Both examples were taken from this question:

注意:Stack Overflow往往是关于XSLT纯度和初学者必须正确学习XSLT的激烈讨论的地方。虽然我不太关心纯度的冗长,或者相当主观的纯度本身,但我真的很想知道这里的表现。

Note: Stack Overflow tends to be a place for heated discussions about the purity of XSLT and beginners having to learn XSLT correctly. While I don't care much about the verboseness of "purity", or the rather subjective "purity" itself, I really wonder about performance here.

推荐答案

这可能会回答你的问题Lukas

this might answer your question Lukas

这篇关于XSLT迭代或递归性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 02:59