- From: <bugzilla@wiggum.w3.org>
- Date: Tue, 19 Jul 2005 19:07:02 +0000
- To: public-qt-comments@w3.org
- Cc:
http://www.w3.org/Bugs/Public/show_bug.cgi?id=1753 Summary: The sorting process Product: XPath / XQuery / XSLT Version: Last Call drafts Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: XSLT 2.0 AssignedTo: mike@saxonica.com ReportedBy: joannet@ca.ibm.com QAContact: public-qt-comments@w3.org According to section 13.1.1 (The Sorting Process) of the XSLT 2.0 spec, sorting is done pairwise for comparable types. The following stylesheet and input document illustrate why comparing values in pairs contradict with other requirements. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="doc/e"> <xsl:sort select="xs:float(@f),xs:integer(@i)" stable="yes"/> <xsl:value-of select="."/> </xsl:for-each> </xsl:template> </xsl:stylesheet> <doc> <e i="100000001">v1</e> <e f="100000000.0">v2</e> <e i="100000000">v3</e> </doc> The sort key for the first element is the xs:integer value 100000001, for the second is the xs:float value 100000000.0 and for the third is the xs:integer value 100000000. The sort keys for the first and third elements compare equal to the sort key for the second element, and the sort key specification is stable, so the first element must precede the second in the sorted sequence and the second must precede the third in the sorted sequence. However, the sort key for the third element is less than the sort key for the first element, so the third element must precede the first in the sorted sequence. A possible solution to this problem is to align sorting with XQuery's order by: The third bullet of section 3.8.3 (Order By and Return Clauses) of the XQuery spec says: All the non-empty orderspec values must be convertible to a common type by subtype substitution and/or type promotion. The ordering is performed in the least common type that has a gt operator. thanks, Joanne
Received on Tuesday, 19 July 2005 19:07:07 UTC