how to set a javascript variable in an xsl variable.

Here should go questions about transforming XML with XSLT and FOP.
mebimathew
Posts: 7
Joined: Mon Nov 05, 2007 1:00 pm
Location: India

how to set a javascript variable in an xsl variable.

Post by mebimathew »

Hi
can you please tell me how to set a javascript variable in an xsl variable.
i have done like this
<xsl:variable name="hello">
<script language="javascript">
var i =0;
</script>
<script language="javascript">
alert('<xsl:value-of select="$hello"/>');
</script>
</xsl:variable>

i know this wont work..can you please tell me how to set a javascript variable in an xsl variable.

Thanks in advance
Hi all
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Post by Radu »

Hi,

I am not exactly sure what you are trying to accomplish.
You are declaring a variable and in it you are trying to refer to the same variable.
This can't be right.

Is this something more like what you want?

Code: Select all


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<xsl:variable name="hello" select="1"/>
<script language="javascript">
var i =<xsl:value-of select="$hello"/>;
</script>
<script language="javascript">
alert('<xsl:value-of select="$hello"/>');
</script>
</xsl:template>
</xsl:stylesheet>
If not, can you clarify more what you are trying to accomplish?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply