• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how can I embed javascript in an XSL

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Whenever I embed javascript inside an XSL via cdata the '<' and '&' signs get changed to < and & spoiling the javascript. Is there a way to stop this?
thanks
Jim
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You couldn't just use escape characters?
eg:- & for &
and < for < (I think)

Originally posted by ROOD:
Hello
Whenever I embed javascript inside an XSL via cdata the '<' and '&' signs get changed to < and & spoiling the javascript. Is there a way to stop this?
thanks
Jim


 
Brendan Kennedy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh man, it converted my escape characters!
Go look it up!

Originally posted by Brendan Kennedy:
You couldn't just use escape characters?
eg:- & for &
and < for < (I think)


 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ROOD",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually people put JavaScripts inside CDATA sections, then you do not need to escape & and <.
<script>
<xsl:comment>
<![CDATA[
*** your script here ***
]]>
</xsl:comment>
</script>
Or, if you do not have lots of &s and <s, you can insert them as
&lt; and &amp;
Brendan, here is the trick: replace leadind & with &amp; i.e. to show &lt; type &amp;lt;
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!