将XSLT变量设置为JavaScript变量?

时间:2021-10-26 22:38:24

How would I grab an XSLT variable and use it to set a JavaScript variable?

我如何获取XSLT变量并使用它来设置JavaScript变量?

I'm working on a bit of AJAX and in order to make it work to the fullest I would like to be able to grab XSLT variables and use those to set the default values of some JavaScript variables that I'll then be manipulating with jQuery.

我正在研究一些AJAX,为了让它充分发挥作用,我希望能够获取XSLT变量并使用它们设置一些JavaScript变量的默认值,然后我将使用jQuery进行操作。

1 个解决方案

#1


Stick something like the following in your XSLT part that outputs the JavaScript.

在输出JavaScript的XSLT部分中粘贴以下内容。

<xsl:variable name="myvar" select="'red'" />
<xsl:text>var myobj="</xsl:text><xsl:value-of select="$myvar"></xsl:value-of><xsl:text>"</xsl:text>

#1


Stick something like the following in your XSLT part that outputs the JavaScript.

在输出JavaScript的XSLT部分中粘贴以下内容。

<xsl:variable name="myvar" select="'red'" />
<xsl:text>var myobj="</xsl:text><xsl:value-of select="$myvar"></xsl:value-of><xsl:text>"</xsl:text>