xsl-list
[Top] [All Lists]

RE: Is this a sorting bug in xalan 6.4.0?

2003-02-06 16:32:18
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(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Stan Dyck
Sent: 06 February 2003 17:01
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
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(_at_)standyck(_dot_)com

      
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