Page 1 of 1

date / variable problem

Posted: Tue Jun 20, 2006 8:25 pm
by wilkinsr
I use this code to retrieve the month and year from a website, and want to retrieve the month name and year. The year works fine, but I get results like, MAY05 or JUNE06 for the month (month name and index). Any idea why this is happening? Any idea how I can get this thing to work.


<xsl:variable name="date" select="document('http://xobjex.com/cgi-bin/date.pl')/date"/>
<xsl:text>LAST REVISED: </xsl:text>
<xsl:variable name="month" select="$date/utc/month"/>
<xsl:choose>
<xsl:when test="$month = 01">January</xsl:when>
<xsl:when test="$month = 02">February</xsl:when>
<xsl:when test="$month = 03">March</xsl:when>
<xsl:when test="$month = 04">April</xsl:when>
<xsl:when test="$month = 05">May</xsl:when>
<xsl:when test="$month = 06">June</xsl:when>
<xsl:when test="$month = 07">July</xsl:when>
<xsl:when test="$month = 08">August</xsl:when>
<xsl:when test="$month = 09">September</xsl:when>
<xsl:when test="$month = 10">October</xsl:when>
<xsl:when test="$month = 11">November</xsl:when>
<xsl:when test="$month = 12">December</xsl:when>
<xsl:otherwise>INVALID MONTH</xsl:otherwise>
</xsl:choose>

Re: date / variable problem

Posted: Tue Jun 20, 2006 8:28 pm
by wilkinsr
wilkinsr wrote:I use this code to get the month and year from a website, and want to retrieve the month name and year. The year works fine, but I get results like, MAY05 or JUNE06 for the month (month name and index). Any idea why this is happening or how I can get this thing to work.


<xsl:variable name="date" select="document('http://xobjex.com/cgi-bin/date.pl')/date"/>
<xsl:text>LAST REVISED: </xsl:text>
<xsl:variable name="month" select="$date/utc/month"/>
<xsl:choose>
<xsl:when test="$month = 01">January</xsl:when>
<xsl:when test="$month = 02">February</xsl:when>
<xsl:when test="$month = 03">March</xsl:when>
<xsl:when test="$month = 04">April</xsl:when>
<xsl:when test="$month = 05">May</xsl:when>
<xsl:when test="$month = 06">June</xsl:when>
<xsl:when test="$month = 07">July</xsl:when>
<xsl:when test="$month = 08">August</xsl:when>
<xsl:when test="$month = 09">September</xsl:when>
<xsl:when test="$month = 10">October</xsl:when>
<xsl:when test="$month = 11">November</xsl:when>
<xsl:when test="$month = 12">December</xsl:when>
<xsl:otherwise>INVALID MONTH</xsl:otherwise>
</xsl:choose>

<xsl:value-of select="$month"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$date/utc/year"/>

Posted: Wed Jun 21, 2006 8:36 am
by Radu
Hi,

The problem is that you have a

Code: Select all

<xsl:value-of select="$month"/>
in the stylesheet fragment which outputs the numeric version of the month. Remove that line and everything seems to work OK.

Regards,
Radu.

Posted: Wed Jun 21, 2006 2:29 pm
by wilkinsr
Thanks, Radu. That did the trick.