• Removed some obsolete comments, and tidied others.
• Removed unused code.
1 parent b5b8edd commit a1ddd387071a44fd73c4d50cbdad4157bade1b10
Nigel Stanger authored on 12 Feb 2016
Showing 1 changed file
View
103
xml2xslt.xsl
<!--
XSLT transformation for a master XML document defining how to transform elements in the course handbook source into HTML and LaTeX. Hmm, meta-stylesheet?!
-->
<!-- <xsl:output method="text" encoding="utf-8" media-type="text/xml" /> -->
<xsl:output method="xml" encoding="utf-8" cdata-section-elements="html" />
 
<!--
What target format are we generating a styesheet for?
<!--
Define an alias for the xsl namespace to avoid confusion when generating xsl: elements in the output of this stylesheet.
-->
<xsl:namespace-alias stylesheet-prefix="xsl-out" result-prefix="xsl" />
 
<!--
Some useful variables. (Could some of these become callable templates?)
-->
<!-- Some useful variables. (Could some of these become callable templates?) -->
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>
 
<xsl:variable name="space"><xsl:text> </xsl:text></xsl:variable>
 
<!-- *** TEMPLATES *** -->
<xsl:template match="/">
<xsl-out:stylesheet version="2.0">
<xsl-out:param name="base-path"><xsl:text>.</xsl:text></xsl-out:param>
<!-- Full period string corresponding to the supplied period code. -->
<xsl-out:variable name="period-string" select="infosci:expand-period-code( $period-code )" />
<!--
<xsl-out:choose>
<xsl-out:when test="$period-code = 'SS'">
<xsl-out:text>Summer School</xsl-out:text>
</xsl-out:when>
<xsl-out:when test="$period-code = 'S1'">
<xsl-out:text>Semester One</xsl-out:text>
</xsl-out:when>
<xsl-out:when test="$period-code = 'S2'">
<xsl-out:text>Semester Two</xsl-out:text>
</xsl-out:when>
<xsl-out:when test="$period-code = 'FY'">
<xsl-out:text>Full Year</xsl-out:text>
</xsl-out:when>
<xsl-out:otherwise>
<xsl-out:message terminate="yes">
<xsl-out:text>Unrecognised period code "</xsl-out:text>
<xsl-out:value-of select="$period-code" />
<xsl-out:text>".</xsl-out:text>
</xsl-out:message>
</xsl-out:otherwise>
</xsl-out:choose>
</xsl-out:variable>
-->
<!-- The date and time when the document was last built. -->
<xsl-out:variable name="date-built" select="current-dateTime()" />
<xsl-out:variable name="document-name" select="reverse( tokenize( base-uri(), '/' ) )[1]" />
 
<!-- Include the generated Oracle documentation code. -->
<xsl-out:include href="oracle-docs.xsl" />
 
<!-- Include the generated teaching calendar dates. -->
<!--
<xsl-out:include href="calendar_dates.xsl" />
-->
 
<!--
We're going to use the text encoding in a few different places, so let's work out what it should be now.
-->
</xsl:choose>
</xsl:variable>
 
<!-- root-level documents should say what type/class of document they are (lecture, tutorial, generic, ...). Do we want to call this a class or a type? -->
<!--
<xsl:variable name="doctype"><xsl:value-of select="/document/@type" /></xsl:variable>
-->
<!--
First, output the document preamble according to target format. This is generally different for each target format.
-->
<xsl:choose>
<xsl:when test="($target-format = 'html') or ($target-format = 'xhtml')">
<!-- *** (X)HTML Output *** -->
<!-- Old version: before using xsl:namespace-alias: -->
<!--
<xsl-out:element name="xsl:output">
<xsl-out:attribute name="method">html</xsl-out:attribute>
<xsl-out:attribute name="encoding">UTF-8</xsl-out:attribute>
<xsl-out:attribute name="media-type">text/html</xsl-out:attribute>
<xsl-out:attribute name="doctype-public">-//W3C//DTD HTML 4.01 Transitional//EN</xsl-out:attribute>
</xsl-out:element>
-->
<!-- Default to PNG images for web dispay. -->
<xsl-out:param name="image-format"><xsl:text>png</xsl:text></xsl-out:param>
 
<!-- Nope, includes can only appear as a child of xsl:stylesheet. -->
<!-- <xsl-out:include href="xml2html-root.xsl" /> -->
<xsl-out:template match="/document">
<xsl-out:comment> THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! </xsl-out:comment>
<html>
<head>
<xsl-out:param name="image-format"><xsl:text>pdf</xsl:text></xsl-out:param>
<!--
Generate macro to encode the document class name.
This is currently BROKEN. If the document class specified loads packages that are then loaded by the boilerplate below with different optons, it will cause LaTeX "option clash" errors. Therefore, DO NOT use the @latex-document-class attribute for now until a solution can be devised!
This is currently BROKEN. If the specified document class loads packages that are then loaded by the boilerplate below with different optons, it will cause LaTeX "option clash" errors. Therefore, DO NOT use the @latex-document-class attribute for now until a solution can be devised!
-->
<xsl-out:template name="setup-document-class">
<xsl-out:text>
\def\DocumentClass{</xsl-out:text>
<xsl-out:text>}
</xsl-out:text>
</xsl-out:template>
 
<!-- *** LaTeX Source Output *** -->
<!-- Should this produce a LaTeX source fragment or an entire valid source document? -->
<!-- *** (Xe)LaTeX Source Output *** -->
<xsl-out:template match="/document">
<xsl-out:choose>
 
<!-- standalone = "yes" means generate an entire valid (Xe)LaTeX source document. -->
<xsl-out:when test="$standalone = 'yes'">
<xsl-out:text>
% THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
 
</xsl-out:call-template>
</xsl-out:if>
<xsl-out:text>\end{document}</xsl-out:text>
</xsl-out:when>
<!-- Not standalone: -->
<!-- standalone = "no" means generate a (Xe)LaTeX source fragment. -->
<xsl-out:otherwise>
<xsl-out:apply-templates select="title" mode="chapter" />
<xsl-out:apply-templates select="*[not(self::title)]" />
<xsl-out:if test="not( @auto-latex-build-date ) or ( @auto-latex-build-date != 'no' )">
</xsl:template>
 
<!--
This template produces a template that calls another template, i.e.
it implements a template alias.
The generated template probably doesn't need a name, but we'll put one
in anyway.
-->
 
This template produces a template that calls another template, i.e., it implements a template alias.
The generated template probably doesn't need a name, but we'll put one in anyway.
-->
<xsl:template match="alias">
<xsl-out:template>
<xsl:attribute name="name"><xsl:value-of select="@source" /></xsl:attribute>
<xsl:attribute name="match"><xsl:value-of select="@source" /></xsl:attribute>
</xsl-out:template>
</xsl:template>
 
<!--
This template produces a template for processing style-oriented markup,
such as empahsis, foreign terms, and quotations.
-->
<!--
<xsl:template match="d">
</xsl-out:template match>
-->
 
<!--
This template produces a template for processing an element that
refers to a hyperlink.
-->
<xsl:template match="hyperlink">
</xsl:template>
</xsl:stylesheet>