[xslt] Bug in xsl:sort when using data-type="number"?



I think I've stumbled over an error in the implementation of xsl:sort 
when using the "number" data type. Given the following XML document and 
stylesheet:

----- test.xml --------
<?xml version="1.0"?>
<a>
   <b>3</b>
   <b/>
   <b>1</b>
</a>
-----------------------

----- test.xsl --------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
<xsl:output indent="yes"/>

<xsl:template match="a">
   <a>
   <xsl:for-each select="b">
     <xsl:sort select="." data-type="number"/>
     <xsl:copy-of select="."/>
   </xsl:for-each>
   </a>
</xsl:template>

</xsl:stylesheet>
-----------------------------------------------------------------


libxslt (1.0.30, and also the current CVS version) produces the 
following output:

-------------------------
<?xml version="1.0"?>
<a>
   <b>3</b>
   <b/>
   <b>1</b>
</a>
-------------------------


While it's true that the XSLT 1.0 specification does not say where to 
put "NaN" values (the 1.1 Working Draft states "in ascending order a NaN 
precedes all other numeric values and in descending order it follows 
them"), I would at least expect "1" to appear before "3".

A quick test with other processors (Saxon, Xalan, MSXML) revealed that 
they handle this case correctly, so I guess it's a bug in libxslt. Or am 
I missing something?

Thanks,
Kaspar




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]