[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|