私はこれに慣れていないので、このアプローチが引数を渡す正しい方法であるかどうかはわかりません。これを修正するか、これを行う別の方法を提案してください。ノード値を xslt から javascript 関数に渡したいです。
これは私のXMLファイルです:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<One>
<Two>
HelloWorld
</Two>
</One>
これは xslt ファイルです:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:variable name="url" select="One/Two"/>
<xsl:template match="/">
<html>
<script>
function Myclick(vara)
{
alert(vara);
}
</script>
<xsl:for-each select="One">
<a>
<xsl:attribute name="href">
http://www.google.com
</xsl:attribute>
<xsl:attribute name="onClick">
alert($url);
Myclick($url);
</xsl:attribute>
<xsl:value-of select="Two"/>
</a>
</xsl:for-each>
</html>
</xsl:template>