Thank you Dimitre.
Those solutions are quite nice and the second, quite complex, to be honest,
for me. However, I still fail to see how they would solve scenarios where
you cannot control the format or the nature of the sort keys. For example,
in your first solution, you know you're going to be processing the data
containing a certain datetime format. However, in many cases, this is not
possible. There are possibly mutiples of tens of possibilities in how a
datetime object may be formatted and doing something like "substring(str, 5,
3)" won't be adequate.
Even if a problem could be resolved with such a solution as your second
example, it might be cleaner in my opinion, to wrap the sorting mechanism in
an extension object, epecially when you know you will only be providing a
solution on a certain platform - in this case, Microsoft. Do you know of an
example where an extension object is used instead?
In any case, you have been most helpful and I can't appreciate enough how
skillful you are with xpath/xslt.
Thank you very much.
Jiho
[quoted text, click to view] "Dimitre Novatchev [MVP XML]" <dnovatchev@yahoo.com> wrote in message
news:c4b6gi$2g5tp1$1@ID-152440.news.uni-berlin.de...
>
> "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 >
>