如何将xsl变量作为参数传递给脚本标记中的javascript函数?

sem*_*d3r 4 javascript xslt

我试过以下代码:

<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
   time({$xx});
</script>
Run Code Online (Sandbox Code Playgroud)

我的目的是通过time()中的document.write()显示文本.但它没有给出任何结果.

Tim*_*m C 6

花括号用于"属性值模板",但在这种情况下,您不是在这里创建属性,只是一个普通的文本节点.我想你需要做这样的事情

<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
   time(<xsl:value-of select="$xx" />);
</script> 
Run Code Online (Sandbox Code Playgroud)