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[(_at_)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
--~------------------------------------------------------------------
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>
--~--