Newer
Older
XML / modules / paper-calendar.xml
<?xml version="1.0" encoding="utf-8"?>

<!--
	Teaching calendar elements.
-->

<stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	
	<template match="calendar">
		<common formats="/latex/xelatex/">
			<xsl:text>
\begin{center}
	\begin{sideways}
		\resizebox{24cm}{!}{%
			\begin{tabular}{|c|c|c|c|l|c|c|c|c|c|c|}
</xsl:text>
							<!-- Calendar heading. -->
							<xsl:text>\multicolumn{</xsl:text>
							<xsl:value-of select="$number-of-columns" />
							<xsl:text>}{c}{\LARGE\textbf{</xsl:text>
							<xsl:apply-templates select="paper" />
							<xsl:text> Paper Calendar, </xsl:text>
							<xsl:apply-templates select="period" />
							<xsl:text>, </xsl:text>
							<xsl:apply-templates select="year" />}}	\\
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:text>\multicolumn{</xsl:text>
							<xsl:value-of select="$number-of-columns" />
							<xsl:text>}{c}{}	\\</xsl:text>
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:text>\hline</xsl:text>
							
							<xsl:call-template name="newline-internal" />
							
							<!-- The calendar itself. -->
							<xsl:apply-templates select="header" />
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:text>\hline\hline</xsl:text>
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:apply-templates select="body" />
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:text>\hline\hline</xsl:text>
							
							<xsl:call-template name="newline-internal" />
							
							<xsl:apply-templates select="footer" />
							
							<xsl:call-template name="newline-internal" />
							
						<xsl:text>
			\end{tabular}%
		}
	\end{sideways}
\end{center}
</xsl:text>
		</common>
		<common formats="/html/xhtml/">
			<!-- Page heading. -->
			<h2>
				<xsl:apply-templates select="paper" />
				<xsl:text> Paper Calendar, </xsl:text>
				<xsl:apply-templates select="period" />
				<xsl:text>, </xsl:text>
				<xsl:apply-templates select="year" />
			</h2>
			
			<!-- The calendar itself. -->
			<div class="sans">
				<table class="small" summary="Paper calendar with relevant links" cellspacing="0">
					<!--
						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>
						<xsl:apply-templates select="header" />
					</thead>
					<tfoot>
						<xsl:apply-templates select="footer" />
					</tfoot>
					<tbody>
						<xsl:apply-templates select="body" />
					</tbody>
				</table>
			</div>
		</common>
	</template>
	
	
	<template name="SubjectCode" match="SubjectCode">
		<common>
			<xsl:value-of select="$subject-code" />
		</common>
	</template>


	<template name="PaperNumber" match="PaperNumber">
		<common>
			<xsl:value-of select="$paper-number" />
		</common>
	</template>


	<template name="PaperCode" match="PaperCode">
		<common>
			<xsl:value-of select="$subject-code" />
			<xsl:text> </xsl:text>
			<xsl:value-of select="$paper-number" />
		</common>
	</template>
	
	
	<xsl:template name="PaperYear" match="PaperYear">
		<common>
			<!--
				@offset lets us output the year +/- some integer value.
				The input value is truncated and defaults to zero if not
				supplied.
			-->
			<xsl:variable name="add">
				<xsl:value-of select="floor(@offset)" />
				<xsl:if test="not(@offset)">0</xsl:if>
			</xsl:variable>
			<xsl:value-of select="$paper-year + $add" />
		</common>
	</xsl:template>
	
	
	<xsl:template name="PaperPeriod" match="PaperPeriod">
		<common>
			<xsl:value-of select="$paper-period" />
		</common>
	</xsl:template>
	
	
	<!--
		Header/footer rows for the calendar table. To get proper table
		headings/footings, use HEADING/FOOTING. For other text, use NOTE.
	-->
	<xsl:template match="header|footer">
		<common formats="/latex/xelatex/">
			<xsl:apply-templates />
			<xsl:text>\\ \hline</xsl:text>
		</common>
		<common formats="/html/xhtml/">
			<tr>
				<xsl:apply-templates />
			</tr>
		</common>
	</xsl:template>
	
	
	<!--
		A table heading or footing, bolded, centered, etc.
	-->
	<xsl:template match="heading|footing">
		<common formats="/latex/xelatex/">
			<xsl:if test="@columns">
				<xsl:text>\multicolumn{</xsl:text>
				<xsl:value-of select="@columns" />
				<xsl:text>}{|c|}{</xsl:text>
			</xsl:if>
			<xsl:text>\textbf{</xsl:text>
			<xsl:apply-templates />
			<xsl:text>}</xsl:text>
			<xsl:if test="@columns">
				<xsl:text>}</xsl:text>
			</xsl:if>
			<xsl:if test="position() != last()">
				<xsl:text>	&amp;	</xsl:text>
			</xsl:if>
		</common>
		<common formats="/html/xhtml/">
			<th>
				<xsl:if test="@columns">
					<xsl:attribute name="colspan">
						<xsl:value-of select="@columns" />
					</xsl:attribute>
				</xsl:if>
				<xsl:apply-templates />
			</th>
		</common>
	</xsl:template>
	
	
	<!--
		A miscellaneous piece of text to be inserted somewhere in the
		calendar table.
	-->
	<xsl:template match="note">
		<common formats="/latex/xelatex/">
			<xsl:if test="@columns">
				<xsl:text>\multicolumn{</xsl:text>
				<xsl:value-of select="@columns" />
				<xsl:text>}{|l|}{</xsl:text>
			</xsl:if>
			<xsl:apply-templates />
			<xsl:if test="@columns">
				<xsl:text>}</xsl:text>
			</xsl:if>
		</common>
		<common formats="/html/xhtml/">
			<td>
				<xsl:if test="@columns">
					<xsl:attribute name="colspan">
						<xsl:value-of select="@columns" />
					</xsl:attribute>
				</xsl:if>
				<xsl:apply-templates />
			</td>
		</common>
	</xsl:template>


</stylesheet>