RE: Sorting Using A Predefined Order
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[@name=current()/head]/@value" data-type="number"/> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Jeff Sese [mailto:jsese@xxxxxxxxxxxx] > Sent: 21 June 2007 05:16 > To: Xsl-List > Subject: 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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format