difference between xsl:param and xsl:variable

后端 未结 1 456
一个人的身影
一个人的身影 2021-02-06 23:07

i am considering either one to use when defining an xsl:template name = myTemplate that will be called in another xsl file.

legacy code seems to use \'xsl:variable\' whe

相关标签:
1条回答
  • 2021-02-06 23:56

    The difference is that the value of an xsl:param could be set outside the context in which it is declared. For example, see:

    <xsl:template ...>
       <xsl:param name="p" select="'x'" />
       <xsl:variable name="v" select="'y'" />
    ...
    

    then you know that $v will always give you the string 'y'. But for $p the string 'x' is only a default: you will see a different value if the template is invoked with either xsl:apply-templates or xsl:call-template which contains an instruction such as:
    <xsl:with-param name="p" select="'not x'" />

    <xsl:param> may also be used outside xsl:template, at the top level in the stylesheet. The value of such a parameter may be set when the XSLT processor is called. How this is done depends on the processor and whether you call it from the command line or by program.

    0 讨论(0)
提交回复
热议问题