Subject: RE: [xsl] Less than comparison has changed into what? From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Fri, 31 May 2002 10:54:27 +0100 |
> When I parse : > <xsl:if test="pwd/level > $lev"> > > the parser (Saxon 7.1) warns me that the > comparison has changed. Can you tell me how? > I'd be thankful for that. > In the current draft XPath 2.0 specs, the rules for "<" and ">" have changed when the arguments are strings (or untyped nodes). In XPath 1.0, both operands were converted to numbers, and were compared numerically. Note this is different from "=", where they are compared as strings. In XPath 1.0, "1" = "1.0" is false, but "1" <= "1.0" is true. In XPath 2.0 WD, a numeric comparison happens if one or both operands is a number, but if both are strings (or untyped nodes), you get an alphabetic comparison (using the default collating sequence). This means that "10" < "2" (both operands strings) will be true. The rules are also generalized to allow comparison of other types such as dates and times. So you need to rewrite the expression by wrapping one or both operands in the number() function. Or better, initialize the $lev attribute so its type is numeric. One reason I put the warning into Saxon 7.1 was to try and get feedback on how many stylesheets were likely to be affected by this change. If there is strong reaction against it, the WG may change its mind. In my view, it's a change for the better and is worth making. (In Saxon 7.1, there is no schema support as yet, so all nodes are untyped. If you had a schema that defined pwd/level as being numeric, you would of course get a numeric comparison). Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Less than comparison has , David Carlisle | Thread | [xsl] Re: Parsing ???, Dimitre Novatchev |
Re: [xsl] speed of loading, Joerg Heinicke | Date | Re: AW: [xsl] Finding node having m, Antonio Fiol Bonnín |
Month |