[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unusual Sort

Subject: Re: Unusual Sort
From: Jirka Kosek <jirka@xxxxxxxx>
Date: Wed, 13 Apr 2005 16:47:53 +0200
chris kosek
Williamson, Chris wrote:

> I was wondering if there is any way to sort elements other than just the
> regular alphabetical order.  For example,  If you wanted to sort grade
> levels (Freshman, Sophmore, Junior, etc)  so that they are displayed in the
> correct order and not the alphabetical order (Freshman, Graduate, Junior,
> Senior, Sophmore). This is an optional piece of my application so if It
> can't be done fairly easily I will probably not worry about creating the
> functionality of the sort on page..in other words if it's a huge deal don't
> worry about going to the trouble of creating the sort..

In simple cases you can define lookup table in your document that will
map your values to sort values. E.g.

<g:grades>
   <grade sortas="1">Freshman</grade>
   <grade sortas="2">Sophmore</grade>
   ...
</g:grade>

And then translate grade text to ordinal number:
....
<xsl:sort select="document('')//g:grades/grade[. =
current()/grade]/@sortas" data-type="number"/>
....

				Jirka

--
------------------------------------------------------------------
   Jirka Kosek     e-mail: jirka@xxxxxxxx     http://www.kosek.cz
------------------------------------------------------------------
   Profesionalnm 9kolenm a poradenstvm v oblasti technologim XML.
      Podmvejte se na na9 novl spu9tln} web http://DocBook.cz
        Podrobn} pxehled 9kolenm http://xmlguru.cz/skoleni/
------------------------------------------------------------------

[demime 1.01d removed an attachment of type application/x-pkcs7-signature which had a name of smime.p7s]

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.