Has anyone evaluated the performance of equivalent equivalent XSL transformations iteratively or recursively using various libraries? The Java libraries are most interesting to me, but other suggestions are also welcome.
An example for an iteration (presumably given ), assuming that //* probably matches several elements for the example, but not "true" for the "spirit" of XSLT):
<xsl:for-each select="//*[position() <= string-length(MyData/MyValue)]"> <someTags> <xsl:value-of select="substring(MyData/MyValue, position(), 1)"/> </someTags> </xsl:for-each>
An example for recursion (clean, but rather 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 overflows tend to be the place for heated discussions about XSLT cleanliness, and beginners need to learn XSLT properly. While I don't care about the verbosity of “purity” or the rather subjective “purity,” I really think about performance here.
Lukas Eder
source share