Subject: RE: xsl variable not resolved in javascript output
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 12 May 2005 16:55:36 +0100
|
The curly brace syntax is only available in attributes. In element content,
use <xsl:value-of select="$var"/>.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Annmarie Rubin (anrubin) [mailto:anrubin@xxxxxxxxx]
> Sent: 12 May 2005 16:40
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: Annmarie Rubin (anrubin)
> Subject: 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>
|