RE: [xsl] xsl variable not resolved in javascript output

Subject: RE: [xsl] xsl variable not resolved in javascript output
From: Maria Amuchastegui <mamuchastegui@xxxxxxxxxxx>
Date: Thu, 12 May 2005 11:46:09 -0400
You're calling an XSL variable from inside a CDATA declaration, which is not
going to work. You can try removing the CDATA declaration, which is not
always needed for Javascript, or at least placing the variable outside it.

Maria

-----Original Message-----
From: Annmarie Rubin (anrubin) [mailto:anrubin@xxxxxxxxx] 
Sent: Thursday, May 12, 2005 11:40 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: Annmarie Rubin (anrubin)
Subject: [xsl] xsl variable not resolved in javascript output

Hello list,

an xsl template outputs javascript code to display frames in the resulting
html. I am trying to use an xsl variable in the javascript code to refer to
the url to display with frames, but can't get the correct syntax so that the
xsl variable is resolved to a file name. Is there a way to do this? I'm
using xalan 2.6.0.

The code snippet of the xsl is shown below.

This is the xsl:variable definition:

<xsl:variable name="__Frameset_File_Name_token">index.htm</xsl:variable>

I have tried the following syntax to specify the xsl variable in the
outputted javascript but the xsl variable is not resolved:

xsl code: "{$__Frameset_File_Name_token}" + "?" + document.URL; result in
html: {$__Frameset_File_Name_token

xsl code: "$__Frameset_File_Name_token" + "?" + document.URL; result in
html: $__Frameset_File_Name_token?

xsl code: $__Frameset_File_Name_token + "?" + document.URL; result in
html:no show/hide links

xsl code: "'$__Frameset_File_Name_token'" + "?" + document.URL; =20 result
in html: null filename. the link resolved to the containing directory

xsl code: '$__Frameset_File_Name_token' + "?" + document.URL; =20 result in
html:$__Frameset_File_Name_token

Thanks for your help,


Ann Marie


<!-- xsl code snippet -->

<xsl:template name="ShowTOCButton">

	
	<script language="javascript1.2" type="text/javascript">

  
  <xsl:comment><![CDATA[
  function showbook() {
  var showframeURL = '$__Frameset_File_Name_token' + "?" + document.URL;

  var hideframeURL = unescape(document.URL);

   if (window.self == top)
      {
 document.write("<a href='" + showframeURL + "' title='Show table of
contents and index'><font face='verdana, arial, helvetica, sans serif'
size='1'>Show Book</font></a>");
}

else
{
 document.write("<a href='" + hideframeURL + "' target='_top'
title='Hide table of contents and index'><font face='verdana, arial,
helvetica, sans serif' size='1'>Hide Book</font></a>"); }
   }
  showbook();

//]]></xsl:comment>
 </script>
</xsl:template>

Current Thread