Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Help with xsl:sort

Reply
Thread Tools

Help with xsl:sort

 
 
Tom Wright
Guest
Posts: n/a
 
      10-13-2006
Hi all

I'm using the following code with Apache and mod-xslt but it's not sorting
the elements as I want it to. At the moment, it sorts them with all items
starting with an uppercase letter first, like this:
A B C a b c

no matter what the setting of the case-order attribute is. It
rather looks like it's sorting them by ASCII (or unicode..?)
character order, rather than according to the language setting.

The lang attribute should be inferred automatically from the
system environment, but even if it is set manually (to "en-GB"),
the sort still does not work as expected.

According to the manual, with the attribute set to upper-first, it should do
this:
A a B b C c
....and with it set to lower-first, it should do this:
a A b B c C


Here's the code:

<xsl:apply-templates select="bookmark|alias[name(id(@ref)) = 'bookmark']"
mode="main">
<xsl:sort select="concat(title,id(@ref)/title)" lang="en-GB"/>
</xsl:apply-templates>

Thanks!

--
I'm at CAMbridge, not SPAMbridge
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      10-13-2006
Is there a reason you're trying to imply this using language, rather
than using the case-order attribute which is specifically intended for
the purpose?

http://www.w3.org/TR/xslt#sorting

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
Tom Wright
Guest
Posts: n/a
 
      10-13-2006
Joe Kesselman wrote:
> Is there a reason you're trying to imply this using language, rather
> than using the case-order attribute which is specifically intended for
> the purpose?


Sorry, I should've explained better. I've tried doing it with just lang,
with just case-order and with both specified but none of it makes any
difference to the final sorting order. Is this a bug in mod-xslt?

--
I'm at CAMbridge, not SPAMbridge
 
Reply With Quote
 
Tom Wright
Guest
Posts: n/a
 
      10-13-2006
To clarify, 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 by any definition that I've seen.

I don't really mind whether it sorts upper case items before or after lower
case, but I would like it to sort all items beginning with an "A" of either
case before all items beginning with a "B" of either case. Either of the
following would be fine:

A a B b C c
a A b B c C

I hope that makes it a bit clearer - sorry, I didn't explain very well the
first time around.

--
I'm at CAMbridge, not SPAMbridge
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      10-13-2006
In article <ego3pe$9nj$>,
Tom Wright <> wrote:

>To clarify, 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


Have you tried the same code with some other stylesheet processor?

-- Richard
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      10-13-2006
Tom Wright wrote:
> A B C a b c
> That's not a correct sorting order by any definition that I've seen.


Correct by ASCII (or Unicode) character order...

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
Tom Wright
Guest
Posts: n/a
 
      10-13-2006
Joseph Kesselman wrote:
> Tom Wright wrote:
>> A B C a b c
>> That's not a correct sorting order by any definition that I've seen.

>
> Correct by ASCII (or Unicode) character order...


Yes ok, but that's not "culturally correct" as per the specs, and it's not
what any non-techie counts as a sensible sorting order.


--
I'm at CAMbridge, not SPAMbridge
 
Reply With Quote
 
Joseph Kesselman
Guest
Posts: n/a
 
      10-13-2006
Tom Wright wrote:
> Sorry, I should've explained better. I've tried doing it with just lang,
> with just case-order and with both specified but none of it makes any
> difference to the final sorting order. Is this a bug in mod-xslt?


Certainly sounds like it. Try other processors.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
Tom Wright
Guest
Posts: n/a
 
      10-13-2006
Richard Tobin wrote:
> Have you tried the same code with some other stylesheet processor?


Good plan - I didn't have any others on the machine, but have just installed
xalan and it gives the same output (mod-xslt is based on libxslt and xalan
is based on libxalan)

If anyone knows of another xslt processor which does sorting correctly, I'd
like to try it out.

--
I'm at CAMbridge, not SPAMbridge
 
Reply With Quote
 
p.lepin@ctncorp.com
Guest
Posts: n/a
 
      10-13-2006

Tom Wright wrote:
> Richard Tobin wrote:


[sorting problems - A a B b C c sort order wanted]

> > Have you tried the same code with some other stylesheet
> > processor?

>
> Good plan - I didn't have any others on the machine, but
> have just installed xalan and it gives the same output
> (mod-xslt is based on libxslt and xalan is based on
> libxalan)
>
> If anyone knows of another xslt processor which does
> sorting correctly, I'd like to try it out.


How about using translate(), at least as a temporary
solution? It won't sort A and a, obviously, but at least
you'll get a A A a B b B C C c C etc., which is better than
nothing imho.

--
Pavel Lepin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57