| |
---|
| | |
---|
| | @lectures-per-week: The number of lectures per week in the paper. Each lecture is assumed to occupy exactly one row in the resulting table, so this effectively determines the number of rows in the resulting table that each week occupies. [required] |
---|
| | --> |
---|
| | <template match="calendar"> |
---|
| | <common formats="/latex/xelatex/"> |
---|
| | <xsl:if test="not( @number-of-weeks )"> |
---|
| | <xsl:message terminate="yes"> |
---|
| | <xsl:text>Required attribute "number-of-weeks" has not been supplied in calendar.</xsl:text> |
---|
| | </xsl:message> |
---|
| | </xsl:if> |
---|
| | <xsl:if test="not( @lectures-per-week )"> |
---|
| | <xsl:message terminate="yes"> |
---|
| | <xsl:text>Required attribute "lectures-per-week" has not been supplied in calendar.</xsl:text> |
---|
| | </xsl:message> |
---|
| | </xsl:if> |
---|
| | |
---|
| | <common> |
---|
| | <!-- |
---|
| | Work out which columns to include based on the elements within the calendar. The week number and date columns will always appear in positions 1 and 2, and the rest follow in the order section, lecture, reading, laboratory, tutorial and assessment. This is slightly cumbersome, but it's pretty much forced on us by the way XSLT works. Since it doesn't matter if we draw the same \clines multiple times, if a column doesn't exist, we just set it's column number to the column number of the previous column. |
---|
| | Work out which columns to include based on the elements within the calendar. The week number and date columns will always appear in positions 1 and 2, and the rest follow in the order section, lecture, reading, laboratory, tutorial and assessment. This is slightly cumbersome, but it's pretty much forced on us by the way XSLT works. |
---|
| | |
---|
| | This is mainly relevant to (Xe)LaTeX in order to underline cells correctly. In (Xe)LaTeX it doesn't matter if we draw the same \clines multiple times, so if a column doesn't exist, we just set it's column number to the column number of the previous column. HTML doesn't really care, but we need to do the calculation anyway in order to work out the correct number of columns. |
---|
| | --> |
---|
| | <xsl:variable name="week-column">1</xsl:variable> |
---|
| | <xsl:variable name="date-column">2</xsl:variable> |
---|
| | <xsl:variable name="section-column" select=" |
---|
| |
---|
| | then $tutorial-column-2 + 1 |
---|
| | else $tutorial-column-2" /> |
---|
| | |
---|
| | <!-- |
---|
| | The number of columns will be equal to the column number of the last column. |
---|
| | The number of columns is equal to the column number of the last column. |
---|
| | --> |
---|
| | <xsl:variable name="num-columns" select="xs:integer( $assessment-column )" /> |
---|
| | |
---|
| | </common> |
---|
| | <common formats="/latex/xelatex/"> |
---|
| | <xsl:if test="not( @number-of-weeks )"> |
---|
| | <xsl:message terminate="yes"> |
---|
| | <xsl:text>Required attribute "number-of-weeks" has not been supplied in calendar.</xsl:text> |
---|
| | </xsl:message> |
---|
| | </xsl:if> |
---|
| | <xsl:if test="not( @lectures-per-week )"> |
---|
| | <xsl:message terminate="yes"> |
---|
| | <xsl:text>Required attribute "lectures-per-week" has not been supplied in calendar.</xsl:text> |
---|
| | </xsl:message> |
---|
| | </xsl:if> |
---|
| | |
---|
| | <!-- |
---|
| | This is used in a few places to set the width of column cells, etc., that contain numbers. I can't remember why I decided to pick twice the number of weeks as the size, other than to ensure a decent spacing around the numbers? |
---|
| | --> |
---|
| |
---|
| | <!-- |
---|
| | I was going to generate COL elements here, but they don't seem to be supported by all browsers. Damn. The same applies for THEAD/TFOOT/TBODY, but I may as well leave them in for the browsers that do support them. |
---|
| | --> |
---|
| | <thead class="calendar"> |
---|
| | <xsl:apply-templates select="header" /> |
---|
| | <xsl:apply-templates select="header"> |
---|
| | <xsl:with-param name="num-columns" select="xs:integer( $num-columns )" /> |
---|
| | </xsl:apply-templates> |
---|
| | </thead> |
---|
| | <tfoot class="calendar"> |
---|
| | <xsl:apply-templates select="footer" /> |
---|
| | <xsl:apply-templates select="footer"> |
---|
| | <xsl:with-param name="num-columns" select="xs:integer( $num-columns )" /> |
---|
| | </xsl:apply-templates> |
---|
| | </tfoot> |
---|
| | <tbody class="calendar"> |
---|
| | <xsl:apply-templates select="body" /> |
---|
| | <xsl:apply-templates select="body"> |
---|
| | <xsl:with-param name="week-column" select="xs:integer( $week-column )" /> |
---|
| | <xsl:with-param name="date-column" select="xs:integer( $date-column )" /> |
---|
| | <xsl:with-param name="section-column" select="xs:integer( $section-column )" /> |
---|
| | <xsl:with-param name="lecture-column-1" select="xs:integer( $lecture-column-1 )" /> |
---|
| | <xsl:with-param name="lecture-column-2" select="xs:integer( $lecture-column-2 )" /> |
---|
| | <xsl:with-param name="reading-column" select="xs:integer( $reading-column )" /> |
---|
| | <xsl:with-param name="laboratory-column-1" select="xs:integer( $laboratory-column-1 )" /> |
---|
| | <xsl:with-param name="laboratory-column-2" select="xs:integer( $laboratory-column-2 )" /> |
---|
| | <xsl:with-param name="tutorial-column-1" select="xs:integer( $tutorial-column-1 )" /> |
---|
| | <xsl:with-param name="tutorial-column-2" select="xs:integer( $tutorial-column-2 )" /> |
---|
| | <xsl:with-param name="assessment-column" select="xs:integer( $assessment-column )" /> |
---|
| | <xsl:with-param name="num-columns" select="xs:integer( $num-columns )" /> |
---|
| | </xsl:apply-templates> |
---|
| | </tbody> |
---|
| | </table> |
---|
| | </div> |
---|
| | </common> |
---|
| |
---|
| | <xsl:call-template name="newline-internal" /> |
---|
| | </common> |
---|
| | <common formats="/html/xhtml/"> |
---|
| | <tr> |
---|
| | <xsl:apply-templates /> |
---|
| | <xsl:apply-templates> |
---|
| | <xsl:with-param name="num-columns" select="xs:integer( $num-columns )" /> |
---|
| | </xsl:apply-templates> |
---|
| | </tr> |
---|
| | </common> |
---|
| | </template> |
---|
| | |
---|
| |
---|
| | <!-- |
---|
| | A week in the calendar. Each week has an associated number (automatically generated) and a date range, and spans some defined number of rows (default 2). The week number and date range are only generated for the first of these rows. |
---|
| | --> |
---|
| | <template match="week"> |
---|
| | <common> |
---|
| | <xsl:param name="num-columns" /> |
---|
| | </common> |
---|
| | <common formats="/latex/xelatex/"> |
---|
| | <xsl:param name="week-column" /> |
---|
| | <xsl:param name="date-column" /> |
---|
| | <xsl:param name="section-column" /> |
---|
| |
---|
| | <xsl:param name="laboratory-column-2" /> |
---|
| | <xsl:param name="tutorial-column-1" /> |
---|
| | <xsl:param name="tutorial-column-2" /> |
---|
| | <xsl:param name="assessment-column" /> |
---|
| | <xsl:param name="num-columns" /> |
---|
| | |
---|
| | <xsl:for-each select="row"> |
---|
| | |
---|
| | <!-- |
---|
| |
---|
| | <!-- Date range. --> |
---|
| | <xsl:call-template name="generate-content-cell"> |
---|
| | <xsl:with-param name="nodes" select="../dates" /> |
---|
| | </xsl:call-template> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:when> |
---|
| | <xsl:otherwise> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:otherwise> |
---|
| | </xsl:choose> |
---|
| | |
---|
| | <!-- |
---|
| | We have to apply each of the sub-templates manually, not so much to ensure the correct ordering, but so that we can correctly output empty cells when a lecture, laboratory or tutorial element is missing. |
---|
| | --> |
---|
| | <xsl:apply-templates select="section" /> |
---|
| | <xsl:if test="$section-column > $date-column"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | <xsl:apply-templates select="section" /> |
---|
| | |
---|
| | <!-- |
---|
| | Lecture cells span two columns, so we need to explicitly output a two-column empty cell if there's no lecture element for the current row. |
---|
| | --> |
---|
| | <xsl:apply-templates select="lecture" /> |
---|
| | <xsl:if test="$lecture-column-1 > $section-column"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | <xsl:if test="count( lecture ) = 0"> |
---|
| | <xsl:call-template name="generate-empty-cell"> |
---|
| | <xsl:with-param name="columns">2</xsl:with-param> |
---|
| | <xsl:with-param name="rows">1</xsl:with-param> |
---|
| | <xsl:with-param name="column-format">c|</xsl:with-param> |
---|
| | </xsl:call-template> |
---|
| | </xsl:if> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | |
---|
| | <xsl:apply-templates select="reading" /> |
---|
| | <xsl:apply-templates select="lecture" /> |
---|
| | |
---|
| | <xsl:if test="$reading-column > $lecture-column-2"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | <xsl:apply-templates select="reading" /> |
---|
| | |
---|
| | <!-- |
---|
| | Labs and tutorials are similar to lectures, except that they span two columns and all rows for the week, so only the the first row of the week will have a laboratory or tutorial element, empty or otherwise. If this laboratory or tutorial element has content (i.e., isn't empty), then we need to skip over these cells for the remaining rows of the week. If this element is empty (or there's no element at all) then we output a two-column empty cell for all rows. |
---|
| | |
---|
| | Note that we use "../row[1]" rather than one of the "preceding" axes, as the latter are effectively indexed in reverse. |
---|
| | --> |
---|
| | <xsl:apply-templates select="laboratory" /> |
---|
| | <xsl:if test="$laboratory-column-1 > $reading-column"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | <xsl:if test="count( laboratory ) = 0"> |
---|
| | <xsl:choose> |
---|
| | <xsl:when test="not( ../row[1]/laboratory/node() )"> |
---|
| | <xsl:call-template name="generate-empty-cell"> |
---|
| |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:otherwise> |
---|
| | </xsl:choose> |
---|
| | </xsl:if> |
---|
| | </xsl:if> |
---|
| | <xsl:apply-templates select="laboratory" /> |
---|
| | |
---|
| | <xsl:if test="$tutorial-column-1 > $laboratory-column-2"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | |
---|
| | <xsl:apply-templates select="tutorial" /> |
---|
| | <xsl:if test="$tutorial-column-1 > $laboratory-column-2"> |
---|
| | <xsl:if test="count( tutorial ) = 0"> |
---|
| | <xsl:choose> |
---|
| | <xsl:when test="not( ../row[1]/tutorial/node() )"> |
---|
| | <xsl:call-template name="generate-empty-cell"> |
---|
| |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:otherwise> |
---|
| | </xsl:choose> |
---|
| | </xsl:if> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | <xsl:apply-templates select="tutorial" /> |
---|
| | |
---|
| | <!-- |
---|
| | Assessments always span a single column and span all rows for a week, so no additional special handling is required for missing elements. |
---|
| | --> |
---|
| | <xsl:if test="$assessment-column > $tutorial-column-2"> |
---|
| | <xsl:call-template name="tabular-column-separator" /> |
---|
| | </xsl:if> |
---|
| | <xsl:apply-templates select="assessment" /> |
---|
| | |
---|
| | <!-- Note assumption that a lecture is always a single row. --> |
---|
| | <xsl:text> \\</xsl:text> |
---|
| |
---|
| | </xsl:for-each> |
---|
| | </common> |
---|
| | <common formats="/html/xhtml/"> |
---|
| | <!-- Not sure why, but this doesn't work if you just access @current directly in the if below. --> |
---|
| | <!-- |
---|
| | <xsl:variable name="current" select="@current" /> |
---|
| | --> |
---|
| | |
---|
| | <xsl:for-each select="row"> |
---|
| | <tr> |
---|
| | <!-- Output the week number and dates columns. --> |
---|
| | <xsl:if test="position() = 1"> |
---|
| | <!-- Week number, first row only. --> |
---|
| | <xsl:call-template name="generate-number-cell"> |
---|
| | <xsl:with-param name="colour" select="if ( $current = 'yes' ) then 'red' else 'white'" /> |
---|
| | <xsl:with-param name="colour" select="if ( ../@current = 'yes' ) then 'red' else 'white'" /> |
---|
| | <xsl:with-param name="number" select="1 + count( preceding::week[not( @holiday )] )" /> |
---|
| | </xsl:call-template> |
---|
| | |
---|
| | <!-- Date range, first row only. --> |
---|
| |
---|
|