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 June 27th, 2007, 06:09 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl:when test - comparison problem

Hi,

I am just trying to make a comparison to
a number and it does not work

<xsl:when test="users/msgstatus/@emailtypeid[1]=5">

which should fail because when I do
<xsl:value-of select="users/msgstatus/@emailtypeid[1]" /><br />

it says

6

 
Old June 29th, 2007, 04:45 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Given a set of values S, the XPath operator S=3 returns true if any value in the set is equal to 3. The xsl:value-of instruction (in XSLT 1.0) shows you the first value in S, ignoring the others.

I suspect you want

<xsl:when test="users/msgstatus[1]/@emailtypeid=5">

or perhaps

<xsl:when test="users[1]/msgstatus/@emailtypeid=5">

or perhaps


<xsl:when test="(users/msgstatus/@emailtypeid)[1]=5">

There's not much point using [1] on an attribute step because an element can only have one attribute with a given name.

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
values comparison in xsl sani723 XSLT 2 April 3rd, 2007 04:05 AM
XSL Params inside When Test shasto100 XSLT 3 April 21st, 2006 05:45 AM
XSL Test tclancy XSLT 2 February 3rd, 2006 02:49 PM
<xsl:if test="" Question kwilliams XSLT 2 August 9th, 2005 08:30 AM
Using xsl:if test attributes rdavisiii XSLT 4 November 9th, 2004 12:24 AM





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