RE: [xsl] Sorting different date formats

Subject: RE: [xsl] Sorting different date formats
From: "Josh Canfield" <josh.canfield@xxxxxxxxxxxx>
Date: Tue, 13 Jan 2004 01:22:25 -0800
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: [xsl] 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