xsl-list
[Top] [All Lists]

Is this a sorting bug in xalan 6.4.0?

2003-02-06 10:01:13
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