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 November 14th, 2009, 01:33 PM
Authorized User
 
Join Date: Oct 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default Passing Variable value

Hello Everyone,

Can u please tell me how can i paas variable value in if contion.

I want to do like this :

Code:
<xsl:template match="Employee">

<xsl:when test="$emp='john'">
                <xsl:variable name="search">
                    <xsl:value-of select="'@search=$value"></xsl:value-of>
                </xsl:variable>
            </xsl:when>

 <xsl:if test="$search">
  
  <!-- code -->


</xsl:if>  

</xsl:template>
How can i variable 'search' in if condtion.

Thanks
Hari
 
Old November 14th, 2009, 01:43 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

There are (at least) two problems with your code: first of all, if you define a variable inside the xsl:when then you can't use it outside of the element.
And furthermore you seem to expect that it is possible to construct an XPath expression in a string variable and then evaluate that somewhere as an XPath expression. That is not possible with pure XPath, neither in XPath 1.0 nor in XPath 2.0.
You will need to look into extension functions of the XSLT processor you use if you think really need that.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a Variable LarryS Beginning PHP 1 August 8th, 2006 07:52 AM
passing variable tbekarov ASP.NET 2.0 Professional 7 February 1st, 2006 04:16 PM
Passing variable to a public variable Hudson40 Access VBA 2 February 25th, 2005 06:23 AM
Passing a variable mrideout BOOK: Beginning ASP.NET 1.0 3 August 6th, 2004 02:57 PM
passing variable gumgak Classic ASP Databases 13 June 29th, 2003 09:13 PM





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