Subject: [xsl] monthNumber from monthName From: James Cummings <james@xxxxxxxxxxxxxxxxx> Date: Sat, 21 Jan 2012 18:43:57 +0000 |
Hiya, I have an xslt2 function which gets a lower-case month name as a string and gives back its numerical equivalent. This is really trivially done as: <xsl:function name="jc:getMonth" as="xs:string"><xsl:param name="month"/> <xsl:choose> <xsl:when test="$month='january'">01</xsl:when> <xsl:when test="$month='february'">02</xsl:when> <xsl:when test="$month='march'">03</xsl:when> <xsl:when test="$month='april'">04</xsl:when> <xsl:when test="$month='may'">05</xsl:when> <xsl:when test="$month='june'">06</xsl:when> <xsl:when test="$month='july'">07</xsl:when> <xsl:when test="$month='august'">08</xsl:when> <xsl:when test="$month='september'">09</xsl:when> <xsl:when test="$month='october'">10</xsl:when> <xsl:when test="$month='november'">11</xsl:when> <xsl:when test="$month='november'">12</xsl:when> <xsl:otherwise>00</xsl:otherwise> </xsl:choose></xsl:function> But in the back of my head, since the result is just a leading-zero sequence number in a potential list of values.... I can't help thinking there is a better way to do this. If it was the month number I had and I wanted the month name, that'd be easy as just grabbing that item from the sequence. Suggestions? -James
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] cell height xsl, Jesse Schaaf | Thread | Re: [xsl] monthNumber from monthNam, Graydon |
Re: [xsl] cell height xsl, Jesse Schaaf | Date | Re: [xsl] monthNumber from monthNam, Graydon |
Month |