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 11th, 2009, 10:40 AM
Authorized User
 
Join Date: Oct 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default Parameter value in If condition

Hi All,

How can i use parameter value in if condtion in place of boolean value 'And/Or'

I am trying like below:

Code:
 <xsl:template match="summary">
        <xsl:param name="field1"></xsl:param>
        <xsl:param name="field2"></xsl:param>
        <xsl:param name="boolean"></xsl:param>
        
        <xsl:if test="@keyword=$field1  $boolean @keyword=$field2">            
            
           <xsl:value-of select="summary"></xsl:value-of> 
        </xsl:if>
    </xsl:template>

I want to use ' $boolean' in if condition.

Thanks
Hari
 
Old November 11th, 2009, 10:48 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

'and' and 'or' are not boolean values, they are boolean operators. You can't use a variable with the name of an 'operator' in the place of an operator, not with XPath and not usually with other programming languages, unless they have some 'eval' function.

So unless you use an extension function that allows you to evaluate a string you construct at run-time as an XPath expression you can't do what you want.

Saxon 9 has http://www.saxonica.com/documentatio.../evaluate.html
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 11th, 2009, 11:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

An interesting variation on the common theme of "I want to construct an XPath expression as a string at run-time". You can do that with extensions such as saxon:evaluate(), but not with standard XSLT.

However, since there are only two variations here, you could do

Code:
test="($op='and' and @keyword=$field1 and @keyword=$field2) or
    ($op='or' and (@keyword=$field1 or @keyword=$field2))"
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the If Condition bex ASP.NET 3.5 Basics 2 June 30th, 2009 02:34 AM
how to pass a control parameter and process a return parameter in sqldatasource jayshankar ASP.NET 2.0 Basics 1 January 1st, 2009 10:18 AM
Parameter object malfunction - out parameter dash dev C# 2005 6 December 4th, 2007 12:58 PM
or condition kgoldvas XSLT 1 July 31st, 2007 03:44 AM
where condition...? mnr555 Crystal Reports 0 June 18th, 2006 05:32 PM





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