[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Problem with Variables


Subject: RE: [xsl] Problem with Variables
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Mon, 2 Feb 2004 15:51:04 -0000

> I am writing a stylesheet which makes a conversion of a date. 
> ie: 1.3.2003 should become 2003.03.01

You can do this in one line:

<xsl:value-of select="
    concat(
    substring-after(substring-after($date,'.'),'.')
    ,'.',
    format-number(substring-before(substring-after($date,'.'),'.'),'00')
    ,'.',
    format-number(substring-before($date,'.'),'00')
    )"/>

The only bit I think you wont already know here is format-number(),
which in this case allows you to pad with zeros to get at least 2 digits

cheers
andrew 

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



Current Thread