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 May 3rd, 2010, 04:15 PM
Authorized User
 
Join Date: Jul 2009
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default <xsl:when> condition failing

Hi,

The below when condition failing always as iam required to search and validate existence of a value

XML:
<xsl: variable name="valid">
<Klm>
<abc>45</abc>
<abc>67</abc>
</klm>
</xsl:variable>
<xsl:variable name="isThere>67</xsl:variable>
<xsl:when test ="count($isThere !=$valid/klm/abc) >0 >

...

</xsl:when>

the when condition is always failing since by default $valid/klm/abc is taking first value 45 always.Can somone let me know how to search the xml for a required value to pass that when condition

Thanks for your help

Last edited by scubin; May 3rd, 2010 at 04:19 PM.. Reason: correction to when condition
 
Old May 3rd, 2010, 06:42 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, I assume you're using an XSLT 2.0 processor - in 1.0, this would be an error.

The semantics of != can be surprising. Your condition $isThere !=$valid/klm/abc is true if there is a pair of values, one from the sequence $isThere and one from the sequence $valid/klm/abc, such that the two values in the pair are unequal.

You probably mean not($isThere = $valid/klm/abc), which is true if there is no pair of values that are equal.
__________________
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
<xsl:copy-of> with <xsl:element> learningxsl XSLT 8 February 5th, 2010 09:26 AM
embedded <xsl:element> into <xsl:with-param> petergoodman XSLT 2 July 9th, 2008 06:36 AM
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
Usage of '*' in test condition of <xsl:when> vikkiefd XSLT 5 March 12th, 2008 10:31 PM
<xsl:choose> and <xsl:otherwise> problem djmarquette XSLT 4 January 21st, 2005 01:56 PM





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