开发者

XSLT iteration or recursion performance

开发者 https://www.devze.com 2023-03-20 05:43 出处:网络
Has anyone measured the performance of running equivalent similar XSL transformations iteratively or recursively using various libraries? I\'m most curious about Java libraries, but other suggestions

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

Example for iteration (valid, given 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, posit开发者_如何学Pythonion(), 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:

XSLT for each letter in a string

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.


this might answer your question Lukas

https://stackoverflow.com/questions/506348/how-do-i-know-my-xsl-is-efficient-and-beautiful

0

精彩评论

暂无评论...
验证码 换一张
取 消