This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to use xslt variable in javascript embedded in XSLT


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]