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() <= 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) > 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
精彩评论