|
Subject: Re: [xsl] Date YYYYMMDD format XSLT 2.0 From: Florent Georges <lists@xxxxxxxxxxxx> Date: Tue, 16 Sep 2008 11:34:16 +0200 (CEST) |
Pankaj Chaturvedi wrote:
Hi
> <chapter version="Feb. 2000"/>
> The date could be optional can be taken as 01 by default. So the
> desired output required in "YYYYMMDD format".
Depending on your precise input, the following can give you a
solution (or an idea to adapt):
<xsl:variable name="months" as="element()+">
<m name="Jan" num="01"/>
<m name="Feb" num="02"/>
<m name="Mar" num="03"/>
<m name="Apr" num="04"/>
<m name="May" num="05"/>
<m name="Jun" num="06"/>
<m name="Jul" num="07"/>
<m name="Aug" num="08"/>
<m name="Sep" num="09"/>
<m name="Oct" num="10"/>
<m name="Nov" num="11"/>
<m name="Dec" num="12"/>
</xsl:variable>
<xsl:template name="test" match="/">
<xsl:variable name="re" select="
'^(([0-9]{{1,2}}) )?([A-Z][a-z][a-z]). ([0-9]{{4}})$'"/>
<xsl:analyze-string select="'02 Feb. 2001'" regex="{ $re }">
<xsl:matching-substring>
<xsl:variable name="day" select="regex-group(2)"/>
<xsl:sequence select="
concat(regex-group(4),
$months[@name eq regex-group(3)]/@num,
if ( string-length($day) eq 1 )
then '0' else '',
if ( $day ) then $day else '01')"/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
Regards,
--drkm
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Date YYYYMMDD format XSLT, Pankaj Chaturvedi | Thread | RE: [xsl] Date YYYYMMDD format XSLT, Pankaj Chaturvedi |
| Re: [xsl] Accessing the Nth Occurre, Andrew Welch | Date | RE: [xsl] Date YYYYMMDD format XSLT, Pankaj Chaturvedi |
| Month |