I am new to this so I don't know whether this approach is the correct way to pass an argument. Please help me correct this or suggest another way to do this. I want to pass a node value from the xslt to a javascript function.
This is my XML file :
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<One>
<Two>
HelloWorld
</Two>
</One>
This is the xslt file :
<?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>