December 2002
Intermediate to advanced
672 pages
16h 53m
English
You want to convert from numerical values for days and months to symbolic values.
If internationalization is not important to your application, then the following simple code will do:
<xsl:template name="date:get-day-of-the-week-name"> <xsl:param name="day-of-the-week"/> <xsl:choose> <xsl:when test="$day-of-the-week = 0">Sunday</xsl:when> <xsl:when test="$day-of-the-week = 1">Monday</xsl:when> <xsl:when test="$day-of-the-week = 2">Tuesday</xsl:when> <xsl:when test="$day-of-the-week = 3">Wednesday</xsl:when> <xsl:when test="$day-of-the-week = 4">Thursday</xsl:when> <xsl:when test="$day-of-the-week = 5">Friday</xsl:when> <xsl:when test="$day-of-the-week = 6">Saturday</xsl:when> <xsl:otherwise> error: <xsl:value-of select="$day-of-the-week"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="date:get-day-of-the-week-abbreviation"> <xsl:param name="day-of-the-week"/> <xsl:choose> <xsl:when test="$day-of-the-week = 0">Sun</xsl:when> <xsl:when test="$day-of-the-week = 1">Mon</xsl:when> <xsl:when test="$day-of-the-week = 2">Tue</xsl:when> <xsl:when test="$day-of-the-week = 3">Wed</xsl:when> <xsl:when test="$day-of-the-week = 4">Thu</xsl:when> <xsl:when test="$day-of-the-week = 5">Fri</xsl:when> <xsl:when test="$day-of-the-week = 6">Sat</xsl:when> <xsl:otherwise> error: <xsl:value-of select="$day-of-the-week"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="date:get-month-name"> <xsl:param name="month"/> ...
Read now
Unlock full access