File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "javascript in XSL" Watch "javascript in XSL" New topic

javascript in XSL

Janaki Samaraweera

Joined: Aug 20, 2002
Posts: 6
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

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=''>
<xsl:template match="/">
<script language="JavaScript">
function someFunction()
{ ... }

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
It is sorta covered in the JavaRanch Style Guide.
subject: javascript in XSL
It's not a secret anymore!