RE: [xsl] Passing an XSLT variable into a <a name="Ixxx" href="javascript:location= line.

Subject: RE: [xsl] Passing an XSLT variable into a <a name="Ixxx" href="javascript:location= line.
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 12:15:47 +0100
You want an attribute value template:

 > <a name="Introduction" href="javascript:location='#Introduction';
>         parent.main_body.location={$testvar};
>         parent.right_side.location='section_1_tools.xml'">
> <img src="Bullets/SmallBlueBullet.gif" align="absmiddle"
>         border ="0" alt="{string(Heading2)}" /> </a>

Odd thing is, you're already using one successfully in the img/@alt
attribute!

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: andrew@xxxxxxxxxxxxxxxxxx [mailto:andrew@xxxxxxxxxxxxxxxxxx] 
> Sent: 21 September 2005 10:05
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Passing an XSLT variable into a <a name="Ixxx" 
> href="javascript:location= line.
> 
> Please forgive me if this posted twice ... I had a powercut 
> as I hit send 
> earlier. 
> 
> I am a real newbie to XSLT, creating a simple proof of 
> concept application 
> so that my employers might see the value of transforming and 
> presenting some 
> XML from a very large Excel spreadsheet. 
> 
> I am using notepad as the editor and the application is check 
> in and will be 
> displayed in Microsoft Internet Explorer 6. (MSXML).  I am 
> attempting to use 
> XSLT 2.0 as described in Dr Tennison's book. 
> 
> For the demo, the application has three frames controlled by 
> a menu in one 
> frame.  The menu, and other documents, are created by 
> transforming XML 
> pulled from Excel.  Bookmark is a field in the Excel that 
> exists in each 
> mode of the XML.  The creation of textvar works as I wish 
> (xsl:value-of 
> demonstrates this to me). 
> 
> 
> The pertinent code extract is ... 
> 
> ... 
> 
> <xsl:variable name ="testvar" 
> select="concat('Section_1#',Bookmark)" as= 
> "xs:string" />
>  
> 
> <a name="Introduction" href="javascript:location='#Introduction';
>         parent.main_body.location=$testvar;
>         parent.right_side.location='section_1_tools.xml'">
> <img src="Bullets/SmallBlueBullet.gif" align="absmiddle"
>         border ="0" alt="{string(Heading2)}" /> </a>
> 
> ... 
> 
> My problem is with having testvar read as "Section_1#Intro" 
> (if Bookmark for 
> this node was "Intro").  No matter how I try to place it - 
> quotes, with / 
> without $ etc, is is always read as a literal and the changes 
> in the other 
> frame just don't happen as desired. 
> 
> I have examined the archive and cannot find a solution (but 
> my lack f skill 
> may mean I missed an obvious analogue). 
> 
> I am truely stumped - I know how to escape in a <script> 
> </script> code 
> block, but this situation is different. 
> 
> Your help greatly appreciated. 
> 
> Andrew

Current Thread