xsl-list
[Top] [All Lists]

[xsl] Sorting date format

2008-12-23 04:51:56
Hi List,

How to sort the date field. Please see below and provide solution.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <date>07/12/07</date>
    <date>11/12/06</date>
    <date>10/12/05</date>
    <date>21/02/05</date>
</root>

XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">
<xsl:output omit-xml-declaration="yes"/>

    <xsl:template match="/">
    <xsl:apply-templates/>
</xsl:template>

    <xsl:template match="root">
        <xsl:for-each select="date">
            <xsl:sort select="." order="ascending" data-type="text"
/><xsl:copy-of select="."/>
        </xsl:for-each>
    </xsl:template>
    
</xsl:stylesheet>

Required Output:

    <date>21/02/05</date>
    <date>10/12/05</date>
    <date>11/12/06</date>
    <date>07/12/07</date>

Regards,
Ramkumar


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>