[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Re: date-time formatting question
You're right. It is simple, just a bit long, and no, you don't necessarily need those templates. They are good, but big. Try this simple approach.:
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="UTF-8" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="text"> <xsl:apply-templates /> </xsl:template> <xsl:template match="date"> <xsl:variable name="day-part"> <xsl:choose> <xsl:when test="substring(.,8,1) = '0'"> <xsl:value-of select="substring(.,9,1)" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring(.,9,2)" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="year-part" select="substring(.,1,4)" /> <xsl:variable name="month-part"> <xsl:choose> <xsl:when test="substring(.,6,2) = '01'">January</xsl:when> <xsl:when test="substring(.,6,2) = '02'">February</xsl:when> <xsl:when test="substring(.,6,2) = '03'">March</xsl:when> <xsl:when test="substring(.,6,2) = '04'">April</xsl:when> <xsl:when test="substring(.,6,2) = '05'">May</xsl:when> <xsl:when test="substring(.,6,2) = '06'">June</xsl:when> <xsl:when test="substring(.,6,2) = '07'">July</xsl:when> <xsl:when test="substring(.,6,2) = '08'">August</xsl:when> <xsl:when test="substring(.,6,2) = '09'">September</xsl:when> <xsl:when test="substring(.,6,2) = '10'">October</xsl:when> <xsl:when test="substring(.,6,2) = '11'">November</xsl:when> <xsl:when test="substring(.,6,2) = '12'">December</xsl:when> <xsl:otherwise></xsl:otherwise> </xsl:choose> </xsl:variable> <date><xsl:value-of select="concat($month-part, ' ', $day-part, ', ', $year-part)" /></date> </xsl:template> </xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email -----Original Message----- From: Bruce D'Arcus <bdarcus@xxxxxxxxxxx> Sent: Tue, 3 Feb 2004 15:13:45 -0500 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: date-time formatting question I wrote: Input example: Umm, just to avoid potential confusion, I of course meant to write: March 15, 2003 Bruce XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|