Hwo to do Hello World From XSLT to JavaScript?

R

RC

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:eek:utput 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>
 
A

Anton Spaans

RC said:
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:eek:utput 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>

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top