In 2.0, you just need to write a user-defined function that translates your
keys into numbers, for example January->1, February->2, and so on. The use
xsl:sort select="my:function(head)".
In 1.0 it's a bit more difficult because you can't call user-defined
functions within the select expression of xsl:sort. But you can usually
achieve the same thing by means of table-defined mapping. Given a document
months.xml such as
<doc>
<month name="January" value="1"/>
<month name="February" value="2"/>
you can write
<xsl:sort
select="document('months.xml')/doc/month[(_at_)name=current()/head]/@value"
data-type="number"/>
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Jeff Sese [mailto:jsese(_at_)asiatype(_dot_)com]
Sent: 21 June 2007 05:16
To: Xsl-List
Subject: [xsl] Sorting Using A Predefined Order
Hi,
Is it possible to sort some data according to a predefined ordering?
I have a file like:
<root>
<div>
<head>Some text 1</head>
</div>
<div>
<head>Some text 2</head>
</div>
<div>
<head>Some text 3</head>
</div>
<div>
<head>Some text <4/head>
</div>
<div>
<head>Some text 5</head>
</div>
</root>
and i want it sorted using this ordering:
Some text 2
Some text 3
Some text 5
Some text 1
Some text 4
Is the only solution to this is creating my own collation?
Thanks!
-- Jeff
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--