You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Reto Bachmann-Gmür <re...@gmuer.ch> on 2006/03/17 10:42:06 UTC
exponent in number and sorting
hello
My xml contains number in the following format:
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float">9.983066E-6</ns6:childStrength>
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0023</ns6:childStrength>
I'm using xsl:sort with data-type="number", however xalan doesn't seem to regard 9.983066E-6 as being smaller than 0.0023. Any way to tell xalan to do this?
Cheers,
reto
Re: exponent in number and sorting
Posted by Joseph Kesselman <ke...@us.ibm.com>.
> I would have thought XSLT and XML
> Schema share the same datatypes.
XSLT 1.0 predates XML Schema. This is one of the things XSLT 2.0 is looking
at changing, I believe.
______________________________________
Joe Kesselman -- Beware of Blueshift!
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
Re: exponent in number and sorting
Posted by Reto Bachmann-Gmür <re...@gmuer.ch>.
Hi Cristine,
Thanks for your reply. I think adapting the code generating the source
xml is the way to go.
However I'm a bit surprised as http://www.w3.org/TR/xmlschema-2/#float
says "For example, -1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 and INF are
all legal literals for float" and I would have thought XSLT and XML
Schema share the same datatypes.
Cheers,
reto
Christine Li wrote:
>
> Hi, Reto
>
> My previous email didn't really response to your question. Henry
> Zongaro pointed to me (Thanks, Henry for correcting me) that string
> value 9.983066E-6 doesn't match XPath 1.0 syntax for a number.
> number("9.9E-6") will return NaN. xsl:sort will work, however, the
> return won't be the expected result.
>
> You'd better change the format of those string values. If you really
> need to use scientific notation represents numbers, you may have to
> write a user extension function to do the conversion from string to
> double.
>
> Hope it helps,
>
> Christine Li
> XSLT Development
> IBM Toronto Lab
> Tel: (905)413-2601
> Email: jycli@ca.ibm.com
>
>
> *Reto Bachmann-Gmür <re...@gmuer.ch>*
>
> 17/03/2006 04:42 AM
>
>
> To
> xalan-j-users@xml.apache.org
> cc
>
> Subject
> exponent in number and sorting
>
>
>
>
>
>
>
>
>
> hello
>
> My xml contains number in the following format:
>
> <ns6:childStrength
> rdf:datatype="http://www.w3.org/2001/XMLSchema#float">9.983066E-6</ns6:childStrength>
> <ns6:childStrength
> rdf:datatype="http://www.w3.org/2001/XMLSchema#float">0.0023</ns6:childStrength>
>
> I'm using xsl:sort with data-type="number", however xalan doesn't seem
> to regard 9.983066E-6 as being smaller than 0.0023. Any way to tell
> xalan to do this?
>
> Cheers,
> reto
>
>
Re: exponent in number and sorting
Posted by Christine Li <jy...@ca.ibm.com>.
Hi, Reto
My previous email didn't really response to your question. Henry Zongaro
pointed to me (Thanks, Henry for correcting me) that string value
9.983066E-6 doesn't match XPath 1.0 syntax for a number. number("9.9E-6")
will return NaN. xsl:sort will work, however, the return won't be the
expected result.
You'd better change the format of those string values. If you really need
to use scientific notation represents numbers, you may have to write a
user extension function to do the conversion from string to double.
Hope it helps,
Christine Li
XSLT Development
IBM Toronto Lab
Tel: (905)413-2601
Email: jycli@ca.ibm.com
Reto Bachmann-Gmür <re...@gmuer.ch>
17/03/2006 04:42 AM
To
xalan-j-users@xml.apache.org
cc
Subject
exponent in number and sorting
hello
My xml contains number in the following format:
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float
">9.983066E-6</ns6:childStrength>
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float
">0.0023</ns6:childStrength>
I'm using xsl:sort with data-type="number", however xalan doesn't seem to
regard 9.983066E-6 as being smaller than 0.0023. Any way to tell xalan to
do this?
Cheers,
reto
Re: exponent in number and sorting
Posted by Christine Li <jy...@ca.ibm.com>.
Both the interpreted and compiled processor of the current code base works
fine with my example
<doc>
<inner1>5.6E-4</inner1>
<inner1>0.0056</inner1>
</doc>
<xsl:template match="doc">
<xsl:for-each select="inner1">
<xsl:sort select="." data-type="number"
order="descending"/>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
Which version of Xalan are you using? Please try with the latest release.
Christine Li
XSLT Development
IBM Toronto Lab
Tel: (905)413-2601
Email: jycli@ca.ibm.com
Reto Bachmann-Gmür <re...@gmuer.ch>
17/03/2006 04:42 AM
To
xalan-j-users@xml.apache.org
cc
Subject
exponent in number and sorting
hello
My xml contains number in the following format:
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float
">9.983066E-6</ns6:childStrength>
<ns6:childStrength rdf:datatype="http://www.w3.org/2001/XMLSchema#float
">0.0023</ns6:childStrength>
I'm using xsl:sort with data-type="number", however xalan doesn't seem to
regard 9.983066E-6 as being smaller than 0.0023. Any way to tell xalan to
do this?
Cheers,
reto