[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

convert String to date format and sort

Subject: convert String to date format and sort
From: Anil Kumar Veeramalli <anil.v@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Oct 2009 15:11:42 +0530
 convert String to date format and sort
Hi,

1) my current date format is 28-Oct-1987(dd-mmm-yyyy), want to convert it yyyy-mm-dd format.
2) sort the dates

XML code:
<Employee startdate="11/20/1999">
<name>John</name>
</Employee>
<Employee startdate="07/06/2001">
<name>John</name>
</Employee>
<Employee startdate="04/23/1999">
<name>John</name>
</Employee>


xslt code to sort by date:
<xsl:template match="Employee">
<xsl:apply-templates>
<xsl:sort select="substring(@startdate,7,4)"/> <!-- year sort -->
<xsl:sort select="substring(@startdate,1,2)"/> <!-- day sort -->
<xsl:sort select="substring(@startdate,4,2)"/> <!-- month sort -->
</xsl:apply-templates>
</xsl:apply-templates>



sorting this way is good approach or do we have any better approach.




Thanks,
Anil

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.