Hello World,
I am try do call a JavaScript function from XSLT, but I got
function not avaible error. See "????" below.
Would someone out there tell me how?
Thank Q!
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:template match="/">
<html><head><title>Hello World</title>
<script type="text/javascript" language="JavaScript1.2">
function hello(w) {
return ("Hello " + w + "!");
}
//
</script>
</head><body>
<xsl:variable name="w" select='World' />
<!-- How do I call JavaScript function here? -->
<xsl:value-of select="????.hello($w)" />
</body></html>
</xsl:template>
</xsl:stylesheet>
Anton Spaans - 29 Mar 2005 20:58 GMT
> Hello World,
> I am try do call a JavaScript function from XSLT, but I got
[quoted text clipped - 26 lines]
> </xsl:template>
> </xsl:stylesheet>
If you want the *browser* to execute this javascript, based on a
variable-value, do this:
<xsl:variable name="w" select='World' />
...
...
<script language="javascript">
var someVar = hello("<xsl:value-of select="$w"/>");
...
...
</script>
...
If you want to execute javascript *from within the XSLT* transformation
itself, you have to use XSLT-extensions for JavaScript.
Go to this site for more info:
http://xml.apache.org/xalan-j/extensions.html
Good luck.