[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to use xslt variable in javascript embedded in

Subject: Re: How to use xslt variable in javascript embedded in XSLT
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Fri, 10 May 2002 11:08:11 -0600
xslt javascript cdata
At 10:34 AM 5/10/2002, you wrote:
I'm trying to use a variable in my javascript which is embedded in my
stylesheet. Can you give me some suggestions on how to use it?

This question keeps coming up in this group so I feel that the following needs to be reiterated. Aside from MSXSL extension functions that use JavaScript directly DURING the transformation process, JavaScript never knows that XSLT exists. When you want to create JavaScript code using XSLT, it is exactly the same procedure as creating any textual content -- you simply write it out. The only "special" qualities about JavaScript code -- as far as XSLT should be concerned -- is that it tends to use special characters that need to be ignored by the XSLT processor. Such strings are often
"<", ">", "&", and "--". These can be outputted using d-o-e on some processors, and CDATA sections in others (or both).


Here is part of my stylesheet and the javascript embedded. I would like
to define a variable "path" using <xsl:variable
name="path">/development/jsp/markRecords.jsp</xsl:variable> and use this
variable in my javascript below.

So, break out of the current CDATA section, output the textual value of the XSL variable, and enter another CDATA section.
<![CDATA[
// Previous JavaScript code
var path = "]]><xsl:value-of select="$path" /><![CDATA[";
// Rest of JavaScript code
]]>





Greg Faron Integre Technical Publishing Co.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.