Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2006, 08:20 AM
Authorized User
 
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using variable in XSLT -Need help !!!

I'm new in XSLT.I want to use a variable to store Id as a parameter like this :
<xsl:for-each select="NewDataSet/Table">
<tr>
<td style="font-family: Verdana;font-size : 8pt;color:blue">
<xsl:variable name="id" select="Id" />
<xsl:value-of select="Id"/>.
</td>
<td>
<a href="showCatalog.aspx?id='$id'" class="catalogLink" ><xsl:value-of select="Name"/> </a>
</td>
</tr>
</xsl:for-each>

but this code doesn't work properly.
I want href property in tag a should be"...showCatalog.aspx?id=1(=2,34,ect..):(
Can any one help me ?
Thanks you very much !

 
Old October 16th, 2006, 08:34 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need what's called an attribute value template (AVT).
Code:
<a href="showCatalog.aspx?id='{$id}'" class="catalogLink" ><xsl:value-of select="Name"/> </a>
--

Joe (Microsoft MVP - XML)
 
Old October 16th, 2006, 09:41 AM
Authorized User
 
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your explanation !

 
Old October 16th, 2006, 10:32 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

To substitute a variable (or any XPath expression) in a literal attribute value, use an attribute value template:

<a href="showCat.aspx?id={$id}">...</a>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT and JavaScript Variable kwilliams XSLT 5 April 21st, 2008 12:05 PM
assign XSLT variable to a wml variable arunagottimukkala XSLT 2 October 19th, 2007 05:15 AM
XSLT variable help needed ElinF XSLT 2 February 23rd, 2007 10:15 AM
Pass Value to XSLT variable bonekrusher XSLT 3 October 9th, 2006 10:16 AM
xslt variable problems lincsimp XSLT 2 August 17th, 2005 02:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.