我是 xsl 的新手,我想调用函数 podInfo( < agr>) ,参数是我在 xsl 中捕获的 xml 文档的某些属性值。但函数调用不正确,任何人都可以建议我是对的吗?下面是片段
<xsl:variable name="xx" select="@name"/>
<td>
<a href="#" onclick="podInfo(<xsl:value-of select="$xx"/>)">
<xsl:value-of select="@name"/>
</a>
</td>
最佳答案
您需要使用<xsl:attribute>
元素,这将允许您撰写 onclick
很容易,即通过使用类似 <xsl:value-of>
的元素等Here is the XSLT2 spec关于这个元素。
它会是这样的:
<a href="#">
<!-- xsl:attribute means that instead of putting it's result
into output document, they will be placed as an attributes
value of parent element (<a> in this case) -->
<xsl:attribute name="onclick">
podInfo(<xsl:value-of select="$xx"/>)
</xsl:attribute>
<xsl:value-of select="@name"/>
</a>
参见this answer一些额外的例子。
关于javascript - 在具有某些参数的 xsl 中调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20115246/