xsl-list
[Top] [All Lists]

[xsl] How to round 2 digt year to 4 digit

2008-12-23 06:47:04
Hi list,

Unable to round year. Please see below and provide solutions.

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="concat(substring(.,7,2),substring(.,4,2),substring(.,1,2))"
order="ascending" data-type="text" /><xsl:copy-of
select=" replace(.,'
/','-')"/><xsl:text>&#xa;</xsl:text>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

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

Expected O/P:

<date>2006-11-05</date>
<date>2006-12-06</date>
<date>2007-12-07</date>
<date>2005-02-08</date>
<date>2005-12-09</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>
--~--