[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Date YYYYMMDD format XSLT 2.0

Subject: Re: Date YYYYMMDD format XSLT 2.0
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Tue, 16 Sep 2008 11:34:16 +0200 (CEST)
Re:  Date YYYYMMDD format XSLT 2.0
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.