Subject: RE: [xsl] comparing a string to a number? From: Niko Matsakis <niko@xxxxxxxxxxxxx> Date: Wed, 17 Sep 2003 09:40:56 -0400 (EDT) |
Actually, the rules of xpath specify conversion to numbers when using the inequality operators (<, <=, >, >=). See the xpath spec, sec 3.4 "When neither object to be compared is a node-set and the operator is <=, <, >= or >, then the objects are compared by converting both objects to numbers and comparing the numbers according to IEEE 754. The < comparison will be true if and only if the first number is less than the second number. The <= comparison will be true if and only if the first number is less than or equal to the second number. The > comparison will be true if and only if the first number is greater than the second number. The >= comparison will be true if and only if the first number is greater than or equal to the second number." Thefore, saying "$a < '20'" is the same as "$a < 20". niko > Yes, '1A' will always be "less than" '20' when compared as strings. String sorting is based on the numeric value (usually ASCII) of each successive character. Thus '10000000' will be "less than" '2'. > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] comparing a string to a n, G. Ken Holman | Thread | Re: [xsl] comparing a string to a n, David Carlisle |
RE: [xsl] comparing a string to a n, G. Ken Holman | Date | Re: [xsl] comparing a string to a n, David Carlisle |
Month |