Re: Custom sorting through xslt extension object
From: Dimitre Novatchev [MVP XML] (dnovatchev_at_yahoo.com)
Date: 03/30/04
- Next message: Oleg Tkachenko [MVP]: "Re: append data to XML file"
- Previous message: Ash: "How to generate xsl file from xsd"
- In reply to: Jiho Han: "Re: Custom sorting through xslt extension object"
- Next in thread: Jiho Han: "Re: Custom sorting through xslt extension object"
- Reply: Jiho Han: "Re: Custom sorting through xslt extension object"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 30 Mar 2004 09:22:26 +0200
"Jiho Han" <jiho.han@infinityinfo.com> wrote in message
news:%239ZICMdFEHA.3448@TK2MSFTNGP09.phx.gbl...
> I don't have a source xml but let me give you a scenario.
> Let's say we have an xml like:
>
> <persons>
> <person>
> <lastname>Smith</lastname>
> <firstname>John</firstname>
> <favoritecolor>red</favoritecolor>
> </person>
> <person>
> <lastname>Doe</lastname>
> <firstname>Jane</firstname>
> <favoritecolor>blue</favoritecolor>
> </person>
> <person>
> <lastname>Cooke</lastname>
> <firstname>Robin</firstname>
> <favoritecolor>yellow</favoritecolor>
> </person>
> </persons>
>
> Then say we want to sort the above by <favoritecolor> element values.
> However, the sorting mechanism won't be alphabetical. For
<favoritecolor>,
> proper ascending order is from warmest color to the coolest color: red,
> orange, yellow, green, blue, indigo, purple, etc. As you can see, I came
up
> with the sorting order - based on rainbow colors. Really, the desired
> sorting order may be defined by the application arbitrarily. I am
guessing
> that this kind of sorting can only be achieved by extension objects. Let
me
> know if there is an example similar to the given scenario or any other
> resources that may be usuful for achieving the disired effects.
Yes, see for example "Date Sorting in pure XSLT"
at: http://www.topxml.com/code/default.asp?p=3&id=v20021212030100
As for generic sort in XSLT, see "Sorting with unknown number of sort keys "
at:
http://www.biglist.com/lists/xsl-list/archives/200303/msg00007.html
Cheers,
Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,
http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
- Next message: Oleg Tkachenko [MVP]: "Re: append data to XML file"
- Previous message: Ash: "How to generate xsl file from xsd"
- In reply to: Jiho Han: "Re: Custom sorting through xslt extension object"
- Next in thread: Jiho Han: "Re: Custom sorting through xslt extension object"
- Reply: Jiho Han: "Re: Custom sorting through xslt extension object"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|