Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2009, 03:11 AM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 119
Thanks: 25
Thanked 3 Times in 3 Posts
Default Sort in a particular way

I have xml like this, this is just a small example

Code:
<classdetail>
<Semester>Fall</Semester>
<Semester>spring</Semester>
<Semester>summer</Semester>
</classdetail>
And I want to sort it with XSLT so that it is output Spring followed by Summer then Fall.

how would I perform this?

Regards
 
Old May 14th, 2009, 03:33 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In XSLT 2.0:

Code:
<xsl:sort select="index-of('spring', 'summer', 'fall'), semester)"/>
In 1.0

Code:
<xsl:sort select="translate(substring(semester,2,1), 'pua', 'abc')"/>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
JohnBampton (May 14th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Sort @* sheila XSLT 2 July 17th, 2005 04:01 PM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM
SORT pallone XSLT 13 February 25th, 2005 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.