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: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 21 Sep 2005 10:16:24 +0100
Put it in curly braces { }

eg href="blah.location={$testvar}"
                                 ^           ^
or build the attribute:

<xsl:attribute name="href">
  <xsl:value-of select="$testvar"/>

Some other points about your post:

- are you intending to transform client side?  If so you can only use XSLT
- never use notepad!  It will break you eventually... there are plenty
of XSLT editors out there and even more XML editors, any of those are
better than notepad.

On 9/21/05, andrew@xxxxxxxxxxxxxxxxxx <andrew@xxxxxxxxxxxxxxxxxx> wrote:
> 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
> XML from a very large Excel spreadsheet.
> I am using notepad as the editor and the application is check in and will
> displayed in Microsoft Internet Explorer 6. (MSXML).  I am attempting to
> 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
> 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