aspose file tools*
The moose likes XML and Related Technologies and the fly likes javascript in XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "javascript in XSL" Watch "javascript in XSL" New topic
Author

javascript in XSL

Janaki Samaraweera
Greenhorn

Joined: Aug 20, 2002
Posts: 6
Hi,
I am new to xml and xsl .
the requirement of our project is we have a xml document and corresponding
xsl style sheet.
once we create a HTML using the xml and xsl, how can we trap events based on
controls created.
i.e if we have a list box created in the final HTML, how can i trap the on
change event of the list box
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
You need to get a working version of HTML with all supporting JavaScript. Then you code JavaScript in XSL. The only tricky part is that "<" symbol cannot be used in XSL as is, it must be "escaped", and to avoid such a hassle people wrap scripts in CDATA sections.
So your XSL will look like
<?xml version='1.0'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
<html>
...
<script language="JavaScript">
<![CDATA[
function someFunction()
{ ... }
]]>
</script>


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript in XSL