You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2004/04/05 18:45:18 UTC
DO NOT REPLY [Bug 28213] New: -
xslt silently changes numerical values
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28213>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28213
xslt silently changes numerical values
Summary: xslt silently changes numerical values
Product: XalanJ2
Version: CurrentCVS
Platform: All
OS/Version: All
Status: NEW
Severity: Critical
Priority: Other
Component: org.apache.xpath
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: paul.murray@gs.com
There is a bug in the file XStringForFSB.java in method toDouble(). The code
works by converting the input string into two long values - a values
called "longResult" that contains the number without any decimal point; and a
value called "scale" that contains a scaling factor determined by the position
of the decimal point.
This works fine when "longResult" and "scale" can fit into a signed 64-bit
quantity, but goes horrendously wrong if they can't. This is easy to have
happen: if the value "1234567890.0987654321" is pumped through the toDouble()
method it comes out as -0.3708569905531746. This is a very bad thing.
The problem is affecting Sun JDK 1.4.2 and BEA jRockit 1.4.2.
I attach a couple of files to illustrate. They are called "elements.xml"
and "elements.xsl". Put them into a directory and then (using a Sun or BEA JDK
1.4.2 release) run "java org.apache.xalan.xslt.Process -Q -IN elements.xml -XSL
elements.xsl". You'll see that the reported "atomic weight" for hydrogen is
right (it's 18 characters long), but the reported "atomic weight" for helium is
completely wrong (it's 20 characters long).
File 1: elements.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="17-2.xsl"?> <PERIODIC_TABLE>
<ATOM STATE="GAS">
<NAME>Hydrogen</NAME>
<SYMBOL>H</SYMBOL>
<ATOMIC_NUMBER>1</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>1.00794736038591744</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">20.28</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">13.81</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter">
<!-- At 300K, 1 atm -->
0.0000899
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Helium</NAME>
<SYMBOL>He</SYMBOL>
<ATOMIC_NUMBER>2</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>4.00260222345678901235</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">4.216</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">0.95</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter"><!-- At 300K -->
0.0001785
</DENSITY>
</ATOM>
</PERIODIC_TABLE>
File 2: elements.xsl :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="PERIODIC_TABLE/ATOM">
<xsl:value-of select="NAME"/>
<xsl:value-of select="number(ATOMIC_WEIGHT)"/>
<br/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This is a really really bad bug - it silently changes values from the input xml
document. I really can't think of anything worse for xslt to do.
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org