[ http://issues.apache.org/jira/browse/XALANJ-1854?page=all ]

Brian Minchau updated XALANJ-1854:
----------------------------------

    Fix Version: 2.7

> xslt silently changes numerical values
> --------------------------------------
>
>          Key: XALANJ-1854
>          URL: http://issues.apache.org/jira/browse/XALANJ-1854
>      Project: XalanJ2
>         Type: Bug
>   Components: XPath
>     Versions: CurrentCVS
>  Environment: Operating System: All
> Platform: All
>     Reporter: Paul Murray
>     Assignee: Xalan Developers Mailing List
>      Fix For: 2.7

>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to