带有param的XSLT模板

时间:2015-07-01 14:03:15

标签: templates xslt xalan

设置: Apache,Xalan 2.7.1,xslt 1.0 输入: 3个文件xml aprox。 750MB

鉴于名称调用了template with param,通过param传递当前上下文还是使用模板内部的current()函数可以获得性能提升吗?

<xsl:call-template name="one">
    <xsl:with-param name="context" select = "." />
</xsl:call-template>

    <!-- OR -->

<xsl:call-template name="two"/>

<xsl:template name="one"> 
    <xsl:param name = "context" />      
    <xsl:value-of select="$context/something"/>     
</xsl:template> 

<xsl:template name="two">   
    <xsl:value-of select="current()/somthing"/>     
</xsl:template>

1 个答案:

答案 0 :(得分:0)

正如@Michael Kay所说我做了一些测试, with-param 似乎比 current()功能略快。

测试输入:xml file540 mb),深度为3级root/l1/l2/l3

测试在apache Xalan 2.7.1上运行了8次

enter image description here

with-param 显示aprox。性能提高20%