4

我尝试了以下代码:

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

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

4

2 回答 2

6

花括号用于“属性值模板”,但在这种情况下,您不是在此处创建属性,而只是一个普通的文本节点。我认为你需要做这样的事情

<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
   time(<xsl:value-of select="$xx" />);
</script> 
于 2012-05-08T12:15:08.613 回答
1

上面的代码片段应该有一个小的更正。参数应在单个引号内传递。

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

这将起作用。

于 2016-02-25T05:16:40.140 回答