home *** CD-ROM | disk | FTP | other *** search
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:include href="datetime_lib.xsl"/>
-
- <xsl:output method="html" encoding="ISO-8859-1" />
-
- <xsl:param name="today" select="20010827"/>
- <xsl:param name="firstWeekDay" select="1"/>
-
- <xsl:variable name="year" select="substring($today, 1, 4)"/>
-
- <xsl:variable name="n-abbreviatedDOW">
- <day>Mo</day>
- <day>Tu</day>
- <day>We</day>
- <day>Th</day>
- <day>Fr</day>
- <day>Sa</day>
- <day>Su</day>
- </xsl:variable>
-
- <xsl:variable name="abbreviatedDOW"
- select="document('')/*/xsl:variable[@name='n-abbreviatedDOW']/*"/>
-
- <xsl:template match="/">
- <html>
- <head />
- Today is: <xsl:text/>
- <xsl:call-template name="named-day-of-week">
- <xsl:with-param name="date" select="$today"/>
- </xsl:call-template>
- <p />
-
- <table>
- <xsl:call-template name="displayQuarter">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="Q" select="1"/>
- </xsl:call-template>
-
- <xsl:call-template name="displayQuarter">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="Q" select="2"/>
- </xsl:call-template>
-
- <xsl:call-template name="displayQuarter">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="Q" select="3"/>
- </xsl:call-template>
-
- <xsl:call-template name="displayQuarter">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="Q" select="4"/>
- </xsl:call-template>
-
- </table>
- </html>
- </xsl:template>
-
- <xsl:template name="displayQuarter">
- <xsl:param name="year"/>
- <xsl:param name="Q"/>
-
- <xsl:variable name="month" select="($Q - 1) * 3 + 1"/>
-
- <xsl:variable name="fMonth" select="concat(substring('00', 1, 2 - string-length($month)), $month)"/>
- <xsl:variable name="fMonth2" select="concat(substring('00', 1, 2 - string-length($month + 1)), $month + 1)"/>
- <xsl:variable name="fMonth3" select="concat(substring('00', 1, 2 - string-length($month + 2)), $month + 2)"/>
-
- <tr valign="top">
-
- <td>
- <xsl:call-template name="displayMonth">
- <xsl:with-param name="date"
- select="concat($year, $fMonth, '01')"/>
- </xsl:call-template>
- </td>
- <td>
- <xsl:call-template name="displayMonth">
- <xsl:with-param name="date"
- select="concat($year, $fMonth2, '01')"/>
- </xsl:call-template>
- </td>
- <td>
- <xsl:call-template name="displayMonth">
- <xsl:with-param name="date"
- select="concat($year, $fMonth3, '01')"/>
- </xsl:call-template>
- </td>
- </tr>
- </xsl:template>
-
-
- <xsl:template name="get-month">
- <xsl:param name="date"/>
- <xsl:variable name="tr-date" select="translate($date, '-', '')"/>
- <xsl:value-of select="substring($tr-date, 5,2)"/>
- </xsl:template>
-
- <xsl:template name="get-year">
- <xsl:param name="date"/>
- <xsl:variable name="tr-date" select="translate($date, '-', '')"/>
- <xsl:value-of select="substring($tr-date, 1,4)"/>
- </xsl:template>
-
- <xsl:template name="get-day">
- <xsl:param name="date"/>
- <xsl:variable name="tr-date" select="translate($date, '-', '')"/>
- <xsl:value-of select="substring($tr-date, 7)"/>
- </xsl:template>
-
- <xsl:template name="displayMonth">
- <xsl:param name="date"/>
-
- <xsl:variable name="month">
- <xsl:call-template name="get-month">
- <xsl:with-param name="date" select="$date"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="year">
- <xsl:call-template name="get-year">
- <xsl:with-param name="date" select="$date"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="nameOfMonth"
- select="substring-before(substring-after($default-month-names, concat('[', $month, ']')), '[')"/>
- <xsl:text>
</xsl:text>
- <center>
- <table border="0" cellpadding="6" cellspacing="0" width="80">
-
- <tr bgColor="#808080">
- <td colSpan="5">
- <font color="#f8f8f8">
- <strong><xsl:value-of select="$nameOfMonth"/></strong>
- </font>
- </td>
- <td colSpan="2">
- <font color="#f8f8f8">
- <strong><xsl:value-of select="$year"/></strong>
- </font>
- </td>
- </tr>
- <tr bgcolor="#E0E0E0">
- <xsl:for-each select="$abbreviatedDOW">
- <xsl:variable name="thisPos">
- <xsl:choose>
- <xsl:when test="$firstWeekDay = 1">
- <xsl:value-of select="position()"/>
- </xsl:when>
- <xsl:when test="$firstWeekDay = 0">
- <xsl:choose>
- <xsl:when test="position() = 1">7</xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="position() - 1"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <td>
- <font color="#0000E0">
- <xsl:value-of select="$abbreviatedDOW[position() = $thisPos]"/>
- </font>
- </td>
- </xsl:for-each>
- </tr>
-
- <xsl:variable name="firstDayOfMonth" select="concat(substring($date, 1, 6), '01')"/>
-
- <xsl:variable name="week-number">
- <xsl:call-template name="week-number">
- <xsl:with-param name="date" select="$firstDayOfMonth"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:call-template name="displayWeeks">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="month" select="$month"/>
- <xsl:with-param name="week" select="$week-number"/>
- </xsl:call-template>
-
- </table>
- </center>
- </xsl:template>
-
- <xsl:template name="displayWeeks">
- <xsl:param name="year"/>
- <xsl:param name="month"/>
- <xsl:param name="week"/>
-
- <xsl:variable name="weekStartDate">
- <xsl:call-template name="week-number-to-date">
- <xsl:with-param name="week" select="$week"/>
- <xsl:with-param name="year" select="$year"/>
- </xsl:call-template>
- </xsl:variable>
-
- <tr align="right" bgcolor="white">
- <xsl:variable name="dOffset">
- <xsl:choose>
- <xsl:when test="$firstWeekDay = 1">0</xsl:when>
- <xsl:when test="$firstWeekDay = 0">1</xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:for-each select="$abbreviatedDOW">
- <xsl:variable name="thisDate">
- <xsl:call-template name="date-add">
- <xsl:with-param name="date" select="$weekStartDate"/>
- <xsl:with-param name="add" select="position() - 1 - $dOffset"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="month-of-this-date">
- <xsl:call-template name="get-month">
- <xsl:with-param name="date" select="$thisDate"/>
- </xsl:call-template>
- </xsl:variable>
- <td>
- <xsl:choose>
- <xsl:when test="$month-of-this-date = $month">
- <xsl:variable name="color">
- <xsl:choose>
- <xsl:when test="$today = translate($thisDate, '-','')">
- <xsl:value-of select="'red'"/>
- </xsl:when>
- <xsl:when test="position() = 7
- or (position() = 6 and $firstWeekDay = 1)
- or (position() = 1 and $firstWeekDay = 0)">
- <xsl:value-of select="'navy'"/>
- </xsl:when>
- <xsl:otherwise>black</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <font color="{$color}">
- <xsl:variable name="thisDay">
- <xsl:call-template name="get-day">
- <xsl:with-param name="date" select="$thisDate"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="formattedDay">
- <xsl:choose>
- <xsl:when test="$thisDay < 10">
- <xsl:value-of select="substring($thisDay, 2)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$thisDay"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="$color = 'navy'">
- <strong><xsl:value-of select="$formattedDay"/></strong>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$formattedDay"/>
- </xsl:otherwise>
- </xsl:choose>
- </font>
-
- </xsl:when>
- <xsl:otherwise>
- <xsl:text> </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </td>
- <xsl:if test="position() = 7">
- <xsl:variable name="next-week-date">
- <xsl:call-template name="date-add">
- <xsl:with-param name="date" select="$weekStartDate"/>
- <xsl:with-param name="add" select="7"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="month-of-next-week">
- <xsl:call-template name="get-month">
- <xsl:with-param name="date" select="$next-week-date"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:if test="$month = $month-of-next-week">
- <xsl:call-template name="displayWeeks">
- <xsl:with-param name="year" select="$year"/>
- <xsl:with-param name="month" select="$month"/>
- <xsl:with-param name="week" select="$week + 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:for-each>
- </tr>
-
- </xsl:template>
- </xsl:stylesheet>
-