[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Float values

Subject: RE: Float values
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 26 Jan 2004 11:10:26 -0500
float values
A gloss on this: whether 0.00 and 0 are the same depends on whether they are strings or numbers. Compared as strings they are not the same; compared as numbers they are. In XSLT they could be either.

The OP has xsl:if test="TotalPaid=0". child::TotalPaid here is a node set (the set of all child TotalPaid elements of the current node). So you have to know how to compare a node-set to a number; the XPath 1.0 casting rules are invoked for this:

If one object to be compared is a node-set and the other is a number, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the number to be compared and on the result of converting the string-value of that node to a number using the number function is true. [XPath 3.4]

0 is a number; the value 0.00 cast to a number is 0; 0 = 0 is true, so that's what we get.


But if you tested "TotalPaid='0'" that would be a test against a string value; the string "0" is not equal to the string "0.00", so it would test as false.

Cheers,
Wendell

At 11:59 AM 1/25/2004, Kenny wrote:
It would be true. 0.00 and 0 are the same in XSLT.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mark
Williams
Sent: Sunday, January 25, 2004 11:29 AM
To: XSL-List
Subject:  Float values

If a value in an xml file (say TotalPaid) was shown as 0.00

Would the following statement in the xslt stylesheet be correct

xsl:if test="TotalPaid=0" be true or false.

TIA

___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_
"Thus I make my own use of the telegraph, without consulting
the directors, like the sparrows, which I perceive use it
extensively for a perch." -- Thoreau



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.