#393876 libxslt: xsl:sort doesn't support (lower|upper)-first case-orders

Package:
libxslt1.1
Source:
libxslt
Description:
XSLT 1.0 processing library - runtime library
Submitter:
Tom Wright
Date:
2013-08-01 22:36:04 UTC
Severity:
wishlist
#393876#5
Date:
2006-10-18 08:35:45 UTC
From:
To:
*** Please type your report below this line ***
When using xsl:sort in the XSLT stylesheet with libapache2-modxslt, its
case-sensitive sorting doesn't work as expected or as defined by the W3C
specification.

I've tried using sort with each of its various options (as listed on
http://www.w3.org/TR/xslt#sorting), but no matter what I do it always sorts
the items like this:

 A B C a b c

That's not a correct sorting order according to the spec and it looks like
it's just putting the in ASCII or Unicode character order.

It should sort them like this:

  A a B b C c

if case-order="upper-first", or like this:

  a A b B c C

if case-order="lower-first".

#393876#8
Date:
2006-11-15 15:40:31 UTC
From:
To:
Hi!

Just curious, have you tried to set lang and data-type="text"
explicitly. This sounds like a bug, yeah, but xsl:sort has always
served me well, so it is kinda strange....

#393876#13
Date:
2006-11-17 10:42:30 UTC
From:
To:
I've just tried this, with the following xsl:sort directive:

<xsl:sort select="concat(title,id(@ref)/title)" data-type="text" lang="en"
case-order="lower-first" />

...it sorted this list of online shops into the following order:

Komplett
Overclockers UK
Scan
Tekheads.co.uk
dabs.com

So it doesn't work correctly, even with the data-type and lang attributes
specified explicitly.  With the fudged workaround to the problem, given by
the following xsl:sort directive:

<xsl:sort
select="translate(concat(title,id(@ref)/title),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"
data-type="text" case-order="lower-first"/>

...it sorted the list (correctly) into the following order:

dabs.com
Komplett
Overclockers UK
Scan
Tekheads.co.uk


Anyway, I hope that helps and let me know if I can run any further tests.

Tom

PS. I like the browser, good work! :)

#393876#18
Date:
2006-11-17 10:48:39 UTC
From:
To:
Nope! That's bad, I think too.

It sounds more likely that the bug is actually in the underlying library
than mod_xslt itself, and there is also a lot more effort going into
libxslt. Could you test with xsltproc on the command line?

Thanks! :-)

#393876#31
Date:
2008-11-01 17:40:14 UTC
From:
To:
Support for the lang attribute of xsl:sort has been added to libxslt and
should be available in the next release. If you set the lang attribute
you should get the following sort order for most languages:

A a B b C c

Additionally, all kinds of language specific rules should be honored.

The case-order attribute is still unsupported, but language dependent
sorting should serve most people just fine.

Nick

#393876#36
Date:
2013-07-30 09:15:07 UTC
From:
To:
Control: found -1 1.1.26-14.1

Actually I get a A b B c C (case-order being unsupported).

Testcase (apply this stylesheet on itself):

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
  <root>
    <item>c</item>
    <item>A</item>
    <item>B</item>
    <item>b</item>
    <item>a</item>
    <item>C</item>
    <upper-first>
      <xsl:for-each select="//item">
        <xsl:sort select="."
                  lang="en"
                  case-order="upper-first"/>
        <xsl:value-of select="."/>
      </xsl:for-each>
    </upper-first>
    <lower-first>
      <xsl:for-each select="//item">
        <xsl:sort select="."
                  lang="en"
                  case-order="lower-first"/>
        <xsl:value-of select="."/>
      </xsl:for-each>
    </lower-first>
  </root>
</xsl:template>

</xsl:stylesheet>

I get:

$ xsltproc case-sort.xsl case-sort.xsl
<?xml version="1.0"?>
<root>
  <item>c</item>
  <item>A</item>
  <item>B</item>
  <item>b</item>
  <item>a</item>
  <item>C</item>
  <upper-first>aAbBcC</upper-first>
  <lower-first>aAbBcC</lower-first>
</root>