|
Subject: RE: [xsl] Sorting different date formats From: "Josh Canfield" <josh.canfield@xxxxxxxxxxxx> Date: Tue, 13 Jan 2004 09:26:47 -0800 |
I think you can simplify this a lot. The text value for the date sorts correctly without transforming it to a number.
<xsl:template match="/dates">
<xsl:for-each select="endDate">
<xsl:sort select="." data-type="text"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:template>
If you did need to do the processing, it seems like it would be simpler to put the translate into the sort elements select statement instead of creating a variable:
<xsl:template match="/dates">
<xsl:for-each select="endDate">
<xsl:sort select="translate(.,'-','')" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:template>
Josh
-----Original Message-----
From: Mukul Gandhi [mailto:mukulgandhi2003@xxxxxxxxxxx]
Sent: Tuesday, January 13, 2004 8:27 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Sorting different date formats
Hi Allan,
I have come up with a sorting algorithm. Hope its
correct, and suits your requirement ;)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl">
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:template match="/dates">
<xsl:variable name="RTF">
<xsl:for-each select="endDate">
<endDate>
<xsl:value-of select="translate(.,'-','')"/>
</endDate>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($RTF)/endDate">
<xsl:sort select="." data-type="number"/>
<endDate>
<xsl:value-of select="substring(. , 1, 4 )"
/>-<xsl:value-of select="substring(. , 5, 2 )"
/>-<xsl:value-of select="substring(. , 7, 2 )" />-
</endDate>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
--- allan.mccluskey@xxxxxxxxxxxxxxxxx wrote: > 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
>
________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Sorting different date fo, Josh Canfield | Thread | RE: [xsl] Sorting different date fo, allan . mccluskey |
| RE: [xsl] Getting the data type of , Michael Kay | Date | Re: [xsl] Anyone can explain me thi, Wendell Piez |
| Month |