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

RE: Sorting different date formats

Subject: RE: Sorting different date formats
From: "Josh Canfield" <josh.canfield@xxxxxxxxxxxx>
Date: Tue, 13 Jan 2004 01:22:25 -0800
xsl date format
The date format that you chose allows for sorting the value as text. 

Input XML:

<events>
	<event>
		<date>2004-02-12</date>
	</event>
	<event>
		<date>2003-02-15</date>
	</event>
	<event>
		<date>2004-03-01</date>
	</event>
	<event>
		<date>2001-02-11</date>
	</event>
	<event>
		<date>2004-11-15</date>
	</event>
</events>

The XSL template:

<!-- match the root of the document -->
<xsl:template match="/">
<!-- output sorted_events element -->
<sorted_events>
  <!-- Iterate over all events/event nodes -->
  <xsl:for-each select="events/event">
    <!-- sort the nodes by text value of the events/event/date node -->
    <xsl:sort select="date" data-type="text" order="ascending"/>
    <!-- copy of the event node to the output -->
    <xsl:copy-of select="."/>
  </xsl:for-each>
</sorted_events>
</xsl:template>


Output XML:

<sorted_events>
  <event>
    <date>2001-02-11</date>
  </event>
  <event>
    <date>2003-02-15</date>
  </event>
  <event>
    <date>2004-02-12</date>
  </event>
  <event>
    <date>2004-03-01</date>
  </event>
  <event>
    <date>2004-11-15</date>
  </event>
</sorted_events>

Hope this helps,
Josh

-----Original Message-----
From: allan.mccluskey@xxxxxxxxxxxxxxxxx
[mailto:allan.mccluskey@xxxxxxxxxxxxxxxxx]
Sent: Tuesday, January 13, 2004 12:28 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Sorting different date formats


Hi all,

Could someone please show me how to perform and XSL:SORT on an date in this
format? <endDate>2004-02-15</endDate>

I have many other sorts that I need to perform so an explantion would also
be much appreciated so I can fully understand how you do it : )

Many thanks,
Allan






Important:  This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege.  If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament.  If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.