RE: [xsl] Is this a sorting bug in xalan 6.4.0?

Subject: RE: [xsl] Is this a sorting bug in xalan 6.4.0?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 6 Feb 2003 23:32:18 -0000
The XSLT 1.0 specification does not define the precise rules for
collating strings, in fact it makes it quite clear that the rules are
implementation-defined. In real life, there are many different ways
people handle spaces and punctuation when compiling lists in
alphabetical order, and there is no right answer.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Stan Dyck
> Sent: 06 February 2003 17:01
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Is this a sorting bug in xalan 6.4.0?
> 
> 
> Can anyone explain this apparent bug in xalan 2.4.0? Given...
> 
> <NameList>
> 	<Record><Name>A</Name></Record>
> 	<Record><Name>AAL</Name></Record>
> 	<Record><Name>Amanda</Name></Record>
> 	<Record><Name>Amy</Name></Record>
> 	<Record><Name>A Maureen</Name></Record>
> </NameList>
> 
> ...and applying the following stylesheet...
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="html" indent="yes"/>
> 
> <xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
> <xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
> 
> <xsl:template match="NameList">
> 	<xsl:comment><xsl:value-of 
> select="system-property('xsl:vendor')"/>
> 	</xsl:comment>
> 	<table>
> 		<xsl:apply-templates select="Record">
> 			<xsl:sort select="translate(Name, 
> $lower, $upper)"/>
> 		</xsl:apply-templates>
> 	</table>
> </xsl:template>
> 
> <xsl:template match="Record">
> 	<tr><td><xsl:value-of select="Name"/></td></tr> 
> </xsl:template> </xsl:stylesheet>
> 
> I get...
> 
> <!--Apache Software Foundation--><table>
> <tr>
> <td>A</td>
> </tr>
> <tr>
> <td>AAL</td>
> </tr>
> <tr>
> <td>Amanda</td>
> </tr>
> <tr>
> <td>A Maureen</td>
> </tr>
> <tr>
> <td>Amy</td>
> </tr>
> </table>
> 
> ...using xalan, and (for example)...
> 
> <!--SAXON 6.4.1 from Michael Kay--><table>
>     <tr>
>        <td>A</td>
>     </tr>
>     <tr>
>        <td>A Maureen</td>
>     </tr>
>     <tr>
>        <td>AAL</td>
>     </tr>
>     <tr>
>        <td>Amanda</td>
>     </tr>
>     <tr>
>        <td>Amy</td>
>     </tr>
> </table>
> 
> ...using saxon. It looks like xalan is removing the space between "A" 
> and "Maureen", causing it to sort below Amanda. It looks like 
> a bug to 
> me, agreed? I couldn't find similar examples on either this list's 
> archives or on xalan's bug list.
> 
> Stan Dyck
> sgd@xxxxxxxxxxxx
> 
> 	
> p.s. Note, I can work around the bug by replacing my upper and lower 
> variables with...
> 
> <xsl:variable name="lower" select="' 
> abcdefghijklmnopqrstuvwxyz'"/> <xsl:variable name="upper" 
> select="'_ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread