Subject: RE: SAXON 5.4 bug in boolean cast to number in xsl:sort From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx> Date: Fri, 04 Aug 2000 11:51:49 +0100 |
Mike, >> SAXON 5.4 seems not to automatically >> cast booleans to numbers when xsl:sort has a data-type of 'number'. > >There's a weirdness in the spec here: the value of the select expression >defining the sort key is always converted first to a string, and if >data-type is "number", this string is then converted to a number. The result >in this case is counter-intuitive, but it's clearly what the spec says. > >If you specify a sort key of "number(contains(x,y))" the boolean result of >contains is converted to a number, this is converted to a string to form the >sort key, the fact that data-type="number" then causes this string to be >converted back to a number (it will be the same number in cases other than >NaN, infinity, etc). Thanks for explaining that; sorry for misaccusing SAXON. I'd missed the stuff about converting the result of the select expression to a string first. I thought that the reason for this might be to do with making sure that the value of a node set was interpreted properly rather than being cast to NaN or something by number(), but number() casts node sets to strings before casting them to numbers anyway. Can anyone shed some light on the rationale behind converting a xsl:sort select expression to a string before using the data-type to determine the order to sort them in? Of course it doesn't matter very much in practice, just means that to get true things before false things, it's better to use: <xsl:sort select="boolean-expression" order="descending" /> (using the fact that 'true' is lexically more than 'false') rather than: <xsl:sort select="number(boolean-expression)" data-type="number" order="descending" /> (using the facts that true -> 1 and false -> 0 and that 1 is numerically more than 0). Cheers, Jeni Dr Jeni Tennison 4 Dudley Court, Beeston, Nottingham NG9 3HZ tel (day): 0115 906 1301 email (work): jeni.tennison@xxxxxxxxxxxxxxxx tel (mob): 07974 420 482 email (home): mail@xxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: SAXON 5.4 bug in boolean cast t, Kay Michael | Thread | problem using Xalan from within a s, andreg |
Re: Saxon VS XT, Sebastian Rahtz | Date | RE: exclude-result-prefixes, Julian Reschke |
Month |