Reputation: 4046
I found different result for following XSL transformation.
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="test">
<xsl:variable name="p1" select="a/@p1"/>
<xsl:variable name="p2" select="a/@p2"/>
<xsl:variable name="p3" select="a/@p3"/>
<xsl:value-of select="$p1+$p2*$p3"/><br />
<xsl:value-of select="$p2*$p3+$p1"/>
</xsl:template>
</xsl:stylesheet>
XML:
<test>
<a p1="1458569700" p2="60" p3="60"/>
</test>
libxslt:
<?xml version="1.0"?>
1458573300<br/>1458573300
Some kind of Java library (http://xslttest.appspot.com):
<?xml version="1.0" encoding="UTF-8"?>1.4585733E9<br/>1.4585733E9
Who is correct and why (reference to specification would be great)?
Upvotes: 0
Views: 132
Reputation: 116959
Both results are "correct" mathematically. In terms of standards, XSLT 1.0 does not allow scientific notation, but XSLT 2.0 does.
XPath 1.0:
https://www.w3.org/TR/xpath/#exprlex production [30]
XPath 2.0:
The rules for converting numbers to strings have changed. These may affect the way numbers are displayed in the output of a stylesheet. For numbers whose absolute value is in the range 1E-6 to 1E+6, the result should be the same, but outside this range, scientific format is used for non-integral xs:float and xs:double values.
https://www.w3.org/TR/xpath20/#id-incompat-in-true-mode
Upvotes: 1