GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
1
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
nigel.stanger
/
XML
Browse code
- Modularised Greek characters.
- Added PHP script for generating Greek character templates.
master
1 parent
b0fefd3
commit
67e2807965011367fdc48223a4e5df6aa50ec0e9
nstanger
authored
on 29 Aug 2011
Patch
Showing
3 changed files
format-master.xml
modules/generate-greek.php
modules/greek-characters.xml
Ignore Space
Show notes
View
format-master.xml
<?xml version="1.0" encoding="utf-8"?> <!-- This will mostly be a list of element names to match, along with the corresponding HTML and LaTeX handling XSLT code. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Various "global" elements that are frequently used across all documents. Some are passed in as arguments to the stylesheet (e.g., paper number), while others are things that don't change that often, and are thus hard coded (e.g., Oracle version). --> <include href="modules/global-elements.xml" /> <!-- Output a string containing the date that the document was last built. --> <include href="modules/build-date.xml" /> <!-- Plain paragraph. @indent: Whether or not to indent this paragraph (probably only relevant in LaTeX). 'no' => don't indent. otherwise => apply standard paragraph formatting. [default] @align: How to align the paragraph. Note that these are potentially distinct from the default action, e.g., specifying align="left" will produce a flushleft environment in LaTeX, which is not the same effect as not specifying an alignment. 'left' => left alignment 'center' => centered alignment 'right' => right alignment @border: Whether or not to draw a border around the paragraph. 'yes' => draw a border. otherwise => apply standard paragraph formatting. [default] --> <template name="paragraph" match="paragraph|para|p|P"> <common formats="/latex/xelatex/"> <xsl:text> </xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>\begin{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="@align = 'center'"> <xsl:text>\begin{center}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{center}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:if test="@indent = 'no'">\noindent </xsl:if> <xsl:if test="@border = 'yes'"> <xsl:text>\fbox{</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="@border = 'yes'"> <xsl:text>}</xsl:text> </xsl:if> </xsl:otherwise> </xsl:choose> <xsl:text> </xsl:text> </common> <!-- HTML is weird about what things you cannot include inside paragraphs (e.g. lists of any kind). However, the end P tag is optional, so one option might simply be not to output it. --> <common formats="/html/xhtml/"> <!-- The HTMLStyle parameter is an Ugly Hack(tm) to ensure that paragraphs are indented correctly inside definition lists in HTML. I tried modes first, but they didn't work correctly. Fortunately this only needs to be done with paragraphs, so this will work fine. --> <xsl:param name="HTMLStyle" /> <p> <xsl:if test="@border = 'yes'"> <xsl:attribute name="style">border: 1px solid black;</xsl:attribute> </xsl:if> <xsl:if test="$HTMLStyle"> <xsl:attribute name="class"> <xsl:value-of select="$HTMLStyle" /> </xsl:attribute> </xsl:if> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <xsl:apply-templates /> </p> </common> </template> <!-- Special characters (should maybe all be named, in case they need to be called explicitly with xsl:call-template) --> <!-- I'd like to use the Unicode names for these; will look them up some time! --> <template name="newline" match="newline|line-break|br"> <common formats="/latex/xelatex/"><xsl:text> \\ </xsl:text></common> <common formats="/html/xhtml/"><br /></common> </template> <!-- Whereas newline|line-break is for line breaks intended to be output into the final document, this is for additional linebreaks in the generated latex or HTML source (for stuff like avoiding "\end{verbatim}\item" all on one line). --> <template name="newline-internal" match="newline-internal"> <common formats="/latex/xelatex/"><xsl:text> </xsl:text></common> <common formats="/html/xhtml/"><xsl:text> </xsl:text></common> </template> <template name="page-break" match="page-break|new-page|newpage|pagebreak"> <common formats="/latex/xelatex/">\newpage</common> </template> <!-- Insert a space. Useful for the occasional case where two elements occur next to each other with only a space separating them (e.g., an <emph> immediately following a <quote>), and the space gets gobbled by XSLT, producing non-separated words in the output. It doesn't seem very consistent as to when it does and doesn't happen, unfortunately, but when it does happen, inserting a <space /> will fix the problem. This is analogous to putting a \ at the end of macros in LaTeX to ensure that spaces after the macro aren't gobbled, and indeed, this is what the LaTeX version of the markup produces. --> <template name="space" match="space"> <common formats="/latex/xelatex/"><xsl:text>\ </xsl:text></common> <!-- U+0020 SPACE --> <common formats="/html/xhtml/"><xsl:text> </xsl:text></common> </template> <template name="space-strip" match="space" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="space" /> </common> </template> <template name="non-breaking-space" match="non-breaking-space|nbsp|no-break-space"> <common formats="/latex/xelatex/">~</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></common> <!-- Could use U+00A0 NO-BREAK SPACE for XHTML? --> </template> <template name="thin-space" match="thin-space|thinspace"> <common formats="/latex/xelatex/">\,</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&thinsp;</xsl:text></common> <!-- Could use U+2009 THIN SPACE for XHTML? --> </template> <!-- Insert a discretionary hyphen. Only relevant for LaTeX output. --> <template name="discretionary-hyphen" match="hyphen"> <common formats="/latex/xelatex/">\-</common> <!-- Could use U+00AD SOFT HYPHEN for XHTML? --> </template> <!-- Technically we don't need to disable output escaping for all of these, but it's probably better to code them all consistently, rather than trying to figure out which ones do need it (e.g.,   for a non-breaking space) and which ones don't (e.g., &). --> <template name="ellipsis-sign" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis"> <common formats="/latex/xelatex/">{\ldots}</common> <html><xsl:text disable-output-escaping="yes">&hellip;</xsl:text></html> <!-- U+2026 HORIZONTAL ELLIPSIS --> <xhtml><xsl:text>…</xsl:text></xhtml> </template> <template name="ellipsis-sign-strip" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="ellipsis-sign" /> </common> </template> <!-- Misc typographic symbols --> <template name="endash" match="endash|en-dash|ndash|n-dash"> <common formats="/latex/xelatex/">--</common> <html><xsl:text disable-output-escaping="yes">&ndash;</xsl:text></html> <!-- U+2013 EN DASH --> <xhtml><xsl:text>–</xsl:text></xhtml> </template> <template name="endash-strip" match="endash|en-dash|ndash|n-dash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="endash" /> </common> </template> <template name="emdash" match="emdash|em-dash|mdash|m-dash"> <common formats="/latex/xelatex/">---</common> <html><xsl:text disable-output-escaping="yes">&mdash;</xsl:text></html> <xhtml><xsl:text>—</xsl:text></xhtml> <!-- U+2014 EM DASH --> </template> <template name="emdash-strip" match="emdash|em-dash|mdash|m-dash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="emdash" /> </common> </template> <!-- Use this for literal underscores that appear outside code blocks. Such things cause LaTeX to wig out. --> <template name="underscore" match="underscore|low-line"> <common formats="/latex/xelatex/">\_</common> <!-- U+005F LOW LINE --> <common formats="/html/xhtml/">_</common> </template> <template name="underscore-strip" match="underscore|low-line" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="underscore" /> </common> </template> <template name="backslash" match="backslash"> <common formats="/latex/xelatex/">\(\backslash\)</common> <!-- U+005C REVERSE SOLIDUS --> <common formats="/html/xhtml/">\</common> </template> <template name="backslash-strip" match="backslash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="backslash" /> </common> </template> <template name="apostrophe" match="apostrophe|right-single-quotation-mark"> <common formats="/latex/xelatex/">'</common> <html><xsl:text disable-output-escaping="yes">&rsquo;</xsl:text></html> <!-- U+2019 RIGHT SINGLE QUOTATION MARK --> <xhtml><xsl:text>’</xsl:text></xhtml> </template> <template name="apostrophe-strip" match="apostrophe|right-single-quotation-mark" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="apostrophe" /> </common> </template> <template name="dollar" match="dollar|dollar-sign"> <common formats="/latex/xelatex/">{\$}</common> <!-- U+0024 DOLLAR SIGN --> <common formats="/html/xhtml/">$</common> </template> <template name="space-dollar" match="dollar|dollar-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="dollar" /> </common> </template> <template name="percent-sign" match="percent-sign|percentage-sign|percent"> <common formats="/latex/xelatex/">{\%}</common> <!-- U+0025 PERCENT SIGN --> <common formats="/html/xhtml/">%</common> </template> <template name="percent-sign-strip" match="percent-sign|percentage-sign|percent" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="percent-sign" /> </common> </template> <template name="ampersand" match="ampersand"> <common formats="/latex/xelatex/">{\&}</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&amp;</xsl:text></common> </template> <template name="ampersand-strip" match="ampersand" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="ampersand" /> </common> </template> <template name="trademark-sign" match="trademark-sign|trademark|tm|trade-mark-sign"> <common formats="/latex/xelatex/">{\texttrademark}</common> <html><xsl:text disable-output-escaping="yes">&trade;</xsl:text></html> <!-- U+2122 TRADE MARK SIGN --> <xhtml><xsl:text>™</xsl:text></xhtml> </template> <template name="trademark-sign-strip" match="trademark-sign|trademark|tm|trade-mark-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="trademark-sign" /> </common> </template> <template name="copyright-sign" match="copyright-sign"> <common formats="/latex/xelatex/">{\copyright}</common> <html><xsl:text disable-output-escaping="yes">&copy;</xsl:text></html> <!-- U+00A9 COPYRIGHT SIGN --> <xhtml><xsl:text>©</xsl:text></xhtml> </template> <template name="copyright-sign-strip" match="copyright-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="copyright-sign" /> </common> </template> <template name="degree-sign" match="degree-sign|degrees"> <common formats="/latex/xelatex/">\ensuremath{^{\circ}}</common> <html><xsl:text disable-output-escaping="yes">&deg;</xsl:text></html> <!-- U+0080 DEGREE SIGN --> <xhtml><xsl:text>°</xsl:text></xhtml> </template> <template name="degree-sign-strip" match="degree-sign|degrees" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="degree-sign" /> </common> </template> <template name="section-sign" match="section-sign"> <common formats="/latex/xelatex/">{\S}</common> <html><xsl:text disable-output-escaping="yes">&sect;</xsl:text></html> <!-- U+00A7 SECTION SIGN --> <xhtml><xsl:text>§</xsl:text></xhtml> </template> <template name="section-sign-strip" match="section-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="section-sign" /> </common> </template> <template name="sharp-sign" match="sharp|hash|number-sign"> <common formats="/latex/xelatex/">{\#}</common> <!-- U+0023 NUMBER SIGN --> <common formats="/html/xhtml/"><xsl:text>#</xsl:text></common> </template> <template name="sharp-sign-strip" match="sharp|hash|number-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="sharp-sign" /> </common> </template> <template name="paragraph-sign" match="paragraph-sign|pilcrow|pilcrow-sign"> <common formats="/latex/xelatex/">{\P}</common> <html><xsl:text disable-output-escaping="yes">&para;</xsl:text></html> <!-- U+00B6 PILCROW SIGN --> <xhtml><xsl:text>¶</xsl:text></xhtml> </template> <template name="paragraph-sign-strip" match="paragraph-sign|pilcrow|pilcrow-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="paragraph-sign" /> </common> </template> <template name="left-curly-bracket" match="left-curly-bracket|left-curly-brace|left-brace"> <common formats="/latex/xelatex/">\ensuremath{\{}</common> <!-- U+007B LEFT CURLY BRACKET --> <common formats="/html/xhtml/"><xsl:text>{</xsl:text></common> </template> <template name="left-curly-bracket-strip" match="left-curly-bracket|left-curly-brace|left-brace" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="left-curly-bracket" /> </common> </template> <template name="right-curly-bracket" match="right-curly-bracket|right-curly-brace|right-brace"> <common formats="/latex/xelatex/">\ensuremath{\}}</common> <!-- U+007D LEFT CURLY BRACKET --> <common formats="/html/xhtml/"><xsl:text>}</xsl:text></common> </template> <template name="right-curly-bracket-strip" match="right-curly-bracket|right-curly-brace|right-brace" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="right-curly-bracket" /> </common> </template> <!-- Greek characters. --> <include href="modules/greek-characters.xml" /> <template name="empty-set-sign" match="empty-set-sign|empty-set|null"> <common formats="/latex/xelatex/">\ensuremath{\emptyset}</common> <html><xsl:text disable-output-escaping="yes">&empty;</xsl:text></html> <!-- U+2205 EMPTY SET --> <xhtml><span class="unicode"><xsl:text>∅</xsl:text></span></xhtml> </template> <template name="empty-set-sign-strip" match="empty-set-sign|empty-set|null" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="empty-set-sign" /> </common> </template> <template name="element-sign" match="element-sign|element|element-of|is-element-of|is-an-element-of"> <common formats="/latex/xelatex/">\ensuremath{\in}</common> <html><xsl:text disable-output-escaping="yes">&isin;</xsl:text></html> <!-- U+2208 ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∈</xsl:text></span></xhtml> </template> <template name="element-sign-strip" match="element-sign|element|element-of|is-element-of|is-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="element-sign" /> </common> </template> <template name="not-element-sign" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of"> <common formats="/latex/xelatex/">\ensuremath{\not\in}</common> <html><xsl:text disable-output-escaping="yes">&notin;</xsl:text></html> <!-- U+2209 NOT AN ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∉</xsl:text></span></xhtml> </template> <template name="not-element-sign-strip" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="not-element-sign" /> </common> </template> <template name="subset-sign" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of"> <common formats="/latex/xelatex/">\ensuremath{\subset}</common> <html><xsl:text disable-output-escaping="yes">&sub;</xsl:text></html> <!-- U+2282 SUBSET OF --> <xhtml><span class="unicode"><xsl:text>⊂</xsl:text></span></xhtml> </template> <template name="subset-strip" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="subset-sign" /> </common> </template> <template name="superset-sign" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of"> <common formats="/latex/xelatex/">\ensuremath{\supset}</common> <html><xsl:text disable-output-escaping="yes">&sup;</xsl:text></html> <!-- U+2283 SUPERSET OF --> <xhtml><span class="unicode"><xsl:text>⊃</xsl:text></span></xhtml> </template> <template name="superset-strip" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="superset-sign" /> </common> </template> <!-- Relational algebra operators. These are distinct from the basic Greek characters, because they can have associated subscripts (i.e., they have arguments). These also use relalg.sty in (Xe)LaTeX for general consistency. --> <template name="project" match="project"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelProject</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&pi;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>π</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="extend" match="extend"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelExtend</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&epsilon;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03B5 GREEK SMALL LETTER EPSILON --> <xhtml> <span class="unicode"><xsl:text>ε</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="rename" match="rename"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelRename</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&rho;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>ρ</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="restrict" match="restrict"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelRestrict</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&sigma;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>σ</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="join-operator" match="join-operator|join|natural-join|inner-join|bowtie"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelNaturalJoin</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <!-- No easy way at present to get the join symbol in HTML, so just use an image. Scale it to 10x10 pixels (fine as long as font size is set relatively normally). We need to ensure that the path is absolute, because we don't necessarily know where the document will end up in the tree. Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:text> </xsl:text> <img> <xsl:attribute name="src"> <xsl:text>/</xsl:text> <xsl:value-of select="$subject-code" /> <xsl:value-of select="$paper-number" /> <xsl:text>/Handbook/join-operator-web.png</xsl:text> </xsl:attribute> <xsl:attribute name="alt"> <xsl:text>join operator</xsl:text> </xsl:attribute> <xsl:attribute name="width"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="height"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="style"> <xsl:text>padding-left:0.3em;padding-right:0.3em</xsl:text> </xsl:attribute> </img> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </html> <!-- Note that we use the Unicode BOWTIE character (U+22C8) rather than JOIN (U+2A1D) because the latter appears to have less font support than the former, and isn't different enough to have any significant effect. --> <!-- U+22C8 BOWTIE --> <xhtml> <xsl:text> </xsl:text> <span class="unicode"><xsl:text>⋈</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </xhtml> </template> <!-- Generate a left, right or full outer join operator. @type: the type of outer join operator [optional] 'left' 'right' 'full' [default] --> <template name="outer-join-operator" match="outer-join-operator|outer-join"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\Rel</xsl:text> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>Full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>OuterJoin</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <!-- No easy way at present to get the join symbol in HTML, so just use an image. Scale it to 10x10 pixels (fine as long as font size is set relatively normally). We need to ensure that the path is absolute, because we don't necessarily know where the document will end up in the tree. Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"> <xsl:text> </xsl:text> <img> <xsl:attribute name="src"> <xsl:text>/</xsl:text> <xsl:value-of select="$subject-code" /> <xsl:value-of select="$paper-number" /> <xsl:text>/Handbook/</xsl:text> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>-outer-join-operator-web.png</xsl:text> </xsl:attribute> <xsl:attribute name="alt"> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text> outer join operator</xsl:text> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="(@type = 'left') or (@type = 'right')"> <xsl:text>15</xsl:text> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>20</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="style"> <xsl:text>padding-left:0.3em;padding-right:0.3em</xsl:text> </xsl:attribute> </img> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </common> <!-- Note that these characters are available in Unicode (U+27D5 LEFT OUTER JOIN, U+27D6 RIGHT OUTER JOIN and U+27D7 FULL OUTER JOIN), but I don't think font support is very widespread yet (Dec 2010). --> <!-- <xhtml> <xsl:text> </xsl:text> <xsl:choose> <xsl:when test="@type = 'left'"> <span class="unicode"><xsl:text>⟕</xsl:text></span> </xsl:when> <xsl:when test="@type = 'right'"> <span class="unicode"><xsl:text>⟖</xsl:text></span> </xsl:when> <xsl:otherwise> <span class="unicode"><xsl:text>⟗</xsl:text></span> </xsl:otherwise> </xsl:choose> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </xhtml> --> </template> <template name="intersect-operator" match="intersect-operator|intersect|intersection|cap"> <common formats="/latex/xelatex/">\ensuremath{\cap}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &cap; </xsl:text></html> <!-- U+2229 INTERSECTION --> <xhtml><span class="unicode"><xsl:text> ∩ </xsl:text></span></xhtml> </template> <template name="intersect-operator-strip" match="intersect-operator|intersect|intersection|cap" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="intersect-operator" /> </common> </template> <template name="union-operator" match="union-operator|union|cup"> <common formats="/latex/xelatex/">\ensuremath{\cup}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &cup; </xsl:text></html> <!-- U+222A UNION --> <xhtml><span class="unicode"><xsl:text> ∪ </xsl:text></span></xhtml> </template> <template name="union-operator-strip" match="union-operator|union|cup" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="union-operator" /> </common> </template> <template name="logical-and-operator" match="logical-and-operator|logical-and|and|and-operator|hat|wedge"> <common formats="/latex/xelatex/">\ensuremath{\wedge}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &and; </xsl:text></html> <!-- U+2227 LOGICAL AND --> <xhtml><span class="unicode"><xsl:text> ∧ </xsl:text></span></xhtml> </template> <template name="logical-and-operator-strip" match="logical-and-operator|logical-and|and|and-operator|hat|wedge" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-and-operator" /> </common> </template> <template name="logical-or-operator" match="logical-or-operator|logical-or|or|or-operator|vee"> <common formats="/latex/xelatex/">\ensuremath{\vee}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &or; </xsl:text></html> <!-- U+2228 LOGICAL OR --> <xhtml><span class="unicode"><xsl:text> ∨ </xsl:text></span></xhtml> </template> <template name="logical-or-operator-strip" match="logical-or-operator|logical-or|or|or-operator|vee" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-or-operator" /> </common> </template> <template name="logical-not-operator" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign"> <common formats="/latex/xelatex/">\ensuremath{\neg}</common> <html><xsl:text disable-output-escaping="yes">&not;</xsl:text></html> <!-- U+00AC NOT SIGN --> <xhtml><span class="unicode"><xsl:text>¬</xsl:text></span></xhtml> </template> <template name="logical-not-operator-strip" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-not-operator" /> </common> </template> <template name="LaTeX" match="LaTeX|latex"> <common formats="/latex/xelatex/">{\LaTeX}</common> <common formats="/html/xhtml/">L<sup>A</sup>T<sub>E</sub>X</common> </template> <template name="LaTeX-strip" match="LaTeX|latex" mode="strip"> <common formats="/html/xhtml/">LaTeX</common> </template> <!-- Note: no equivalent of \triangleright in HTML, use right arrow instead. --> <template name="menu-separator" match="menu-separator|menusep|menu/separator"> <common formats="/latex/xelatex/"> \ensuremath{\triangleright} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &rarr; </xsl:text></html> <!-- U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE --> <xhtml><span class="unicode"><xsl:text> ▹ </xsl:text></span></xhtml> </template> <template name="menu-separator-strip" match="menu-separator|menusep|menu/separator" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="menu-separator" /> </common> </template> <template name="menu-item" match="menu/item"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><b><xsl:apply-templates /></b></common> </template> <!-- Emoticons, specifically :), :| and :(. We may be able to do more with the HTML version if we switch to Unicode? The LaTeX version requires the pifont package, which has been added to the list of standard packages in xml2xslt.xsl. It also requires Microsoft's Wingdings font (jwi) to be available. @type: the type of emoticon [optional] 'sad' 'neutral' or 'meh' :) 'happy' [default] --> <template name="emoticon" match="emoticon|smiley"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="@type = 'sad'"> <xsl:text>\Pisymbol{jwi}{"4C}</xsl:text> </xsl:when> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>\Pisymbol{jwi}{"4B}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>\Pisymbol{jwi}{"4A}</xsl:text> </xsl:otherwise> </xsl:choose> </common> <html> <xsl:choose> <xsl:when test="@type = 'sad'"> <xsl:text>:(</xsl:text> </xsl:when> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>:|</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>:)</xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@type = 'sad'"> <!-- U+2639 WHILE FROWNING FACE --> <span class="unicode"><xsl:text>☹</xsl:text></span> </xsl:when> <!-- There doesn't appear to be a Unicode character for this one. :( --> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>:|</xsl:text> </xsl:when> <xsl:otherwise> <!-- U+263A WHILE SMILING FACE --> <span class="unicode"><xsl:text>☺</xsl:text></span> </xsl:otherwise> </xsl:choose> </xhtml> </template> <template name="emoticon-strip" match="emoticon|smiley" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="emoticon" /> </common> </template> <!-- Special styles --> <template name="emph" match="emph|em"> <common formats="/latex/xelatex/">\emph{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><em><xsl:apply-templates /></em></common> </template> <!-- Emphasis inside answers needs to be handled specially in HTML, as it doesn't just flip-flop automatically like it does in LaTeX. --> <template name="emph-in-answer" match="answer//emph|answer//em"> <common formats="/latex/xelatex/">\emph{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <template name="italic" match="italic"> <common formats="/latex/xelatex/">\textit{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i><xsl:apply-templates /></i></common> </template> <template name="strong" match="strong"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <template name="bold" match="bold"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><b><xsl:apply-templates /></b></common> </template> <template name="underline" match="underline|u"> <common formats="/latex/xelatex/">\underline{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><span style="text-decoration: underline;"><xsl:apply-templates /></span></common> </template> <template name="term" match="term"> <common formats="/latex/xelatex/">\term{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i class="term"><xsl:apply-templates /></i></common> </template> <template name="foreign" match="foreign"> <common formats="/latex/xelatex/">\foreign{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i class="foreign"><xsl:apply-templates /></i></common> </template> <template name="code" match="code"> <!-- <latex>\code{<xsl:apply-templates />}</latex> --> <!-- Using \verb is quite handy because things like underscores don't bother it. However, it seems it can't be used inside hyperlinks. Maybe create another template that just does a \texttt on the contents? --> <!-- OK, but then we need an <underscore> element to stop them from freaking LaTeX out. --> <common formats="/latex/xelatex/">\verb`<xsl:apply-templates />`</common> <common formats="/html/xhtml/"><code><xsl:apply-templates /></code></common> </template> <template name="typewriter" match="typewriter|monospace|tt"> <common formats="/latex/xelatex/">\texttt{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><tt><xsl:apply-templates /></tt></common> </template> <template name="sans-serif" match="sans-serif|sans|ss|sf"> <common formats="/latex/xelatex/">\textsf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><font face="sans-serif"><xsl:apply-templates /></font></common> </template> <!-- Non-maths super- and subscript. --> <template name="superscript" match="superscript"> <common formats="/latex/xelatex/">\ensuremath{^{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common> </template> <template name="subscript" match="subscript"> <common formats="/latex/xelatex/">\ensuremath{_{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common> </template> <!-- Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines. --> <template name="tiny" match="tiny"> <common formats="/latex/xelatex/">{\tiny <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="scriptsize" match="scriptsize"> <common formats="/latex/xelatex/">{\scriptsize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="footnotesize" match="footnotesize"> <common formats="/latex/xelatex/">{\footnotesize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="small" match="small"> <common formats="/latex/xelatex/">{\small <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </common> </template> <template name="large" match="large"> <common formats="/latex/xelatex/">{\large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </common> </template> <!-- Fortunately, XML is case-sensitive. --> <template name="Large" match="Large"> <common formats="/latex/xelatex/">{\Large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="LARGE" match="LARGE"> <common formats="/latex/xelatex/">{\LARGE <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="huge" match="huge"> <common formats="/latex/xelatex/">{\huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="Huge" match="Huge"> <common formats="/latex/xelatex/">{\Huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </span> </common> </template> <!-- Text that shouldn't be broken across a line (i.e., LaTeX \mbox). Only really relevant for LaTeX because we can't control this in HTML. --> <template name="no-break" match="no-break|mbox"> <common formats="/latex/xelatex/">\mbox{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Skip a certain amount of space vertically. Probably more relevant to LaTeX than HTML. Is it even possible to vskip a set amount in HTML?? @size: the amount of space to skip. missing => \vskip\baselineskip [default] 'small' => \smallskip 'medium' => \medskip 'large' => \bigskip 'fill' => \vfill LaTeX length => \vskipxx --> <template name="vertical-skip" match="vertical-skip|vskip"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="not(@size)"> \vskip\baselineskip </xsl:when> <xsl:when test="@size='small'"> \smallskip </xsl:when> <xsl:when test="@size='medium'"> \medskip </xsl:when> <xsl:when test="@size='large'"> \bigskip </xsl:when> <xsl:when test="@size='fill'"> \vfill </xsl:when> <xsl:otherwise> \vskip<xsl:value-of select="@size" /> </xsl:otherwise> </xsl:choose> </common> <!-- For the moment we'll just throw in a BR :) --> <common formats="/html/xhtml/"><br clear="left" /></common> </template> <!-- We can decide later whether to use plain verbatim or listings. --> <template name="code-block" match="code-block"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <!-- If the code-block specifies "allow-breaks='no'", wrap the verbatim inside a minipage to avoid page breaks within the code. --> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{minipage}{\textwidth}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\end{minipage}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre class="code"><xsl:apply-templates /></pre> </common> </template> <!-- This is for stuff that should unequivocally be treated verbatim (e.g. problem code). I'm pretty sure that previously this was distinguished from "code-block" because it (code-block) used to use listings instead of verbatim. Now that they're both using verbatim there is probably no need for them both (but we might switch back to using listings for code-block). --> <template name="verbatim" match="verbatim"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre><xsl:apply-templates /></pre> </common> </template> <!-- Quoted text. Handles nested quotes correctly. @single: Whether to enclose the text in single or double quotes. 'yes' => single quotes (''). otherwise => double quotes (""). [default] --> <template name="single-quote" match="quote[@single='yes']|q[@single='yes']"> <common formats="/latex/xelatex/">`<xsl:apply-templates />'</common> <html> <xsl:text disable-output-escaping="yes">&lsquo;</xsl:text> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes">&rsquo;</xsl:text> </html> <xhtml> <!-- U+2018 LEFT SINGLE QUOTATION MARK --> <xsl:text>‘</xsl:text> <xsl:apply-templates /> <!-- U+2019 RIGHT SINGLE QUOTATION MARK --> <xsl:text>’</xsl:text> </xhtml> </template> <template name="double-quote" match="quote|qq"> <common formats="/latex/xelatex/">``<xsl:apply-templates />''</common> <html> <xsl:text disable-output-escaping="yes">&ldquo;</xsl:text> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes">&rdquo;</xsl:text> </html> <xhtml> <!-- U+201C LEFT DOUBLE QUOTATION MARK --> <xsl:text>“</xsl:text> <xsl:apply-templates /> <!-- U+201D RIGHT DOUBLE QUOTATION MARK --> <xsl:text>”</xsl:text> </xhtml> </template> <!-- With nested quotes, we need to figure out what depth of nesting we're at, then call the appropriate template depending on the initial quoting style (single or double). --> <template name="nested-double-quote" match="quote//quote"> <common> <xsl:choose> <xsl:when test="(count(ancestor::quote) mod 2) = 0"> <xsl:call-template name="double-quote" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="single-quote" /> </xsl:otherwise> </xsl:choose> </common> </template> <template name="nested-single-quote" match="quote[@single='yes']//quote" priority="2"> <common> <xsl:choose> <xsl:when test="(count(ancestor::quote) mod 2) = 0"> <xsl:call-template name="single-quote" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="double-quote" /> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Note the lack of orthgonality that means that elements other than <item> are ignored. --> <!-- TODO: Use just xsl:apply-templates and instead of using modes, check inside the item template what the parent is? --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list|itemize|unordered-list|bulleted-list|bullet-list|bullet-points|UL|ul"> <common formats="/latex/xelatex/"> \begin{itemize} <xsl:apply-templates select="item" mode="normal" /> \end{itemize} </common> <common formats="/html/xhtml/"> <ul> <xsl:apply-templates select="item" mode="normal" /> </ul> </common> </template> <!-- Ordered lists. @start: The starting number for the list. [default 1] --> <template name="enumerated-list" match="enumerated-list|enumerate|ordered-list|numbered-list|question-list|OL|ol"> <common formats="/latex/xelatex/"> \begin{enumerate} <xsl:if test='@start'> <!-- Set the appropriate enum counter according to the depth. Use the format attribute of xsl:number to output it in Roman numerals. Depth must be at least 1 (enumi) and at most 4 (enumiv). Bizarrely, a count(ancestor::xxx) here gives 0 for the outermost element, whereas for section elements it gives 1?!?! --> <xsl:text>\setcounter{enum</xsl:text> <xsl:number value="min( ( 1 + count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> <xsl:text>}{</xsl:text> <!-- Remember that LaTeX adds 1 to the counter before using it. --> <xsl:value-of select="@start - 1" /> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates select="item" mode="enumerated-list" /> \end{enumerate} </common> <common formats="/html/xhtml/"> <ol> <xsl:if test="@start"> <!-- Note that we're using the START attribute of OL, which is actually deprecated in HTML 4 and XHTML. However, the alternative (using CSS styling) is useless, as it doesn't permit different number formatting for different levels of list (e.g., 1., a., ii., etc.). The only standards-compliant solution to this is to forgo HTML list elements completely and do it all ourselves. Ugh, no thanks! --> <xsl:attribute name="start"> <xsl:value-of select="@start" /> </xsl:attribute> </xsl:if> <xsl:apply-templates select="item" mode="enumerated-list" /> </ol> </common> </template> <!-- Definition or description lists. --> <template name="definition-list" match="definition-list|description-list|DL|dl"> <common formats="/latex/xelatex/"> \begin{description} <xsl:apply-templates select="item" mode="definition-list" /> \end{description} </common> <common formats="/html/xhtml/"> <!-- <dl>s in HTML tend to come out with the spacing a bit wrong (or maybe it's just my browser?). Anyway, they don't appear to be displayed correctly. A more portable solution is to use plain <p>s with CSS margins to control the hanging indent. The tricky part is dealing with embedded <paragraph>s inside the <description-list>. The clever details are handled in the "definition-item" template. --> <xsl:apply-templates select="item" mode="definition-list" /> </common> </template> <!-- List elements --> <template name="list-item" match="item" mode="normal"> <common formats="/latex/xelatex/"><xsl:text>\item </xsl:text><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <li><xsl:apply-templates /></li> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the item content so that the item spacing looks OK. --> <xsl:otherwise> <li><p><xsl:apply-templates /></p></li> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Provide the ability to set the numbering of specific items in enumerated lists. Results could be unpredictable if this is applied to an itemised list! @value: the number to use for the next list item. [default 1] --> <template name="enumerated-item-value" match="item[@value]" mode="enumerated-list"> <common formats="/latex/xelatex/"> <!-- Set the appropriate enum counter. --> <xsl:text>\setcounter{enum</xsl:text> <xsl:number value="min( ( count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> <xsl:text>}{</xsl:text> <!-- Remember that LaTeX adds 1 to the counter before using it. --> <xsl:value-of select="@value - 1" /> <xsl:text>}</xsl:text> <xsl:apply-templates select="." mode="normal" /> </common> <!-- Unfortunately this can't just be a wrapper around the "normal" item template because of the nesting of attributes inside the element. --> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <li> <xsl:attribute name="value" select="@value" /> <xsl:apply-templates /> </li> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the item content so that the item spacing looks OK. --> <xsl:otherwise> <li> <xsl:attribute name="value" select="@value" /> <p><xsl:apply-templates /></p> </li> </xsl:otherwise> </xsl:choose> </common> </template> <template name="enumerated-item" match="item[not( @value )]" mode="enumerated-list"> <common> <xsl:apply-templates select="." mode="normal" /> </common> </template> <template name="definition-item" match="item" mode="definition-list"> <common formats="/latex/xelatex/"> <xsl:text>\item[</xsl:text> <xsl:apply-templates select="keyword|term|topic|DT|dt" /> <xsl:text>] </xsl:text> <xsl:apply-templates select="definition|description|discourse|DD|dd" /> </common> <common formats="/html/xhtml/"> <!-- We have to be a little clever here, because we're transforming potentially multiple embedded elements (embedded <paragraph>s in particular) into one or more <p> tags in the HTML. We need to ensure that: (a) we don't end up with nested <p> tags, (b) all paragraphs are correctly indented, and (c) if the first thing following the <definition> is a <paragraph> or text node, it gets positioned correctly relative to the <keyword>. We know that the <keyword> won't have embedded <paragraph>s (it doesn't really make sense, not that we actually check :) The only thing we therefore need to check for is <paragraph> elements inside the <definition> element. --> <xsl:choose> <!-- If the first sub-node of the <definition> is NOT a <p> node, then the whole thing should be just simple text and contain only basic formatting elements, if anything (i.e., no lists!). We therefore just wrap the <keyword> and <definition> within a <p> with a hanging indent and finish. Note the use of child::node[1|2], because we don't necessarily know what variants of <keyword> and <definition> have actually been used, but we know that they will (should!) always be the first and second children of the <item> respectively. This probably is the most common case, so test for it first. --> <xsl:when test="not(child::node()[2]/child::node()[1][self::p] or child::node()[2]/child::node()[1][self::paragraph])"> <p class="definition1"> <xsl:apply-templates select="child::node()[1]" /> <xsl:text> </xsl:text> <xsl:apply-templates select="child::node()[2]" /> </p> </xsl:when> <!-- If the first sub-node of the <definition> IS a <p> or <paragraph>, then we need to skip over the processing of this element to avoid nested <p>s in the output. Any remaining sub-nodes are processed normally, except that we pass in the HTMLStyle parameter to ensure that any remaining paragraph elements are correctly indented. I would have used modes for this, but it killed embedded <itemize>s, because there isn't an <itemize> template with the appropriate mode (nor is there a need for one). Grr. --> <xsl:otherwise> <p class="definition1"> <xsl:apply-templates select="child::node()[1]" /> <xsl:text> </xsl:text> <xsl:apply-templates select="child::node()[2]/child::node()[1]/node()" /> </p> <xsl:apply-templates select="child::node()[2]/*[position() > 1]"> <xsl:with-param name="HTMLStyle">definition2</xsl:with-param> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Need to provide some context here as, e.g., <term> is also a standalone element. --> <template name="keyword" match="item/keyword|item/term|item/topic|item/DT|item/dt"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <!-- Need to provide some context here as, e.g., <description> is also used within <image>. --> <template name="definition" match="item/definition|item/description|item/discourse|item/DD|item/dd"> <common><xsl:apply-templates /></common> </template> <!-- Question text. This only exists so that we can ensure that appropriate <p> tags are correctly inserted. If this template didn't exist, showing the answers would generate invalid HTML. The answers are enclosed in a <div class="answer">...</div>. Without this template, the answer markup ends up embedded inside <p>...</p>, which is invalid. --> <template name="question" match="question"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs inside the question. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <xsl:apply-templates /> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the question content. --> <xsl:otherwise> <p><xsl:apply-templates /></p> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Sample answers, which may optionally be excluded from the output. This can be done globally for all answers by setting the style sheet parameter $showanswers to "no", or it can be done locally on a question-by-question basis by setting the @hide attribute of the element to "yes". @hide: If "yes", don't include this answer in the output stream. The default is to include the answer. --> <template name="answer" match="answer"> <common formats="/latex/xelatex/"> <!-- It's nice to weed out the sample answer markup at the XSLT processing stage to make LaTeX run faster. Note that \showanswers still needs to be called so that LaTeX can format chapter headings like "Answers for ..." --> <xsl:if test="$showanswers='yes'"> \begin{answer} <xsl:apply-templates /> \end{answer} </xsl:if> </common> <common formats="/html/xhtml/"> <xsl:if test="$showanswers='yes'"> <div class="answer"> <xsl:apply-templates /> </div> </xsl:if> </common> </template> <!-- Match hidden answers and do nothing. --> <template name="hidden-answer" match="answer[@hide='yes']" /> <!-- Sections, subsections, subsubsections, ... @label: A label that can be used for cross referencing. Any value can be used, as long as it's a legal identifier in both LaTeX and HTML. @number: Whether or not to generate a section number. It makes the most logical sense for this attribute to be associated with the section element, but the section numbers are actually generated in the "section-title" template (see below). Consequently, this attribute isn't even mentioned in this template. 'yes' [default] 'no' --> <template name="section" match="section"> <common formats="/latex/xelatex/"> <xsl:apply-templates> <xsl:with-param name="label"> <xsl:value-of select="@label" /> <xsl:if test="not(@label)">THERE_IS_NO_LABEL</xsl:if> </xsl:with-param> </xsl:apply-templates> </common> <common formats="/html/xhtml/"> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates /> </common> </template> <!-- Footnotes. --> <template name="footnote" match="footnote"> <common formats="/latex/xelatex/">\footnote{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <a> <xsl:attribute name="name"> <xsl:text>footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-source</xsl:text> </xsl:attribute> <xsl:attribute name="href"> <xsl:text>#footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-target</xsl:text> </xsl:attribute> <xsl:text>[</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>]</xsl:text> </a> </common> </template> <!-- This is only required for HTML, as LaTeX does it all for you. --> <template name="footnote-list" match="footnote" mode="list"> <common formats="/html/xhtml/"> <p> <a> <xsl:attribute name="name"> <xsl:text>footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-target</xsl:text> </xsl:attribute> <sup> <xsl:text>[</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>]</xsl:text> </sup> </a> <xsl:text> </xsl:text> <xsl:apply-templates /> <xsl:text> </xsl:text> <!-- Provide a back link to the original footnote marker. --> <a> <xsl:attribute name="href"> <xsl:text>#footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-source</xsl:text> </xsl:attribute> <xsl:text>[Back]</xsl:text> </a> </p> </common> </template> <!-- Document preamble stuff: title, author, date. --> <template name="preamble-title" match="document/title" mode="preamble"> <common formats="/latex/xelatex/"> <xsl:text>\title{</xsl:text> <xsl:if test="/document/@class = 'assignment'"> <xsl:if test="$showanswers='yes'">Sample Solution for </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:text> Assignment </xsl:text> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: \\</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <!-- For HTML, strip out any raw HTML formatting (e.g., emphasis), as this is not interpreted within the <title> tag, resulting in raw HTML markup in the window title. Ick. We do this by switching to "strip" mode. --> <common formats="/html/xhtml/"> <xsl:if test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' ) or ( /document/@class = 'assignment' )"> <xsl:if test="$showanswers='yes'"> <xsl:choose> <xsl:when test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' )"> <xsl:text>Selected Answers for </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text>Sample Solution for </xsl:text> </xsl:when> </xsl:choose> </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text> Tutorial </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text> Lab </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text> Assignment </xsl:text> </xsl:when> </xsl:choose> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: </xsl:text> </xsl:if> <xsl:apply-templates mode="strip" /> </common> </template> <template name="preamble-author" match="document/author" mode="preamble"> <common formats="/latex/xelatex/">\author{<xsl:apply-templates />}</common> </template> <template name="preamble-date" match="document/date" mode="preamble"> <common formats="/latex/xelatex/">\date{<xsl:apply-templates />}</common> </template> <template name="document-title" match="document/title"> <!-- Need to do something sensible for LaTeX here. --> <common formats="/latex/xelatex/"> <!-- Under the LaTeX framework, the rest of the chapter title text is generated by LaTeX macros, so this is pretty simple. I think this is broken? In fact, I think that for LaTeX documents, this template isn't called at all?? Looking at xml2xslt.xsl, if the document's standalone, "preamble-title" is used, and otherwise, "chapter-title" is used. --> <xsl:if test="/document/@standalone = 'yes'"><xsl:apply-templates /></xsl:if> </common> <common formats="/html/xhtml/"> <h1> <xsl:if test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' ) or ( /document/@class = 'assignment' )"> <xsl:if test="$showanswers='yes'"> <xsl:choose> <xsl:when test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' )"> <xsl:text>Selected Answers for </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text>Sample Solution for </xsl:text> </xsl:when> </xsl:choose> </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text> Tutorial </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text> Lab </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text> Assignment </xsl:text> </xsl:when> </xsl:choose> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: </xsl:text> </xsl:if> <xsl:apply-templates /> </h1> </common> </template> <!-- New template for tutorials and labs, which are essentially chapters when included in a course book, but are marked up as documents in themselves. --> <template name="chapter-title" match="document/title" mode="chapter"> <!-- TODO: For LaTeX, filling in the "INFO XXX Tutorial", etc., is currently done in the LaTeX layer in the infrastructure surrounding the \lab and \tutorial macros (i.e., it's magic). This derives from the historical origins of the handbook, and should be moved here for consistency. An initial attempt to just replace calls to \tutorial, etc., with \chapter didn't work properly, as these macros do other things as well, including internal munging of chapter handling. This Will Be Complicated :(. --> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text>\tutorial{</xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text>\lab{</xsl:text> </xsl:when> <xsl:otherwise> <!-- maybe we should assume that we're in a book documentclass and issue a \chapter here? --> <xsl:text>\general{</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <h1><xsl:call-template name="PaperCode" /> Tutorial <xsl:value-of select="/document/@sequence-number" /><xsl:if test="$showanswers='yes'"> Sample Answers</xsl:if>: <br /><xsl:apply-templates /></h1> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <h1><xsl:call-template name="PaperCode" /> Lab <xsl:value-of select="/document/@sequence-number" /><xsl:if test="$showanswers='yes'"> Sample Answers</xsl:if>: <br /><xsl:apply-templates /></h1> </xsl:when> <xsl:otherwise> <h1><xsl:apply-templates /></h1> </xsl:otherwise> </xsl:choose> </common> </template> <template name="document-author" match="document/author"> <common formats="/html/xhtml/"><p><xsl:apply-templates /></p></common> </template> <template name="document-date" match="document/date" /> <!-- Generate some number of "sub"s so we can produce, e.g., "subsubsection" for LaTeX. $depth: the number of repetitions (0 to 2, which maps to 1 to 3 below due to counting ancestor section elements coming out one more than expected). --> <template name="generate-subs"> <common formats="/latex/xelatex/"> <xsl:param name="depth">1</xsl:param> <xsl:if test="$depth > 1"> <xsl:if test="$depth < 4"> <xsl:text>sub</xsl:text> </xsl:if> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth" select="$depth - 1" /> </xsl:call-template> </xsl:if> </common> </template> <!-- Generate section title with nested numbering, e.g., 1.1.3. --> <template name="section-title" match="section/title"> <common formats="/latex/xelatex/"> <xsl:param name="label" /> <xsl:text>\</xsl:text> <!-- Generate the correct number of "sub"s for LaTeX. --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth" select="count( ancestor::section )" /> </xsl:call-template> <xsl:text>section</xsl:text> <!-- Unnumbered section. We reference the @number attribute of the parent section element. (We are guaranteed that the parent is a section element by the match context for this template.) --> <xsl:if test="../@number = 'no'"> <xsl:text>*</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:apply-templates /><xsl:text>}</xsl:text> <xsl:if test="$label != 'THERE_IS_NO_LABEL'"> \label{<xsl:value-of select="$label" />} </xsl:if> </common> <common formats="/html/xhtml/"> <!-- The depth is used in a couple of places, so we pre-calculate it. --> <xsl:variable name="depth"> <xsl:number value="1 + count(ancestor::section)" /> <xsl:if test="1 + count(ancestor::section) > 6">6</xsl:if> </xsl:variable> <xsl:text disable-output-escaping="yes"><h</xsl:text><xsl:number value="$depth" /><xsl:text disable-output-escaping="yes">></xsl:text> <!-- Unnumbered section, as per above. Note that the sense of the test is reversed: with LaTeX we output _additional_ text to get an unnumbered section, where as with HTML, we _suppress_ the additional text (i.e., the section number, which is generated here). We also only count sections that _are_ numbered. --> <xsl:if test="not( ../@number ) or ( ../@number != 'no' )"> <xsl:number count="section[not( @number ) or ( @number != 'no' )]" level="multiple" format="1.1.1.1.1.1" /> <xsl:text> </xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes"></h</xsl:text><xsl:number value="$depth" /><xsl:text disable-output-escaping="yes">></xsl:text> </common> </template> <!-- A quotation. @align: The alignment of the quotation paragraph. 'left' [default] 'center' | 'centre' 'right' --> <template name="quotation" match="quotation"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>\begin{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>\begin{center}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{center}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>\begin{quote}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{quote}</xsl:text> </xsl:otherwise> </xsl:choose> </common> <!-- Nominally we should use <blockquote>, but it doesn't have alignment. --> <common formats="/html/xhtml/"> <p> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <i><xsl:apply-templates /></i> </p> </common> </template> <!-- Anything inside a <metadata> is ignored completely. (More accurately, we pick bits out of it manually as required; it's only ignored by apply-templates.) If we move to using attributes of "document" for all metadata, this will become redundant. --> <template name="metadata" match="metadata"> <common> <xsl:message><xsl:text>Use of metadata element obsolete!</xsl:text></xsl:message> </common> </template> <!-- Anything inside an <omit> is also ignored completely. --> <template name="omit" match="omit" /> <!-- ...and the legacy id tags inside figures. --> <template match="figure/id" /> <template match="figure/label" /> <!-- Comments are not quite ignored completely, as they're carried through to the output document (kind of: "It is an error if instantiating the content of xsl:comment creates nodes other than text nodes.") --> <template name="comment" match="comment"> <common formats="/latex/xelatex/"> <xsl:text> \begin{comment}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{comment} </xsl:text> </common> <common formats="/html/xhtml/"> <xsl:comment> <xsl:apply-templates /> </xsl:comment> </common> </template> <!-- Meta-element for items that are not yet completed. --> <template name="todo" match="todo|to-do|incomplete|check"> <common formats="/latex/xelatex/"> <xsl:text>\fbox{\textbf{!!</xsl:text> <xsl:apply-templates /> <xsl:text>!!}}</xsl:text> </common> <common formats="/html/xhtml/"> <strong style="border: 1px solid black;">!!<xsl:apply-templates />!!</strong> </common> </template> <!-- Tabular structures (LaTeX {tabular}, HTML <table>). @align: The alignment of the table as a whole. 'left' [default] 'center' | 'centre' 'right' @valign (LaTeX only): Vertical alignment of the tabular within the paragraph. 'top' 'center' | 'centre' [default] 'bottom' @border: Width of cell border for HTML tables. @scale (LaTeX only): Scaling factor for the tabular. @rotate (LaTeX only): Rotation angle of tabular in degrees anti-clockwise. --> <template name="tabular" match="tabular"> <common formats="/latex/xelatex/"> <!-- spacing --> <xsl:text> </xsl:text> <!-- Overall tabular alignment. --> <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <!-- tabular rotation --> <xsl:if test="@rotate"> <xsl:text>\rotatebox{</xsl:text> <xsl:value-of select="@rotate" /> <xsl:text>}{</xsl:text> </xsl:if> <!-- tabular scaling --> <xsl:if test="@scale"> <xsl:text>\scalebox{</xsl:text> <xsl:value-of select="@scale" /> <xsl:text>}{</xsl:text> </xsl:if> <xsl:text>\begin{tabular}</xsl:text> <!-- vertical alignment --> <xsl:if test="@valign = 'top' or @valign = 'bottom'"> <xsl:text>[</xsl:text> <xsl:value-of select="substring(@valign, 1, 1)" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:apply-templates select="tabular-columns" /> <xsl:text>}</xsl:text> <xsl:apply-templates select="tabular-header" /> <xsl:apply-templates select="tabular-body" /> <xsl:apply-templates select="tabular-footer" /> <xsl:text>\end{tabular}</xsl:text> <xsl:if test="@scale"><xsl:text>}</xsl:text></xsl:if> <xsl:if test="@rotate"><xsl:text>}</xsl:text></xsl:if> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <!-- spacing --> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <table> <xsl:attribute name="border"> <xsl:value-of select="@border" /> <xsl:if test="not(@border)">0</xsl:if> </xsl:attribute> <xsl:attribute name="cellspacing">0</xsl:attribute> <xsl:attribute name="style"> <xsl:text>border-collapse: collapse; </xsl:text> <xsl:choose> <xsl:when test="@align='center'"> <xsl:text>margin-left:auto; margin-right: auto; </xsl:text> </xsl:when> <xsl:when test="@align='right'"> <xsl:text>margin-left:auto; </xsl:text> </xsl:when> <xsl:otherwise /> </xsl:choose> </xsl:attribute> <!-- Note different ordering of tabular components: HTML requires THEAD and TFOOT to precede TBODY. --> <xsl:apply-templates select="tabular-header" /> <xsl:apply-templates select="tabular-footer" /> <xsl:apply-templates select="tabular-body" /> </table> </common> </template> <!-- Specify column formatting, mainly for LaTeX, although HTML does get <td> ALIGN values from here. @align: The alignment of this particular column. 'left' [default] 'center' | 'centre' 'right' @left-border: Set to '|' to include a column separator to the left of this column. @right-border: Set to '|' to include a column separator to the right of this column. Careful: including a right-border on a cell and a left-border on the next cell will produce '||', not '|'. BUT, when doing multi-column or multi-row cells, always include both borders if required, because \multicolumn overrides the default border specification. --> <template name="aligned-tabular-column" match="tabular-columns/column[@align]"> <common formats="/latex/xelatex/"> <xsl:value-of select="@left-border" /> <xsl:value-of select="substring(@align, 1, 1)" /> <xsl:value-of select="@right-border" /> </common> </template> <template name="unaligned-tabular-column" match="tabular-columns/column[not(@align)]"> <common formats="/latex/xelatex/"> <xsl:value-of select="@left-border" /> <xsl:text>l</xsl:text> <xsl:value-of select="@right-border" /> </common> </template> <template name="tabular-header" match="tabular-header"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <thead> <xsl:apply-templates /> </thead> </common> </template> <template name="tabular-footer" match="tabular-footer"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <tfoot> <xsl:apply-templates /> </tfoot> </common> </template> <template name="tabular-body" match="tabular-body"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <tbody> <xsl:apply-templates /> </tbody> </common> </template> <!-- @no-page-break: Inhibit page breaks after this row (LaTeX only). --> <template name="row" match="row"> <common formats="/latex/xelatex/"> <xsl:apply-templates /> <!-- TODO: Don't put a \\ on the last row of a tabular. --> <xsl:text> \\</xsl:text> <xsl:if test="@no-page-break = 'yes'">*</xsl:if> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <tr> <xsl:if test="@valign"> <xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute> </xsl:if> <xsl:apply-templates /> </tr> </common> </template> <!-- Horizontal rules (LaTeX only). @columns: The column range to draw the rule across. Specify as you would for a \cline in LaTeX, e.g., '3-5'. If omitted, the rule is drawn across all columns. @weight: The weight of the rule. Note that double weight isn't available for partial rules in LaTeX, because repeated \cline macros simply draw over the top of each other. 'single' [default] 'double' = a double rule --> <template name="row-rule-full" match="row-rule[not(@columns)]"> <common formats="/latex/xelatex/"> <xsl:text>\hline</xsl:text> <xsl:if test="@weight = 'double'"><xsl:text>\hline</xsl:text></xsl:if> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <tr> <td> <xsl:attribute name="style"> <xsl:text>border-bottom: 1px solid black; </xsl:text> <!-- This is a bit of a hack to get a double border, as some browsers don't support the "double" border style yet. It looks slightly ugly, but works. --> <xsl:if test="@weight = 'double'"> <xsl:text>border-top: 1px solid black; </xsl:text> </xsl:if> </xsl:attribute> <xsl:attribute name="colspan"> <xsl:value-of select="count(ancestor::tabular/tabular-columns/column)" /> </xsl:attribute> </td> </tr> </common> </template> <template name="row-rule-partial" match="row-rule[@columns]"> <common formats="/latex/xelatex/"> <!-- Tokenise the column specifications for later reference. --> <xsl:variable name="column-specs" select="tokenize(@columns, ',')" /> <xsl:for-each select="$column-specs"> <xsl:text>\cline{</xsl:text> <xsl:value-of select="." /> <!-- Normalise the value to a range if necessary. --> <xsl:if test="not(contains(., '-'))"> <xsl:text>-</xsl:text> <xsl:value-of select="." /> </xsl:if> <xsl:text>}</xsl:text> </xsl:for-each> </common> <common formats="/html/xhtml/"> <!-- Tokenise the column specifications for later reference. --> <xsl:variable name="column-specs" select="tokenize(@columns, '[-,]')" /> <!-- We need to store the value of @weight, because the context will be changed by the for-each loop below. Default to "single" in any case. --> <xsl:variable name="weight"> <xsl:value-of select="@weight" /> <xsl:if test="not(@weight)"> <xsl:text>single</xsl:text> </xsl:if> </xsl:variable> <tr> <!-- Loop through all of the columns in the table, testing to see whether the column index exists in $column-specs. If so, add a border to the cell. Note that this loop changes the current context! --> <xsl:for-each select="1 to count(ancestor::tabular/tabular-columns/column)"> <td> <xsl:if test="exists(index-of($column-specs, . cast as xs:string))"> <xsl:attribute name="style"> <xsl:text>border-bottom: 1px solid black; </xsl:text> <xsl:if test="$weight = 'double'"> <xsl:text>border-top: 1px solid black; </xsl:text> </xsl:if> </xsl:attribute> </xsl:if> </td> </xsl:for-each> </tr> </common> </template> <!-- Hmm, the multi-row stuff is somewhat broken in LaTeX, oops. Need to insert missing columns (as was done in the calendar XSL) when a multi-row cell is encountered. Also need to sort out \hlines in the presence of multi-row cells and also what happens to vertical cell borders :( This probably needs reworking. --> <!-- Multi-row cells (LaTeX only, as this is pretty trivial to achieve in HTML). @rows: The number of rows this cell spans. @header: Is this a header cell? [yes, NO] --> <template name="multirow-cell" match="cell" mode="latex-multi-row"> <common formats="/latex/xelatex/"> <xsl:text>\multirow{</xsl:text> <xsl:value-of select="@rows" /> <xsl:text>}{*}{</xsl:text> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> <xsl:text>}</xsl:text> </common> </template> <!-- Multi-column cells (LaTeX only, as this is pretty trivial to achieve in HTML). $num-columns: The number of rows this cell spans. @header: Is this a header cell? [yes, NO] --> <template name="multicolumn-cell" match="cell" mode="latex-multi-column"> <common formats="/latex/xelatex/"> <xsl:param name="num-columns">1</xsl:param> <xsl:text>\multicolumn{</xsl:text> <xsl:value-of select="$num-columns" /> <xsl:text>}{</xsl:text> <xsl:value-of select="@left-border" /> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:value-of select="@right-border" /> <xsl:text>}{</xsl:text> <xsl:choose> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="multi-row" /> </xsl:when> <xsl:otherwise> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </common> </template> <!-- Top-level template for generating cells. @columns: The number of columns this cell spans. @rows: The number of rows this cell spans. @align: The alignment of this cell. [LEFT, center, right] @header: Is this a header cell? [yes, NO] --> <template match="cell"> <common> <!-- position() doesn't seem to work very well in this context. --> <xsl:variable name="column-no"><xsl:number /></xsl:variable> </common> <!-- Doing this sensibly for LaTeX is actually pretty ugly, because different attribute combinations produce different code :( This is the sort of algorithm that can only really be clearly described by a flow chart :) --> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="@columns"> <xsl:apply-templates select="." mode="latex-multi-column"> <xsl:with-param name="num-columns" select="@columns" /> </xsl:apply-templates> </xsl:when> <xsl:when test="@align"> <xsl:apply-templates select="." mode="latex-multi-column" /> </xsl:when> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="latex-multi-row" /> </xsl:when> <xsl:otherwise> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> </xsl:otherwise> </xsl:choose> <xsl:if test="$column-no != last()"> & </xsl:if> </common> <!-- It's much easier in HTML, because a <td> is a <td> is a <td>, regardless of the attributes supplied. --> <common formats="/html/xhtml/"> <!-- Hmm, how to generate either a TD or TH as required, including attributes, without repeating code? Aha, the answer is attribute value templates! --> <xsl:variable name="celltype"> <xsl:choose> <xsl:when test="@header = 'yes'">th</xsl:when> <xsl:otherwise>td</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:element name="{$celltype}"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> <xsl:if test="not(@align)"> <xsl:value-of select="ancestor::tabular/tabular-columns/column[position() = $column-no]/@align" /> <xsl:if test="not(ancestor::tabular/tabular-columns/column[position() = $column-no]/@align)">left</xsl:if> </xsl:if> </xsl:attribute> <xsl:attribute name="valign"> <xsl:value-of select="@valign" /> <xsl:if test="not(@valign)">middle</xsl:if> </xsl:attribute> <xsl:attribute name="colspan"> <xsl:value-of select="@columns" /> <xsl:if test="not(@columns)">1</xsl:if> </xsl:attribute> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows" /> <xsl:if test="not(@rows)">1</xsl:if> </xsl:attribute> <xsl:apply-templates /> </xsl:element> </common> </template> <!-- Hyperlinks. The content of the element is the hyperlink text. @label: A label that the hyperlink links to. The value should be an acceptable label in both LaTeX and HTML. [optional] @url: A URL that the hyperlink links to. If no link text is provided, the URL is used as the link text. [optional] --> <template name="hyperlink-label" match="hyperlink[@label and node()]"> <common formats="/latex/xelatex/">\hyperref[<xsl:value-of select="@label" />]{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><a href="#{@label}"><xsl:apply-templates /></a></common> </template> <template name="empty-hyperlink-label" match="hyperlink[@label and not(node())]"> <common> <xsl:message terminate="yes"><hyperlink> with @label must include link text.</xsl:message> </common> </template> <template name="hyperlink-url" match="hyperlink[@url and node()]"> <common formats="/latex/xelatex/">\href{<xsl:value-of select="@url" />}{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><a href="{@url}"><xsl:apply-templates /></a></common> </template> <template name="empty-hyperlink-url" match="hyperlink[@url and not(node())]"> <!-- Note: not safe to use the url package here because \url{...} is fragile. --> <common formats="/latex/xelatex/">\url{<xsl:value-of select="@url" />}</common> <common formats="/html/xhtml/"><a href="{@url}"><code><xsl:value-of select="@url" /></code></a></common> </template> <template name="hyperlink-bogus" match="hyperlink[@url and @label]" priority="2"> <common> <xsl:message terminate="yes">Cannot use both @url and @label in <hyperlink>.</xsl:message> </common> </template> <!-- Internal parameterised hyperlink template to be called by the likes of the empty Oracle documentation elements. --> <template name="hyperlink-internal" match="hyperlink" mode="hyperlink-internal"> <common> <xsl:param name="url" /> <xsl:param name="label" /> </common> <common formats="/latex/xelatex/">\href{<xsl:value-of select="$url" />}{<xsl:apply-templates select="exsl:node-set($label)" />}</common> <common formats="/html/xhtml/"><a href="{$url}"><xsl:apply-templates select="exsl:node-set($label)" /></a></common> </template> <template name="empty-hyperlink-url-internal" match="hyperlink" mode="empty-hyperlink-internal"> <common><xsl:param name="url" /></common> <common formats="/latex/xelatex/">\url{<xsl:value-of select="$url" />}</common> <common formats="/html/xhtml/"><a href="{$url}"><code><xsl:value-of select="$url" /></code></a></common> </template> <!-- A plain URL (i.e., not necessarily a hyperlink). --> <template name="url" match="url|uri|email|e-mail|email-address|e-mail-address"> <!-- Hmm, \url{...} appears to turn the URL into a non-functional link in PDF output (probably an interaction with hyperref). Not really what we want (as the link aspect is already dealt with by the <hyperlink> templates), so we'll just use \texttt{...}. --> <common formats="/latex/xelatex/">\nolinkurl{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><code><xsl:apply-templates /></code></common> </template> <!-- References. Note the distinction betwen these and hyperlinks: a reference is merely something like "see Section 2.3", and doesn't necessarily imply a hyperlink, or vice versa. @label: The label of the item that we're referencing. It must be a valid label in both LaTeX and HTML. [required] @include-pageref: If "yes", also append a page reference (LaTeX only; this is handled by the "item-page-reference" template below). --> <template name="reference" match="reference[@label]"> <common> <!-- Find the element whose label is the same as our label. --> <xsl:apply-templates select="//*[@label = current()/@label]" mode="reference" /> <xsl:if test="@include-pageref = 'yes'"> <xsl:apply-templates select="//*[@label = current()/@label]" mode="page-reference" /> </xsl:if> </common> </template> <template name="broken-reference" match="reference[not( @label )]"> <common> <xsl:message terminate="yes">Reference elements must include a label attribute.</xsl:message> </common> </template> <!-- Do a separate template for each type of referenced item; easier. --> <template name="section-reference" match="section" mode="reference"> <!-- It's probably more consistent to just use \ref* and insert "Section" ourselves rather than let LaTeX do it. --> <common formats="/latex/xelatex/"> <xsl:text>Section~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Section&nbsp;</xsl:text> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1" /> </common> </template> <template name="figure-reference" match="figure" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>Figure~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Figure&nbsp;</xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="figure" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="figure[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> </common> </template> <template name="table-reference" match="table" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>Table~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Table&nbsp;</xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="table" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="table[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Standalone direct reference to a page (i.e., not associated with some other item like a figure or table). This only really makes sense in LaTeX, as HTML doesn't have page numbers. For HTML, we fudge things by inserting the string "here", which will make sense if the reference is wrapped with a hyperlink (as they usually are). --> <template name="page-reference" match="page[@label]" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>page~\pageref{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">here</xsl:text> </common> </template> <!-- Common template for appended page references, as they're identical for all items except for standalone page references, which aren't included in this template. The include-pageref attribute is therefore ignored on standalone page references. --> <template name="item-page-reference" match="section|figure|table" mode="page-reference"> <common formats="/latex/xelatex/"> <xsl:text> on page~\pageref{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> </template> <!-- Generate a standalone label for use in direct page references. TODO: Hmm, this seems to generate the correct page number in LaTeX but the hyperlink is to the wrong page (one lower?). Something to worry about later. @label: The label to be inserted. It must be a valid label in both LaTeX and HTML. [required] --> <template name="page" match="page[@label]"> <common formats="/latex/xelatex/"> <xsl:text>\label{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <a id="{@label}"></a> </common> </template> <template name="broken-page" match="page[not( @label )]"> <common> <xsl:message terminate="yes">Page elements must include a label attribute.</xsl:message> </common> </template> <!-- Figures & tables (in the LaTeX sense, i.e., "floating" items). @border-placement: The style of border to place around the figure or table. 'none' [default] 'box' or: any combination of 'top', 'left', 'bottom', 'right', e.g., 'bottom, left' (not all options may be available) --> <template name="figure" match="figure"> <common formats="/latex/xelatex/"> \begin{figure}<xsl:if test="@latex-placement">[<xsl:value-of select="@latex-placement" />]</xsl:if> \centering <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(caption) != 0"> \caption{<xsl:apply-templates select="caption" />} <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> <xsl:if test="count(id) != 0">\label{<xsl:value-of select="id" />}</xsl:if> </xsl:if> \end{figure} </common> <common formats="/html/xhtml/"> <div class="figure" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:if test="count(id) != 0"><a id="{id}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <template name="table" match="table"> <common formats="/latex/xelatex/"> \begin{table}<xsl:if test="@latex-placement">[<xsl:value-of select="@latex-placement" />]</xsl:if> \centering <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(caption) != 0"> \caption{<xsl:apply-templates select="caption" />} <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> </xsl:if> \end{table} </common> <common formats="/html/xhtml/"> <div class="table" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:if test="count(id) != 0"><a id="{id}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <template name="multipart-table" match="table[count(part) > 0]"> <common formats="/latex/xelatex/"> <xsl:for-each select="part"> \begin{table}[p] \centering <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="../@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates /> <xsl:choose> <xsl:when test="../@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(../caption) != 0"> <xsl:text>\caption{</xsl:text> <xsl:apply-templates select="../caption" /> <xsl:choose> <xsl:when test="position() > 1"> <xsl:text> \emph{(continued)}}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> \emph{(continues over)}}</xsl:text> <xsl:if test="../@label">\label{<xsl:value-of select="../@label" />}</xsl:if> </xsl:otherwise> </xsl:choose> <!-- Consider the possibility of labels for each part? --> <!-- <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> --> </xsl:if> \end{table} \addtocounter{table}{-1} \clearpage </xsl:for-each> \stepcounter{table} </common> </template> <template name="figure-caption" match="figure/caption"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Figure </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="figure" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="figure[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> <template name="table-caption" match="table/caption"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Table </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="table" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="table[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> <!-- Images. Includes a scaling factor for LaTeX. To do: alternatively, allow defining the scaling factor by specifying what proportion of the page width the image should occupy (a la LaTeX [width] parameter). How about a <latex-attributes> element that can be used to specify \includegraphics arguments? <width keepaspectratio="yes">0.5\columnwidth</width> <height>2cm</height> <scale>0.5</scale> etc. To do: if no description is given, use the basename as the content of the ALT element. Ideally, I think we should be able to define two image formats (PDF, EPS, PNG, ...) when marking up an image: one for LaTeX output, another for HTML. Mind you, if the generation of the various formats from a single master is handled outside of the XSLT processing...? --> <!-- LaTeX images are always handled the same way regardless. --> <template name="latex-image" match="image" mode="latex"> <common formats="/latex/xelatex/"> <xsl:text>\includegraphics</xsl:text> <xsl:if test="count(latex-scaling) != 0"> <xsl:message terminate="no"><latex-scaling> element is deprecated in <image>; please use latex-options attribute instead.</xsl:message> <xsl:text>[scale=</xsl:text> <xsl:value-of select="latex-scaling" /> <xsl:text>]</xsl:text> </xsl:if> <!-- Adding general-purpose latex pass-through arguments for \includegraphics; this should eventually subsume the "scale"-only handler above. --> <!-- If providing multiple arguments, these should be comma-separated in the source XML, but do not need the enclosing square brackets. --> <xsl:if test="@latex-options"> <xsl:text>[</xsl:text> <xsl:value-of select="@latex-options" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <!-- need to phase out "basename" as an element and switch to using an attribute --> <xsl:if test="count(basename) != 0"> <xsl:message terminate="no"><basename> element is deprecated in <image>; please use basename attribute instead.</xsl:message> <xsl:value-of select="basename" /> </xsl:if> <xsl:if test="@basename"> <xsl:value-of select="@basename" /> </xsl:if> <xsl:text>-print.</xsl:text> <!-- Figure out the image format. --> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </common> </template> <template name="normal-image" match="image[count(provide-large-version) = 0]"> <common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common> <common formats="/html/xhtml/"> <img class="padded" style="border-style: none;"> <xsl:attribute name="src"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="alt"><xsl:apply-templates select="description" /></xsl:attribute> </img> </common> </template> <template name="zoomable-image" match="image[count(provide-large-version) != 0]"> <common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common> <common formats="/html/xhtml/"> <a> <xsl:attribute name="href"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web-zoom.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <img class="padded" style="border-style: none;"> <xsl:attribute name="src"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="alt"> <xsl:apply-templates select="description" /> </xsl:attribute> </img> <br clear="right" /> <xsl:text>(Larger version)</xsl:text> </a> </common> </template> <!-- Include another XML/HTML/LaTeX document into the current one. If you don't specify @type, it assumes the type of document that you're currently generating (HTML or LaTeX). LaTeX documents are simply included using \input{...}. The old <latex-input> element is now deprecated. HTML documents are a little trickier, as there's no equivalent of \input{} in HTML, plus the XSLT processor always seems to generate a DOCTYPE when producing HTML, whether you want it or not, which means that you can only really include entire HTML documents, rather than HTML fragments (maybe you can turn this off?). The workaround currently is to embed the HTML document inside an <object>. A similar argument applies for plain text documents (such as code listings) that we want to include, but are externally generated and so can't just be embedded in the source XML. @type: The type of the document to be included. [optional] Valid values are: "xml" "html" [default for HTML] "latex" [default for LaTeX] "plain" (as in text/plain) @basename: Name of file to include (including suffix!). [required] @location: Path to file to include. Note that this gets a / appended to it. However, this shouldn't make any difference in normal usage. [optional] --> <template name="include-document" match="include-document"> <common> <!-- Work out the full path specification for the file to be included = base-path + location + basename. --> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> </common> <common formats="/html/xhtml/"> <div> <xsl:attribute name="align"> <xsl:choose> <xsl:when test="@align"><xsl:value-of select="@align" /></xsl:when> <xsl:otherwise>left</xsl:otherwise> </xsl:choose> </xsl:attribute> <object data="{$file}"> <!-- Output text/html or text/plain as appropriate. --> <xsl:attribute name="type"> <xsl:text>text/</xsl:text> <xsl:choose> <xsl:when test="@type"><xsl:value-of select="@type" /></xsl:when> <xsl:otherwise><xsl:text>html</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:choose> <xsl:when test="@height"><xsl:value-of select="@height" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> </object> </div> </common> <common formats="/latex/xelatex/"> <xsl:text>\</xsl:text> <!-- Note that input text files are currently verbatim'd in LaTeX. We may want to change this in future? --> <xsl:if test="@type = 'plain'"> <xsl:text>verbatim</xsl:text> </xsl:if> <xsl:text>input{</xsl:text> <xsl:value-of select="$file" /> <xsl:text>}</xsl:text> </common> </template> <!-- Note that including XML documents is currently problematic, as the document() function expects a valid XML document. Including XML fragments is impossible. XInclude will fix this, once it is widely supported (not yet). Best to avoid this completely for now. --> <template name="include-xml" match="include-document[@type='xml']"> <common> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> <xsl:apply-templates select="document($file,/)" /> </common> </template> <!-- Environment setup. This enables you to define environment settings (e.g., required LaTeX packages, etc.). We normally explicitly call the sub-elements within this, so this template is empty to prevent unwanted stuff accidentally being included in the output. --> <template name="environment" match="environment" /> <!-- Load a LaTeX package. @options: Any arguments to the package. [optional] --> <template name="latex-package" match="latex-packages/package"> <common formats="/latex/xelatex/">\usepackage<xsl:if test="@options">[<xsl:value-of select="@options" />]</xsl:if>{<xsl:value-of select="." />}</common> </template> <!-- Execute a preamble LaTeX command. Use to set up things like counters, fonts, hyperref options, etc. --> <template name="latex-command" match="latex-commands/command"> <common formats="/latex/xelatex/"><xsl:value-of select="." /></common> </template> <!-- LaTeX hyphenation. A space-delimited list of hyphenated words. --> <template name="latex-hyphenation" match="latex-commands/hyphenation"> <common formats="/latex/xelatex/">\hyphenation{<xsl:value-of select="." />}</common> </template> <!-- Hmm, the following may be more complex than I thought... External environment files sort of stuff it up. Perhaps LaTeX document class stuff should be in attributes of the document element? --> <!-- Specify LaTeX document class and options. The master stylesheet specifies \documentclass[a4paper,12pt]{article}. Anything you specify here will override that completely, so be sure to set a4paper and 12pt if that's what you want. @options: The required document class options. [optional] --> <template name="latex-documentclass" match="latex-documentclass|documentclass"> <common formats="/latex/xelatex/">\documentclass[<xsl:value-of select="@options" />]{<xsl:value-of select="." />}</common> </template> <template name="latex-documentclass-options" match="latex-documentclass[@options]|documentclass[@options]"> <common formats="/latex/xelatex/">\documentclass[<xsl:value-of select="@options" />]{<xsl:value-of select="." />}</common> </template> <!-- Specify additional LaTeX document class options (i.e., in addition to the defaults). These should be a comma-separated list of the required options. These will be appended to the standard defaults (a4paper, 12pt). --> <template name="latex-document-options" match="latex-document-options"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <!-- Sometimes we might need to embed raw code to handle something tricky. --> <template name="raw-latex" match="raw-code[@format = 'latex']|raw-latex"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <!-- This can be a tricky if the document being processed declares any namespaces, as they generally end up attached to the first element of the raw HTML. I haven't discovered a workaround yet :(. --> <template name="raw-html" match="raw-code[@format = 'html']|raw-html"> <common formats="/html/xhtml/"><xsl:copy-of select="*" /></common> </template> <!-- Generate a LaTeX \input{} macro. --> <template name="latex-input" match="latex-input"> <common formats="/latex/xelatex/"> <xsl:message>Use of latex-input is deprecated. Please use include-document instead.</xsl:message> \input{<xsl:value-of select="." />} </common> </template> <!-- Conditional processing depending on the format. It may appear redundant to have two templates, but this is the only way to ensure that the LaTeX template is empty in the HTML style sheet, and vice versa. Note the assumption that all LaTeX format names include the string 'latex' and all HTML format names include the string 'html'. @format: the format under which this XML is to be processed. [required] --> <template name="process-when-latex" match="process-when[ contains( @format, 'latex' ) ]"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <template name="process-when-html" match="process-when[ contains( @format, 'html' ) ]"> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Basic maths stuff. Anything more complicated is... complicated. We should probably be using MathML, but we still have to mangle it into HTML regardless. @style: How to format the maths expression. Valid values are: 'inline' [default] display expression inline 'display' display expression in its own paragraph --> <template name="math-inline" match="math|math[@style='inline']"> <common formats="/latex/xelatex/">\(<xsl:apply-templates />\)</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <template name="math-display" match="math[@style='display']"> <common formats="/latex/xelatex/">\[<xsl:apply-templates />\]</common> <common formats="/html/xhtml/"><p style="text-align: center;"><xsl:apply-templates /></p></common> </template> <!-- Equation arrays --> <template name="equation-array" match="equation-array"> <common formats="/latex/xelatex/"> <xsl:text>\begin{eqnarray*} </xsl:text> <xsl:apply-templates /> <xsl:text>\end{eqnarray*}</xsl:text> </common> <common formats="/html/xhtml/"> <table class="equation" border="0" style="margin-left: auto; margin-right: auto;"><xsl:apply-templates /></table> </common> </template> <!-- Hmm, LaTeX uses "&" as separators: how do we know if there's another cell coming? Ah, but the LaTeX eqnarray can have no more than three columns, so there's no need to generalise. --> <template match="equation-array/row"> <common formats="/latex/xelatex/"> <xsl:apply-templates select="left" /><xsl:text disable-output-escaping="yes"> & </xsl:text><xsl:apply-templates select="middle" /><xsl:text disable-output-escaping="yes"> & </xsl:text><xsl:apply-templates select="right" /><xsl:text> \\ \\ </xsl:text> </common> <common formats="/html/xhtml/"> <tr><td align="right"><xsl:apply-templates select="left" /></td><td align="center"><xsl:apply-templates select="middle" /></td><td align="left"><xsl:apply-templates select="right" /></td></tr> </common> </template> <!-- Roman (upright) text inside math environments. \mathrm sounds like it's probably more correct, but doesn't retain spaces (which \textup does). --> <template name="math-text" match="text"> <common formats="/latex/xelatex/">\textup{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Calligraphic letters (upper case only for LaTeX). --> <template name="calligraphic-text" match="calligraphic|cursive"> <common formats="/latex/xelatex/">\ensuremath{\mathcal{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><font face="cursive"><xsl:apply-templates /></font></common> </template> <!-- Digit grouping separator character for large numbers. SI conventions say this should be a space (but we could make it a comma if desired). --> <template name="digit-group-separator" match="digit-group-separator|digitsep"> <common><xsl:call-template name="thin-space" /></common> </template> <!-- Mathematical super- and subscript. --> <template name="superscript-math" match="math//superscript"> <common formats="/latex/xelatex/">\ensuremath{^{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common> </template> <template name="subscript-math" match="math//subscript"> <common formats="/latex/xelatex/">\ensuremath{_{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common> </template> <!-- Basic mathematical operators. We get around the problem of math vs. non-math mode operators in LaTeX by liberally sprinkling \ensuremath around. If we're not in math mode, it enables it, and if we're already in math mode, it ignores it. This means we don't need identical templates for math and non-math modes. Yay! Do we really need <left-parenthesis> and <right-parenthesis>? Maybe we're getting a little carried away with these :). --> <template name="plus-operator" match="plus"> <common>+</common> </template> <template name="minus-operator" match="minus|subtract|minus-sign"> <common formats="/latex/xelatex/">\ensuremath{-}</common> <html><xsl:text disable-output-escaping="yes">&minus;</xsl:text></html> <!-- U+2212 MINUS SIGN --> <xhtml><span class="unicode"><xsl:text>−</xsl:text></span></xhtml> </template> <template name="times-operator" match="times|multiply|multiplication|multiplication-sign"> <common formats="/latex/xelatex/">\ensuremath{\times}</common> <html><xsl:text disable-output-escaping="yes">&times;</xsl:text></html> <!-- U+00D7 MULTIPLICATION SIGN --> <xhtml><span class="unicode"><xsl:text>×</xsl:text></span></xhtml> </template> <template name="divide-operator" match="divide|division|division-slash"> <common formats="/latex/xelatex/">\ensuremath{/}</common> <html><xsl:text>/</xsl:text></html> <!-- U+2215 DIVISION SLASH --> <xhtml><span class="unicode"><xsl:text>∕</xsl:text></span></xhtml> </template> <template name="equals-operator" match="equals|eq|equals-sign|equality"> <common formats="/latex/xelatex/">\ensuremath{=}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <!-- U+003D EQUALS SIGN --> <common formats="/html/xhtml/"><xsl:text> = </xsl:text></common> </template> <template name="not-equals-operator" match="not-equals|ne|inequality|not-equal-to"> <common formats="/latex/xelatex/">\ensuremath{\neq}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &ne; </xsl:text></html> <!-- U+2260 NOT EQUAL TO --> <xhtml><xsl:text> ≠ </xsl:text></xhtml> </template> <template name="greater-than-operator" match="greater-than|gt|greater-than-sign"> <common formats="/latex/xelatex/">\ensuremath{>}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &gt; </xsl:text></common> </template> <template name="greater-equals-operator" match="greater-equals|ge|greater-than-or-equal-to"> <common formats="/latex/xelatex/">\ensuremath{\geq}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &ge; </xsl:text></html> <!-- U+2265 GREATER-THAN OR EQUAL TO --> <xhtml><xsl:text> ≥ </xsl:text></xhtml> </template> <template name="less-than-operator" match="less-than|lt|less-than-sign"> <common formats="/latex/xelatex/"> \ensuremath{<} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &lt; </xsl:text></common> </template> <template name="less-equals-operator" match="less-equals|le"> <common formats="/latex/xelatex/"> \ensuremath{\leq} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &le; </xsl:text></html> <!-- U+2264 LESS-THAN OR EQUAL TO --> <xhtml><xsl:text> ≤ </xsl:text></xhtml> </template> <template name="approximately-equals-operator" match="approximately-equals|approximately-equal-to|approx"> <common formats="/latex/xelatex/">\ensuremath{\approx}</common> <html><xsl:text disable-output-escaping="yes">&asymp;</xsl:text></html> <xhtml><xsl:text>≈</xsl:text></xhtml> </template> <!-- Can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "rightwards-arrow". --> <template name="right-arrow" match="right-arrow|rightarrow|implies|rarr|rarrow|rightwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight='double'">R</xsl:when> <xsl:otherwise>r</xsl:otherwise> </xsl:choose> <xsl:text>ightarrow}</xsl:text> </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:choose> <xsl:when test="@weight='double'"> <xsl:text disable-output-escaping="yes"> &rArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &rarr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight='double'"> <!-- U+21D2 RIGHTWARDS DOUBLE ARROW --> <span class="unicode"> <xsl:text> ⇒ </xsl:text> </span> </xsl:when> <xsl:otherwise> <!-- U+2192 RIGHTWARDS ARROW --> <xsl:text> → </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> <!-- Can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "leftwards-arrow". --> <template name="left-arrow" match="left-arrow|leftarrow|larr|larrow|leftwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight='double'">L</xsl:when> <xsl:otherwise>l</xsl:otherwise> </xsl:choose> <xsl:text>eftarrow}</xsl:text> </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:choose> <xsl:when test="@weight='double'"> <xsl:text disable-output-escaping="yes"> &lArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &larr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight='double'"> <!-- U+21D0 LEFTWARDS DOUBLE ARROW --> <xsl:text> ⇐ </xsl:text> </xsl:when> <xsl:otherwise> <!-- U+2190 LEFTWARDS ARROW --> <xsl:text> ← </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> <!-- The equivalent of LaTeX's "log-like functions". @name: The name of the function. We assume the names used by LaTeX here, as they work out correct anyway. There's actually nothing to stop you using any name you like, except that it'll probably die horribly in LaTeX :) [required] --> <template name="log-like-function" match="function"> <common formats="/latex/xelatex/">\ensuremath{\<xsl:value-of select="@name" />}</common> <common formats="/html/xhtml/"><xsl:value-of select="@name" /></common> </template> <!-- Any mathematical variable names. --> <template name="math-variable" match="variable|var"> <common formats="/latex/xelatex/">\ensuremath{\mathit{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><i><xsl:apply-templates /></i></common> </template> <!-- A displayed fraction. Is there a nicer way of doing this in HTML? --> <template name="math-fraction" match="fraction"> <common formats="/latex/xelatex/">\ensuremath{\frac{<xsl:apply-templates select="numerator" />}{<xsl:apply-templates select="denominator" />}}</common> <html> <sup><xsl:apply-templates select="numerator" /></sup> <xsl:text disable-output-escaping="yes">&frasl;</xsl:text> <sub><xsl:apply-templates select="denominator" /></sub> </html> <xhtml> <sup><xsl:apply-templates select="numerator" /></sup> <span class="unicode"> <!-- U+2044 FRACTION SLASH --> <xsl:text>⁄</xsl:text> </span> <sub><xsl:apply-templates select="denominator" /></sub> </xhtml> </template> <!-- Format a University paper code. These normally appear in the form "SPOD 123", i.e., a space between the subject code and the paper number. --> <template name="paper" match="paper"> <common> <xsl:apply-templates select="subject-code" /> <xsl:text> </xsl:text> <xsl:apply-templates select="paper-number" /> </common> </template> <template name="subject-code" match="paper/subject-code"> <common><xsl:apply-templates /></common> </template> <template name="paper-number" match="paper/paper-number"> <common><xsl:apply-templates /></common> </template> <!-- Create a layout of multiple columns across the page. By default, columns are of equal width, but may be varied on a column-by-column basis. Each column is totally independent of the others, i.e., you can't have text automatically flowing from one column to the next (yet). @vspace: The amount of vertical space to put around the multi-column elements. [small, medium, big, LaTeX length, NONE] @align: Overall alignment of the columns (only relevant if the total width of the columns is less than the page width). [LEFT, center, right] @width: Total width of the column set, expressed as a fraction of the usable page width between 0 and 1 (this will be multiplied by 100 for HTML). Individual column widths are then expressed as a fraction of this total width. [default is 1] --> <template name="multi-column" match="multi-column"> <common formats="/latex/xelatex/"> <xsl:variable name="total-width"> <xsl:value-of select="1" /> <xsl:if test="@width"><xsl:value-of select="@width" /></xsl:if> </xsl:variable> <xsl:choose> <xsl:when test="@vspace = 'small'">\smallskip</xsl:when> <xsl:when test="@vspace = 'medium'">\medskip</xsl:when> <xsl:when test="@vspace = 'big'">\bigskip</xsl:when> <xsl:when test="@vspace">\vskip<xsl:value-of select="@vspace" /></xsl:when> </xsl:choose> \noindent <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates> <xsl:with-param name="default-width"> <xsl:value-of select="format-number($total-width div count(column),'0.00')" /> </xsl:with-param> </xsl:apply-templates> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:choose> <xsl:when test="@vspace = 'small'">\smallskip</xsl:when> <xsl:when test="@vspace = 'medium'">\medskip</xsl:when> <xsl:when test="@vspace = 'big'">\bigskip</xsl:when> <xsl:when test="@vspace">\vskip<xsl:value-of select="@vspace" /></xsl:when> </xsl:choose> </common> <common formats="/html/xhtml/"> <xsl:variable name="total-width"> <xsl:value-of select="100" /> <xsl:if test="@width"><xsl:value-of select="@width * 100" /></xsl:if> </xsl:variable> <xsl:if test="@vspace"><br /></xsl:if> <table border="0" width="{$total-width}%"> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <tr> <xsl:apply-templates> <xsl:with-param name="default-width"> <xsl:value-of select="round($total-width div count(column))" /> </xsl:with-param> </xsl:apply-templates> </tr> </table> <xsl:if test="@vspace"><br /></xsl:if> </common> </template> <!-- A column within a multi-column element. $default-width: The default width of the column, expressed as a fraction of the total column set width. This is calculated by the <multi-column> template and should be 1/n of the column set width, where n is the number of columns. @width: The width of this particular column (overrides the default). This should be expressed as a fraction between 0 and 1 (which is then multipled by 100 for HTML). Make sure that all widths add up! @align: How each individual column is to be aligned internally. --> <template name="multi-column-column" match="multi-column/column"> <common formats="/latex/xelatex/"> <xsl:param name="default-width">1</xsl:param> <xsl:text>\begin{minipage}{</xsl:text> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:value-of select="$default-width" /></xsl:otherwise> </xsl:choose> <xsl:text>\columnwidth}</xsl:text> <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>\end{minipage}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:param name="default-width">100</xsl:param> <td> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width * 100" /></xsl:when> <xsl:otherwise><xsl:value-of select="$default-width" /></xsl:otherwise> </xsl:choose> <xsl:text>%</xsl:text> </xsl:attribute> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <xsl:apply-templates /> </td> </common> </template> <!-- Center stuff on the page. --> <template name="center" match="center|centering|centre|centring"> <common formats="/latex/xelatex/"> \begin{center} <xsl:apply-templates /> \end{center} </common> <common formats="/html/xhtml/"> <div style="text-align: center;"> <xsl:apply-templates /> </div> </common> </template> <!-- Simple numbered bibliographies and reference lists (equivalent to LaTeX "plain" style biblipgraphies). We could go the whole hog and try to do something BibTeX-like, but I can't be bothered :) This is essentially similar to manually creating a LaTeX bibliography, so it's up to the writer to ensure that items are correctly sorted and formatted. An important point to note is that all items will be included, regardless of whether they are cited or not. This should suffice for most of what we want to do for teaching, though. @name: The name of the section as it should appear in print. "References" is used if not specified. --> <template name="bibliography" match="bibliography"> <common formats="/latex/xelatex/"> <xsl:if test="@name"> \renewcommand{\refname}{<xsl:value-of select="@name" />} </xsl:if> \bibliographystyle{plain} \begin{thebibliography}{99} <xsl:apply-templates /> \end{thebibliography} </common> <common formats="/html/xhtml/"> <h1> <xsl:value-of select="@name" /> <xsl:if test="not(@name)">References</xsl:if> </h1> <ol> <xsl:apply-templates /> </ol> </common> </template> <!-- An item within a bibliography. @label: The unique label of the bibliography item, so it can be cited. [REQUIRED] --> <template name="bibitem" match="bibliography/item"> <common formats="/latex/xelatex/">\bibitem{<xsl:value-of select="@label" />} <xsl:apply-templates /></common> <common formats="/html/xhtml/"> <li><a id="{@label}"></a><xsl:apply-templates /></li> </common> </template> <!-- A citation. To cater for multiple cited items, the items are specified using nested <item> elements rather than a "label" attribute. There must be at least one item. Each item must have a "label" attribute. --> <template name="citation" match="cite"> <common formats="/latex/xelatex/">\cite{<xsl:apply-templates select="item" />}</common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <xsl:text> [</xsl:text> <xsl:apply-templates select="item" /> <xsl:text>]</xsl:text> </common> </template> <!-- A cited item. @label: The unique label of the cited item. [REQUIRED] --> <template name="citation-item" match="cite/item"> <common formats="/latex/xelatex/"> <xsl:value-of select="@label" /> <xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if> </common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <a href="#{@label}"><xsl:value-of select="1 + count(//bibliography/item[@label = $id]/preceding-sibling::*)" /></a> <xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if> </common> </template> <!-- Format numbers. --> <include href="modules/number-formatting.xml" /> </stylesheet>
<?xml version="1.0" encoding="utf-8"?> <!-- This will mostly be a list of element names to match, along with the corresponding HTML and LaTeX handling XSLT code. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <!-- Various "global" elements that are frequently used across all documents. Some are passed in as arguments to the stylesheet (e.g., paper number), while others are things that don't change that often, and are thus hard coded (e.g., Oracle version). --> <include href="modules/global-elements.xml" /> <!-- Output a string containing the date that the document was last built. --> <include href="modules/build-date.xml" /> <!-- Plain paragraph. @indent: Whether or not to indent this paragraph (probably only relevant in LaTeX). 'no' => don't indent. otherwise => apply standard paragraph formatting. [default] @align: How to align the paragraph. Note that these are potentially distinct from the default action, e.g., specifying align="left" will produce a flushleft environment in LaTeX, which is not the same effect as not specifying an alignment. 'left' => left alignment 'center' => centered alignment 'right' => right alignment @border: Whether or not to draw a border around the paragraph. 'yes' => draw a border. otherwise => apply standard paragraph formatting. [default] --> <template name="paragraph" match="paragraph|para|p|P"> <common formats="/latex/xelatex/"> <xsl:text> </xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>\begin{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="@align = 'center'"> <xsl:text>\begin{center}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{center}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:if test="@indent = 'no'">\noindent </xsl:if> <xsl:if test="@border = 'yes'"> <xsl:text>\fbox{</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="@border = 'yes'"> <xsl:text>}</xsl:text> </xsl:if> </xsl:otherwise> </xsl:choose> <xsl:text> </xsl:text> </common> <!-- HTML is weird about what things you cannot include inside paragraphs (e.g. lists of any kind). However, the end P tag is optional, so one option might simply be not to output it. --> <common formats="/html/xhtml/"> <!-- The HTMLStyle parameter is an Ugly Hack(tm) to ensure that paragraphs are indented correctly inside definition lists in HTML. I tried modes first, but they didn't work correctly. Fortunately this only needs to be done with paragraphs, so this will work fine. --> <xsl:param name="HTMLStyle" /> <p> <xsl:if test="@border = 'yes'"> <xsl:attribute name="style">border: 1px solid black;</xsl:attribute> </xsl:if> <xsl:if test="$HTMLStyle"> <xsl:attribute name="class"> <xsl:value-of select="$HTMLStyle" /> </xsl:attribute> </xsl:if> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <xsl:apply-templates /> </p> </common> </template> <!-- Special characters (should maybe all be named, in case they need to be called explicitly with xsl:call-template) --> <!-- I'd like to use the Unicode names for these; will look them up some time! --> <template name="newline" match="newline|line-break|br"> <common formats="/latex/xelatex/"><xsl:text> \\ </xsl:text></common> <common formats="/html/xhtml/"><br /></common> </template> <!-- Whereas newline|line-break is for line breaks intended to be output into the final document, this is for additional linebreaks in the generated latex or HTML source (for stuff like avoiding "\end{verbatim}\item" all on one line). --> <template name="newline-internal" match="newline-internal"> <common formats="/latex/xelatex/"><xsl:text> </xsl:text></common> <common formats="/html/xhtml/"><xsl:text> </xsl:text></common> </template> <template name="page-break" match="page-break|new-page|newpage|pagebreak"> <common formats="/latex/xelatex/">\newpage</common> </template> <!-- Insert a space. Useful for the occasional case where two elements occur next to each other with only a space separating them (e.g., an <emph> immediately following a <quote>), and the space gets gobbled by XSLT, producing non-separated words in the output. It doesn't seem very consistent as to when it does and doesn't happen, unfortunately, but when it does happen, inserting a <space /> will fix the problem. This is analogous to putting a \ at the end of macros in LaTeX to ensure that spaces after the macro aren't gobbled, and indeed, this is what the LaTeX version of the markup produces. --> <template name="space" match="space"> <common formats="/latex/xelatex/"><xsl:text>\ </xsl:text></common> <!-- U+0020 SPACE --> <common formats="/html/xhtml/"><xsl:text> </xsl:text></common> </template> <template name="space-strip" match="space" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="space" /> </common> </template> <template name="non-breaking-space" match="non-breaking-space|nbsp|no-break-space"> <common formats="/latex/xelatex/">~</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></common> <!-- Could use U+00A0 NO-BREAK SPACE for XHTML? --> </template> <template name="thin-space" match="thin-space|thinspace"> <common formats="/latex/xelatex/">\,</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&thinsp;</xsl:text></common> <!-- Could use U+2009 THIN SPACE for XHTML? --> </template> <!-- Insert a discretionary hyphen. Only relevant for LaTeX output. --> <template name="discretionary-hyphen" match="hyphen"> <common formats="/latex/xelatex/">\-</common> <!-- Could use U+00AD SOFT HYPHEN for XHTML? --> </template> <!-- Technically we don't need to disable output escaping for all of these, but it's probably better to code them all consistently, rather than trying to figure out which ones do need it (e.g.,   for a non-breaking space) and which ones don't (e.g., &). --> <template name="ellipsis-sign" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis"> <common formats="/latex/xelatex/">{\ldots}</common> <html><xsl:text disable-output-escaping="yes">&hellip;</xsl:text></html> <!-- U+2026 HORIZONTAL ELLIPSIS --> <xhtml><xsl:text>…</xsl:text></xhtml> </template> <template name="ellipsis-sign-strip" match="ellipsis-sign|etc|ellipsis|dots|horizontal-ellipsis" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="ellipsis-sign" /> </common> </template> <!-- Misc typographic symbols --> <template name="endash" match="endash|en-dash|ndash|n-dash"> <common formats="/latex/xelatex/">--</common> <html><xsl:text disable-output-escaping="yes">&ndash;</xsl:text></html> <!-- U+2013 EN DASH --> <xhtml><xsl:text>–</xsl:text></xhtml> </template> <template name="endash-strip" match="endash|en-dash|ndash|n-dash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="endash" /> </common> </template> <template name="emdash" match="emdash|em-dash|mdash|m-dash"> <common formats="/latex/xelatex/">---</common> <html><xsl:text disable-output-escaping="yes">&mdash;</xsl:text></html> <xhtml><xsl:text>—</xsl:text></xhtml> <!-- U+2014 EM DASH --> </template> <template name="emdash-strip" match="emdash|em-dash|mdash|m-dash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="emdash" /> </common> </template> <!-- Use this for literal underscores that appear outside code blocks. Such things cause LaTeX to wig out. --> <template name="underscore" match="underscore|low-line"> <common formats="/latex/xelatex/">\_</common> <!-- U+005F LOW LINE --> <common formats="/html/xhtml/">_</common> </template> <template name="underscore-strip" match="underscore|low-line" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="underscore" /> </common> </template> <template name="backslash" match="backslash"> <common formats="/latex/xelatex/">\(\backslash\)</common> <!-- U+005C REVERSE SOLIDUS --> <common formats="/html/xhtml/">\</common> </template> <template name="backslash-strip" match="backslash" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="backslash" /> </common> </template> <template name="apostrophe" match="apostrophe|right-single-quotation-mark"> <common formats="/latex/xelatex/">'</common> <html><xsl:text disable-output-escaping="yes">&rsquo;</xsl:text></html> <!-- U+2019 RIGHT SINGLE QUOTATION MARK --> <xhtml><xsl:text>’</xsl:text></xhtml> </template> <template name="apostrophe-strip" match="apostrophe|right-single-quotation-mark" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="apostrophe" /> </common> </template> <template name="dollar" match="dollar|dollar-sign"> <common formats="/latex/xelatex/">{\$}</common> <!-- U+0024 DOLLAR SIGN --> <common formats="/html/xhtml/">$</common> </template> <template name="space-dollar" match="dollar|dollar-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="dollar" /> </common> </template> <template name="percent-sign" match="percent-sign|percentage-sign|percent"> <common formats="/latex/xelatex/">{\%}</common> <!-- U+0025 PERCENT SIGN --> <common formats="/html/xhtml/">%</common> </template> <template name="percent-sign-strip" match="percent-sign|percentage-sign|percent" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="percent-sign" /> </common> </template> <template name="ampersand" match="ampersand"> <common formats="/latex/xelatex/">{\&}</common> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes">&amp;</xsl:text></common> </template> <template name="ampersand-strip" match="ampersand" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="ampersand" /> </common> </template> <template name="trademark-sign" match="trademark-sign|trademark|tm|trade-mark-sign"> <common formats="/latex/xelatex/">{\texttrademark}</common> <html><xsl:text disable-output-escaping="yes">&trade;</xsl:text></html> <!-- U+2122 TRADE MARK SIGN --> <xhtml><xsl:text>™</xsl:text></xhtml> </template> <template name="trademark-sign-strip" match="trademark-sign|trademark|tm|trade-mark-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="trademark-sign" /> </common> </template> <template name="copyright-sign" match="copyright-sign"> <common formats="/latex/xelatex/">{\copyright}</common> <html><xsl:text disable-output-escaping="yes">&copy;</xsl:text></html> <!-- U+00A9 COPYRIGHT SIGN --> <xhtml><xsl:text>©</xsl:text></xhtml> </template> <template name="copyright-sign-strip" match="copyright-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="copyright-sign" /> </common> </template> <template name="degree-sign" match="degree-sign|degrees"> <common formats="/latex/xelatex/">\ensuremath{^{\circ}}</common> <html><xsl:text disable-output-escaping="yes">&deg;</xsl:text></html> <!-- U+0080 DEGREE SIGN --> <xhtml><xsl:text>°</xsl:text></xhtml> </template> <template name="degree-sign-strip" match="degree-sign|degrees" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="degree-sign" /> </common> </template> <template name="section-sign" match="section-sign"> <common formats="/latex/xelatex/">{\S}</common> <html><xsl:text disable-output-escaping="yes">&sect;</xsl:text></html> <!-- U+00A7 SECTION SIGN --> <xhtml><xsl:text>§</xsl:text></xhtml> </template> <template name="section-sign-strip" match="section-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="section-sign" /> </common> </template> <template name="sharp-sign" match="sharp|hash|number-sign"> <common formats="/latex/xelatex/">{\#}</common> <!-- U+0023 NUMBER SIGN --> <common formats="/html/xhtml/"><xsl:text>#</xsl:text></common> </template> <template name="sharp-sign-strip" match="sharp|hash|number-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="sharp-sign" /> </common> </template> <template name="paragraph-sign" match="paragraph-sign|pilcrow|pilcrow-sign"> <common formats="/latex/xelatex/">{\P}</common> <html><xsl:text disable-output-escaping="yes">&para;</xsl:text></html> <!-- U+00B6 PILCROW SIGN --> <xhtml><xsl:text>¶</xsl:text></xhtml> </template> <template name="paragraph-sign-strip" match="paragraph-sign|pilcrow|pilcrow-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="paragraph-sign" /> </common> </template> <template name="left-curly-bracket" match="left-curly-bracket|left-curly-brace|left-brace"> <common formats="/latex/xelatex/">\ensuremath{\{}</common> <!-- U+007B LEFT CURLY BRACKET --> <common formats="/html/xhtml/"><xsl:text>{</xsl:text></common> </template> <template name="left-curly-bracket-strip" match="left-curly-bracket|left-curly-brace|left-brace" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="left-curly-bracket" /> </common> </template> <template name="right-curly-bracket" match="right-curly-bracket|right-curly-brace|right-brace"> <common formats="/latex/xelatex/">\ensuremath{\}}</common> <!-- U+007D LEFT CURLY BRACKET --> <common formats="/html/xhtml/"><xsl:text>}</xsl:text></common> </template> <template name="right-curly-bracket-strip" match="right-curly-bracket|right-curly-brace|right-brace" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="right-curly-bracket" /> </common> </template> <!-- I think the pi symbol is only available in LaTeX in math mode, but if we're already in math mode, the extra $ signs will mess things up... --> <!-- Use \ensuremath to resolve the problem. --> <template name="epsilon" match="epsilon|greek-small-letter-epsilon"> <common formats="/latex/xelatex/">\ensuremath{\epsilon}</common> <html><xsl:text disable-output-escaping="yes">&epsilon;</xsl:text></html> <!-- U+03B5 GREEK SMALL LETTER EPSILON --> <xhtml><span class="unicode"><xsl:text>ε</xsl:text></span></xhtml> </template> <template name="epsilon-strip" match="epsilon|greek-small-letter-epsilon" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="epsilon" /> </common> </template> <template name="pi" match="pi|greek-small-letter-pi"> <common formats="/latex/xelatex/">\ensuremath{\pi}</common> <html><xsl:text disable-output-escaping="yes">&pi;</xsl:text></html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml><span class="unicode"><xsl:text>π</xsl:text></span></xhtml> </template> <template name="pi-strip" match="pi|greek-small-letter-pi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="pi" /> </common> </template> <template name="rho" match="rho|greek-small-letter-rho"> <common formats="/latex/xelatex/">\ensuremath{\rho}</common> <html><xsl:text disable-output-escaping="yes">&rho;</xsl:text></html> <!-- U+03C1 GREEK SMALL LETTER RHO --> <xhtml><span class="unicode"><xsl:text>ρ</xsl:text></span></xhtml> </template> <template name="rho-strip" match="rho|greek-small-letter-rho" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="rho" /> </common> </template> <template name="sigma" match="sigma|greek-small-letter-sigma"> <common formats="/latex/xelatex/">\ensuremath{\sigma}</common> <html><xsl:text disable-output-escaping="yes">&sigma;</xsl:text></html> <!-- U+03C3 GREEK SMALL LETTER SIGMA --> <xhtml><span class="unicode"><xsl:text>σ</xsl:text></span></xhtml> </template> <template name="sigma-strip" match="sigma|greek-small-letter-sigma" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="sigma" /> </common> </template> <template name="capital-phi" match="Phi|greek-capital-letter-phi"> <common formats="/latex/xelatex/">\ensuremath{\Phi}</common> <html><xsl:text disable-output-escaping="yes">&Phi;</xsl:text></html> <!-- U+03A6 GREEK CAPITAL LETTER PHI --> <xhtml><span class="unicode"><xsl:text>Φ</xsl:text></span></xhtml> </template> <template name="capital-phi-strip" match="Phi|greek-capital-letter-phi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-phi" /> </common> </template> <template name="empty-set-sign" match="empty-set-sign|empty-set|null"> <common formats="/latex/xelatex/">\ensuremath{\emptyset}</common> <html><xsl:text disable-output-escaping="yes">&empty;</xsl:text></html> <!-- U+2205 EMPTY SET --> <xhtml><span class="unicode"><xsl:text>∅</xsl:text></span></xhtml> </template> <template name="empty-set-sign-strip" match="empty-set-sign|empty-set|null" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="empty-set-sign" /> </common> </template> <template name="element-sign" match="element-sign|element|element-of|is-element-of|is-an-element-of"> <common formats="/latex/xelatex/">\ensuremath{\in}</common> <html><xsl:text disable-output-escaping="yes">&isin;</xsl:text></html> <!-- U+2208 ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∈</xsl:text></span></xhtml> </template> <template name="element-sign-strip" match="element-sign|element|element-of|is-element-of|is-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="element-sign" /> </common> </template> <template name="not-element-sign" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of"> <common formats="/latex/xelatex/">\ensuremath{\not\in}</common> <html><xsl:text disable-output-escaping="yes">&notin;</xsl:text></html> <!-- U+2209 NOT AN ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∉</xsl:text></span></xhtml> </template> <template name="not-element-sign-strip" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="not-element-sign" /> </common> </template> <template name="subset-sign" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of"> <common formats="/latex/xelatex/">\ensuremath{\subset}</common> <html><xsl:text disable-output-escaping="yes">&sub;</xsl:text></html> <!-- U+2282 SUBSET OF --> <xhtml><span class="unicode"><xsl:text>⊂</xsl:text></span></xhtml> </template> <template name="subset-strip" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="subset-sign" /> </common> </template> <template name="superset-sign" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of"> <common formats="/latex/xelatex/">\ensuremath{\supset}</common> <html><xsl:text disable-output-escaping="yes">&sup;</xsl:text></html> <!-- U+2283 SUPERSET OF --> <xhtml><span class="unicode"><xsl:text>⊃</xsl:text></span></xhtml> </template> <template name="superset-strip" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="superset-sign" /> </common> </template> <!-- Relational algebra operators. These are distinct from the basic Greek characters, because they can have associated subscripts (i.e., they have arguments). These also use relalg.sty in (Xe)LaTeX for general consistency. --> <template name="project" match="project"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelProject</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&pi;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>π</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="extend" match="extend"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelExtend</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&epsilon;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03B5 GREEK SMALL LETTER EPSILON --> <xhtml> <span class="unicode"><xsl:text>ε</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="rename" match="rename"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelRename</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&rho;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>ρ</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="restrict" match="restrict"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelRestrict</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <html> <xsl:text disable-output-escaping="yes">&sigma;</xsl:text> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml> <span class="unicode"><xsl:text>σ</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text disable-output-escaping="yes">&thinsp;</xsl:text> </xhtml> </template> <template name="join-operator" match="join-operator|join|natural-join|inner-join|bowtie"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\RelNaturalJoin</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <!-- No easy way at present to get the join symbol in HTML, so just use an image. Scale it to 10x10 pixels (fine as long as font size is set relatively normally). We need to ensure that the path is absolute, because we don't necessarily know where the document will end up in the tree. Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:text> </xsl:text> <img> <xsl:attribute name="src"> <xsl:text>/</xsl:text> <xsl:value-of select="$subject-code" /> <xsl:value-of select="$paper-number" /> <xsl:text>/Handbook/join-operator-web.png</xsl:text> </xsl:attribute> <xsl:attribute name="alt"> <xsl:text>join operator</xsl:text> </xsl:attribute> <xsl:attribute name="width"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="height"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="style"> <xsl:text>padding-left:0.3em;padding-right:0.3em</xsl:text> </xsl:attribute> </img> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </html> <!-- Note that we use the Unicode BOWTIE character (U+22C8) rather than JOIN (U+2A1D) because the latter appears to have less font support than the former, and isn't different enough to have any significant effect. --> <!-- U+22C8 BOWTIE --> <xhtml> <xsl:text> </xsl:text> <span class="unicode"><xsl:text>⋈</xsl:text></span> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </xhtml> </template> <!-- Generate a left, right or full outer join operator. @type: the type of outer join operator [optional] 'left' 'right' 'full' [default] --> <template name="outer-join-operator" match="outer-join-operator|outer-join"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\Rel</xsl:text> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>Full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>OuterJoin</xsl:text> <xsl:if test="* | text()"> <xsl:text>_{</xsl:text> <xsl:apply-templates /> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>}</xsl:text> </common> <!-- No easy way at present to get the join symbol in HTML, so just use an image. Scale it to 10x10 pixels (fine as long as font size is set relatively normally). We need to ensure that the path is absolute, because we don't necessarily know where the document will end up in the tree. Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"> <xsl:text> </xsl:text> <img> <xsl:attribute name="src"> <xsl:text>/</xsl:text> <xsl:value-of select="$subject-code" /> <xsl:value-of select="$paper-number" /> <xsl:text>/Handbook/</xsl:text> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>-outer-join-operator-web.png</xsl:text> </xsl:attribute> <xsl:attribute name="alt"> <xsl:choose> <xsl:when test="@type"> <xsl:value-of select="@type" /> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>full</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text> outer join operator</xsl:text> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="(@type = 'left') or (@type = 'right')"> <xsl:text>15</xsl:text> </xsl:when> <!-- default to a full outer join --> <xsl:otherwise> <xsl:text>20</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:text>10</xsl:text> </xsl:attribute> <xsl:attribute name="style"> <xsl:text>padding-left:0.3em;padding-right:0.3em</xsl:text> </xsl:attribute> </img> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </common> <!-- Note that these characters are available in Unicode (U+27D5 LEFT OUTER JOIN, U+27D6 RIGHT OUTER JOIN and U+27D7 FULL OUTER JOIN), but I don't think font support is very widespread yet (Dec 2010). --> <!-- <xhtml> <xsl:text> </xsl:text> <xsl:choose> <xsl:when test="@type = 'left'"> <span class="unicode"><xsl:text>⟕</xsl:text></span> </xsl:when> <xsl:when test="@type = 'right'"> <span class="unicode"><xsl:text>⟖</xsl:text></span> </xsl:when> <xsl:otherwise> <span class="unicode"><xsl:text>⟗</xsl:text></span> </xsl:otherwise> </xsl:choose> <xsl:if test="* | text()"> <sub><xsl:apply-templates /></sub> </xsl:if> <xsl:text> </xsl:text> </xhtml> --> </template> <template name="intersect-operator" match="intersect-operator|intersect|intersection|cap"> <common formats="/latex/xelatex/">\ensuremath{\cap}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &cap; </xsl:text></html> <!-- U+2229 INTERSECTION --> <xhtml><span class="unicode"><xsl:text> ∩ </xsl:text></span></xhtml> </template> <template name="intersect-operator-strip" match="intersect-operator|intersect|intersection|cap" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="intersect-operator" /> </common> </template> <template name="union-operator" match="union-operator|union|cup"> <common formats="/latex/xelatex/">\ensuremath{\cup}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &cup; </xsl:text></html> <!-- U+222A UNION --> <xhtml><span class="unicode"><xsl:text> ∪ </xsl:text></span></xhtml> </template> <template name="union-operator-strip" match="union-operator|union|cup" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="union-operator" /> </common> </template> <template name="logical-and-operator" match="logical-and-operator|logical-and|and|and-operator|hat|wedge"> <common formats="/latex/xelatex/">\ensuremath{\wedge}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &and; </xsl:text></html> <!-- U+2227 LOGICAL AND --> <xhtml><span class="unicode"><xsl:text> ∧ </xsl:text></span></xhtml> </template> <template name="logical-and-operator-strip" match="logical-and-operator|logical-and|and|and-operator|hat|wedge" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-and-operator" /> </common> </template> <template name="logical-or-operator" match="logical-or-operator|logical-or|or|or-operator|vee"> <common formats="/latex/xelatex/">\ensuremath{\vee}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &or; </xsl:text></html> <!-- U+2228 LOGICAL OR --> <xhtml><span class="unicode"><xsl:text> ∨ </xsl:text></span></xhtml> </template> <template name="logical-or-operator-strip" match="logical-or-operator|logical-or|or|or-operator|vee" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-or-operator" /> </common> </template> <template name="logical-not-operator" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign"> <common formats="/latex/xelatex/">\ensuremath{\neg}</common> <html><xsl:text disable-output-escaping="yes">&not;</xsl:text></html> <!-- U+00AC NOT SIGN --> <xhtml><span class="unicode"><xsl:text>¬</xsl:text></span></xhtml> </template> <template name="logical-not-operator-strip" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-not-operator" /> </common> </template> <template name="LaTeX" match="LaTeX|latex"> <common formats="/latex/xelatex/">{\LaTeX}</common> <common formats="/html/xhtml/">L<sup>A</sup>T<sub>E</sub>X</common> </template> <template name="LaTeX-strip" match="LaTeX|latex" mode="strip"> <common formats="/html/xhtml/">LaTeX</common> </template> <!-- Note: no equivalent of \triangleright in HTML, use right arrow instead. --> <template name="menu-separator" match="menu-separator|menusep|menu/separator"> <common formats="/latex/xelatex/"> \ensuremath{\triangleright} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &rarr; </xsl:text></html> <!-- U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE --> <xhtml><span class="unicode"><xsl:text> ▹ </xsl:text></span></xhtml> </template> <template name="menu-separator-strip" match="menu-separator|menusep|menu/separator" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="menu-separator" /> </common> </template> <template name="menu-item" match="menu/item"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><b><xsl:apply-templates /></b></common> </template> <!-- Emoticons, specifically :), :| and :(. We may be able to do more with the HTML version if we switch to Unicode? The LaTeX version requires the pifont package, which has been added to the list of standard packages in xml2xslt.xsl. It also requires Microsoft's Wingdings font (jwi) to be available. @type: the type of emoticon [optional] 'sad' 'neutral' or 'meh' :) 'happy' [default] --> <template name="emoticon" match="emoticon|smiley"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="@type = 'sad'"> <xsl:text>\Pisymbol{jwi}{"4C}</xsl:text> </xsl:when> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>\Pisymbol{jwi}{"4B}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>\Pisymbol{jwi}{"4A}</xsl:text> </xsl:otherwise> </xsl:choose> </common> <html> <xsl:choose> <xsl:when test="@type = 'sad'"> <xsl:text>:(</xsl:text> </xsl:when> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>:|</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>:)</xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@type = 'sad'"> <!-- U+2639 WHILE FROWNING FACE --> <span class="unicode"><xsl:text>☹</xsl:text></span> </xsl:when> <!-- There doesn't appear to be a Unicode character for this one. :( --> <xsl:when test="@type = 'neutral' or @type = 'meh'"> <xsl:text>:|</xsl:text> </xsl:when> <xsl:otherwise> <!-- U+263A WHILE SMILING FACE --> <span class="unicode"><xsl:text>☺</xsl:text></span> </xsl:otherwise> </xsl:choose> </xhtml> </template> <template name="emoticon-strip" match="emoticon|smiley" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="emoticon" /> </common> </template> <!-- Special styles --> <template name="emph" match="emph|em"> <common formats="/latex/xelatex/">\emph{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><em><xsl:apply-templates /></em></common> </template> <!-- Emphasis inside answers needs to be handled specially in HTML, as it doesn't just flip-flop automatically like it does in LaTeX. --> <template name="emph-in-answer" match="answer//emph|answer//em"> <common formats="/latex/xelatex/">\emph{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <template name="italic" match="italic"> <common formats="/latex/xelatex/">\textit{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i><xsl:apply-templates /></i></common> </template> <template name="strong" match="strong"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <template name="bold" match="bold"> <common formats="/latex/xelatex/">\textbf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><b><xsl:apply-templates /></b></common> </template> <template name="underline" match="underline|u"> <common formats="/latex/xelatex/">\underline{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><span style="text-decoration: underline;"><xsl:apply-templates /></span></common> </template> <template name="term" match="term"> <common formats="/latex/xelatex/">\term{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i class="term"><xsl:apply-templates /></i></common> </template> <template name="foreign" match="foreign"> <common formats="/latex/xelatex/">\foreign{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><i class="foreign"><xsl:apply-templates /></i></common> </template> <template name="code" match="code"> <!-- <latex>\code{<xsl:apply-templates />}</latex> --> <!-- Using \verb is quite handy because things like underscores don't bother it. However, it seems it can't be used inside hyperlinks. Maybe create another template that just does a \texttt on the contents? --> <!-- OK, but then we need an <underscore> element to stop them from freaking LaTeX out. --> <common formats="/latex/xelatex/">\verb`<xsl:apply-templates />`</common> <common formats="/html/xhtml/"><code><xsl:apply-templates /></code></common> </template> <template name="typewriter" match="typewriter|monospace|tt"> <common formats="/latex/xelatex/">\texttt{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><tt><xsl:apply-templates /></tt></common> </template> <template name="sans-serif" match="sans-serif|sans|ss|sf"> <common formats="/latex/xelatex/">\textsf{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><font face="sans-serif"><xsl:apply-templates /></font></common> </template> <!-- Non-maths super- and subscript. --> <template name="superscript" match="superscript"> <common formats="/latex/xelatex/">\ensuremath{^{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common> </template> <template name="subscript" match="subscript"> <common formats="/latex/xelatex/">\ensuremath{_{\mathrm{<xsl:apply-templates />}}}</common> <common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common> </template> <!-- Font sizing, using relative font size elements borrowed from LaTeX. Note that we use CSS relative font sizes (smaller and larger), which means that we have to string a bunch of them together to achieve the same effect as a single command in LaTeX. We can't use absolute sizes in CSS as they would probably look different on different machines. --> <template name="tiny" match="tiny"> <common formats="/latex/xelatex/">{\tiny <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="scriptsize" match="scriptsize"> <common formats="/latex/xelatex/">{\scriptsize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="footnotesize" match="footnotesize"> <common formats="/latex/xelatex/">{\footnotesize <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="small" match="small"> <common formats="/latex/xelatex/">{\small <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:smaller;"> <xsl:apply-templates /> </span> </common> </template> <template name="large" match="large"> <common formats="/latex/xelatex/">{\large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </common> </template> <!-- Fortunately, XML is case-sensitive. --> <template name="Large" match="Large"> <common formats="/latex/xelatex/">{\Large <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </common> </template> <template name="LARGE" match="LARGE"> <common formats="/latex/xelatex/">{\LARGE <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </common> </template> <template name="huge" match="huge"> <common formats="/latex/xelatex/">{\huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </common> </template> <template name="Huge" match="Huge"> <common formats="/latex/xelatex/">{\Huge <xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <span style="font-size:larger;"> <xsl:apply-templates /> </span> </span> </span> </span> </span> </common> </template> <!-- Text that shouldn't be broken across a line (i.e., LaTeX \mbox). Only really relevant for LaTeX because we can't control this in HTML. --> <template name="no-break" match="no-break|mbox"> <common formats="/latex/xelatex/">\mbox{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Skip a certain amount of space vertically. Probably more relevant to LaTeX than HTML. Is it even possible to vskip a set amount in HTML?? @size: the amount of space to skip. missing => \vskip\baselineskip [default] 'small' => \smallskip 'medium' => \medskip 'large' => \bigskip 'fill' => \vfill LaTeX length => \vskipxx --> <template name="vertical-skip" match="vertical-skip|vskip"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="not(@size)"> \vskip\baselineskip </xsl:when> <xsl:when test="@size='small'"> \smallskip </xsl:when> <xsl:when test="@size='medium'"> \medskip </xsl:when> <xsl:when test="@size='large'"> \bigskip </xsl:when> <xsl:when test="@size='fill'"> \vfill </xsl:when> <xsl:otherwise> \vskip<xsl:value-of select="@size" /> </xsl:otherwise> </xsl:choose> </common> <!-- For the moment we'll just throw in a BR :) --> <common formats="/html/xhtml/"><br clear="left" /></common> </template> <!-- We can decide later whether to use plain verbatim or listings. --> <template name="code-block" match="code-block"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <!-- If the code-block specifies "allow-breaks='no'", wrap the verbatim inside a minipage to avoid page breaks within the code. --> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{minipage}{\textwidth}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:if test="@allow-breaks = 'no'"> <xsl:text>\end{minipage}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\vskip\baselineskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre class="code"><xsl:apply-templates /></pre> </common> </template> <!-- This is for stuff that should unequivocally be treated verbatim (e.g. problem code). I'm pretty sure that previously this was distinguished from "code-block" because it (code-block) used to use listings instead of verbatim. Now that they're both using verbatim there is probably no need for them both (but we might switch back to using listings for code-block). --> <template name="verbatim" match="verbatim"> <common formats="/latex/xelatex/"> <xsl:call-template name="newline-internal" /> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{verbatim}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <pre><xsl:apply-templates /></pre> </common> </template> <!-- Quoted text. Handles nested quotes correctly. @single: Whether to enclose the text in single or double quotes. 'yes' => single quotes (''). otherwise => double quotes (""). [default] --> <template name="single-quote" match="quote[@single='yes']|q[@single='yes']"> <common formats="/latex/xelatex/">`<xsl:apply-templates />'</common> <html> <xsl:text disable-output-escaping="yes">&lsquo;</xsl:text> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes">&rsquo;</xsl:text> </html> <xhtml> <!-- U+2018 LEFT SINGLE QUOTATION MARK --> <xsl:text>‘</xsl:text> <xsl:apply-templates /> <!-- U+2019 RIGHT SINGLE QUOTATION MARK --> <xsl:text>’</xsl:text> </xhtml> </template> <template name="double-quote" match="quote|qq"> <common formats="/latex/xelatex/">``<xsl:apply-templates />''</common> <html> <xsl:text disable-output-escaping="yes">&ldquo;</xsl:text> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes">&rdquo;</xsl:text> </html> <xhtml> <!-- U+201C LEFT DOUBLE QUOTATION MARK --> <xsl:text>“</xsl:text> <xsl:apply-templates /> <!-- U+201D RIGHT DOUBLE QUOTATION MARK --> <xsl:text>”</xsl:text> </xhtml> </template> <!-- With nested quotes, we need to figure out what depth of nesting we're at, then call the appropriate template depending on the initial quoting style (single or double). --> <template name="nested-double-quote" match="quote//quote"> <common> <xsl:choose> <xsl:when test="(count(ancestor::quote) mod 2) = 0"> <xsl:call-template name="double-quote" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="single-quote" /> </xsl:otherwise> </xsl:choose> </common> </template> <template name="nested-single-quote" match="quote[@single='yes']//quote" priority="2"> <common> <xsl:choose> <xsl:when test="(count(ancestor::quote) mod 2) = 0"> <xsl:call-template name="single-quote" /> </xsl:when> <xsl:otherwise> <xsl:call-template name="double-quote" /> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Note the lack of orthgonality that means that elements other than <item> are ignored. --> <!-- TODO: Use just xsl:apply-templates and instead of using modes, check inside the item template what the parent is? --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list|itemize|unordered-list|bulleted-list|bullet-list|bullet-points|UL|ul"> <common formats="/latex/xelatex/"> \begin{itemize} <xsl:apply-templates select="item" mode="normal" /> \end{itemize} </common> <common formats="/html/xhtml/"> <ul> <xsl:apply-templates select="item" mode="normal" /> </ul> </common> </template> <!-- Ordered lists. @start: The starting number for the list. [default 1] --> <template name="enumerated-list" match="enumerated-list|enumerate|ordered-list|numbered-list|question-list|OL|ol"> <common formats="/latex/xelatex/"> \begin{enumerate} <xsl:if test='@start'> <!-- Set the appropriate enum counter according to the depth. Use the format attribute of xsl:number to output it in Roman numerals. Depth must be at least 1 (enumi) and at most 4 (enumiv). Bizarrely, a count(ancestor::xxx) here gives 0 for the outermost element, whereas for section elements it gives 1?!?! --> <xsl:text>\setcounter{enum</xsl:text> <xsl:number value="min( ( 1 + count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> <xsl:text>}{</xsl:text> <!-- Remember that LaTeX adds 1 to the counter before using it. --> <xsl:value-of select="@start - 1" /> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates select="item" mode="enumerated-list" /> \end{enumerate} </common> <common formats="/html/xhtml/"> <ol> <xsl:if test="@start"> <!-- Note that we're using the START attribute of OL, which is actually deprecated in HTML 4 and XHTML. However, the alternative (using CSS styling) is useless, as it doesn't permit different number formatting for different levels of list (e.g., 1., a., ii., etc.). The only standards-compliant solution to this is to forgo HTML list elements completely and do it all ourselves. Ugh, no thanks! --> <xsl:attribute name="start"> <xsl:value-of select="@start" /> </xsl:attribute> </xsl:if> <xsl:apply-templates select="item" mode="enumerated-list" /> </ol> </common> </template> <!-- Definition or description lists. --> <template name="definition-list" match="definition-list|description-list|DL|dl"> <common formats="/latex/xelatex/"> \begin{description} <xsl:apply-templates select="item" mode="definition-list" /> \end{description} </common> <common formats="/html/xhtml/"> <!-- <dl>s in HTML tend to come out with the spacing a bit wrong (or maybe it's just my browser?). Anyway, they don't appear to be displayed correctly. A more portable solution is to use plain <p>s with CSS margins to control the hanging indent. The tricky part is dealing with embedded <paragraph>s inside the <description-list>. The clever details are handled in the "definition-item" template. --> <xsl:apply-templates select="item" mode="definition-list" /> </common> </template> <!-- List elements --> <template name="list-item" match="item" mode="normal"> <common formats="/latex/xelatex/"><xsl:text>\item </xsl:text><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <li><xsl:apply-templates /></li> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the item content so that the item spacing looks OK. --> <xsl:otherwise> <li><p><xsl:apply-templates /></p></li> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Provide the ability to set the numbering of specific items in enumerated lists. Results could be unpredictable if this is applied to an itemised list! @value: the number to use for the next list item. [default 1] --> <template name="enumerated-item-value" match="item[@value]" mode="enumerated-list"> <common formats="/latex/xelatex/"> <!-- Set the appropriate enum counter. --> <xsl:text>\setcounter{enum</xsl:text> <xsl:number value="min( ( count( ancestor::enumerated-list|ancestor::enumerate|ancestor::ordered-list|ancestor::numbered-list|ancestor::question-list|ancestor::OL|ancestor::ol ), 4 ) )" format="i" /> <xsl:text>}{</xsl:text> <!-- Remember that LaTeX adds 1 to the counter before using it. --> <xsl:value-of select="@value - 1" /> <xsl:text>}</xsl:text> <xsl:apply-templates select="." mode="normal" /> </common> <!-- Unfortunately this can't just be a wrapper around the "normal" item template because of the nesting of attributes inside the element. --> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs or things that should be treated like paragraphs inside the item. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <li> <xsl:attribute name="value" select="@value" /> <xsl:apply-templates /> </li> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the item content so that the item spacing looks OK. --> <xsl:otherwise> <li> <xsl:attribute name="value" select="@value" /> <p><xsl:apply-templates /></p> </li> </xsl:otherwise> </xsl:choose> </common> </template> <template name="enumerated-item" match="item[not( @value )]" mode="enumerated-list"> <common> <xsl:apply-templates select="." mode="normal" /> </common> </template> <template name="definition-item" match="item" mode="definition-list"> <common formats="/latex/xelatex/"> <xsl:text>\item[</xsl:text> <xsl:apply-templates select="keyword|term|topic|DT|dt" /> <xsl:text>] </xsl:text> <xsl:apply-templates select="definition|description|discourse|DD|dd" /> </common> <common formats="/html/xhtml/"> <!-- We have to be a little clever here, because we're transforming potentially multiple embedded elements (embedded <paragraph>s in particular) into one or more <p> tags in the HTML. We need to ensure that: (a) we don't end up with nested <p> tags, (b) all paragraphs are correctly indented, and (c) if the first thing following the <definition> is a <paragraph> or text node, it gets positioned correctly relative to the <keyword>. We know that the <keyword> won't have embedded <paragraph>s (it doesn't really make sense, not that we actually check :) The only thing we therefore need to check for is <paragraph> elements inside the <definition> element. --> <xsl:choose> <!-- If the first sub-node of the <definition> is NOT a <p> node, then the whole thing should be just simple text and contain only basic formatting elements, if anything (i.e., no lists!). We therefore just wrap the <keyword> and <definition> within a <p> with a hanging indent and finish. Note the use of child::node[1|2], because we don't necessarily know what variants of <keyword> and <definition> have actually been used, but we know that they will (should!) always be the first and second children of the <item> respectively. This probably is the most common case, so test for it first. --> <xsl:when test="not(child::node()[2]/child::node()[1][self::p] or child::node()[2]/child::node()[1][self::paragraph])"> <p class="definition1"> <xsl:apply-templates select="child::node()[1]" /> <xsl:text> </xsl:text> <xsl:apply-templates select="child::node()[2]" /> </p> </xsl:when> <!-- If the first sub-node of the <definition> IS a <p> or <paragraph>, then we need to skip over the processing of this element to avoid nested <p>s in the output. Any remaining sub-nodes are processed normally, except that we pass in the HTMLStyle parameter to ensure that any remaining paragraph elements are correctly indented. I would have used modes for this, but it killed embedded <itemize>s, because there isn't an <itemize> template with the appropriate mode (nor is there a need for one). Grr. --> <xsl:otherwise> <p class="definition1"> <xsl:apply-templates select="child::node()[1]" /> <xsl:text> </xsl:text> <xsl:apply-templates select="child::node()[2]/child::node()[1]/node()" /> </p> <xsl:apply-templates select="child::node()[2]/*[position() > 1]"> <xsl:with-param name="HTMLStyle">definition2</xsl:with-param> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Need to provide some context here as, e.g., <term> is also a standalone element. --> <template name="keyword" match="item/keyword|item/term|item/topic|item/DT|item/dt"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"><strong><xsl:apply-templates /></strong></common> </template> <!-- Need to provide some context here as, e.g., <description> is also used within <image>. --> <template name="definition" match="item/definition|item/description|item/discourse|item/DD|item/dd"> <common><xsl:apply-templates /></common> </template> <!-- Question text. This only exists so that we can ensure that appropriate <p> tags are correctly inserted. If this template didn't exist, showing the answers would generate invalid HTML. The answers are enclosed in a <div class="answer">...</div>. Without this template, the answer markup ends up embedded inside <p>...</p>, which is invalid. --> <template name="question" match="question"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <xsl:choose> <!-- Check whether there are actual paragraphs inside the question. If so, let them worry about inserting the <p> tags. --> <xsl:when test="count(paragraph|para|p|question|answer|code-block) != 0"> <xsl:apply-templates /> </xsl:when> <!-- Otherwise, insert <p> tags surrounding the question content. --> <xsl:otherwise> <p><xsl:apply-templates /></p> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Sample answers, which may optionally be excluded from the output. This can be done globally for all answers by setting the style sheet parameter $showanswers to "no", or it can be done locally on a question-by-question basis by setting the @hide attribute of the element to "yes". @hide: If "yes", don't include this answer in the output stream. The default is to include the answer. --> <template name="answer" match="answer"> <common formats="/latex/xelatex/"> <!-- It's nice to weed out the sample answer markup at the XSLT processing stage to make LaTeX run faster. Note that \showanswers still needs to be called so that LaTeX can format chapter headings like "Answers for ..." --> <xsl:if test="$showanswers='yes'"> \begin{answer} <xsl:apply-templates /> \end{answer} </xsl:if> </common> <common formats="/html/xhtml/"> <xsl:if test="$showanswers='yes'"> <div class="answer"> <xsl:apply-templates /> </div> </xsl:if> </common> </template> <!-- Match hidden answers and do nothing. --> <template name="hidden-answer" match="answer[@hide='yes']" /> <!-- Sections, subsections, subsubsections, ... @label: A label that can be used for cross referencing. Any value can be used, as long as it's a legal identifier in both LaTeX and HTML. @number: Whether or not to generate a section number. It makes the most logical sense for this attribute to be associated with the section element, but the section numbers are actually generated in the "section-title" template (see below). Consequently, this attribute isn't even mentioned in this template. 'yes' [default] 'no' --> <template name="section" match="section"> <common formats="/latex/xelatex/"> <xsl:apply-templates> <xsl:with-param name="label"> <xsl:value-of select="@label" /> <xsl:if test="not(@label)">THERE_IS_NO_LABEL</xsl:if> </xsl:with-param> </xsl:apply-templates> </common> <common formats="/html/xhtml/"> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates /> </common> </template> <!-- Footnotes. --> <template name="footnote" match="footnote"> <common formats="/latex/xelatex/">\footnote{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"> <a> <xsl:attribute name="name"> <xsl:text>footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-source</xsl:text> </xsl:attribute> <xsl:attribute name="href"> <xsl:text>#footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-target</xsl:text> </xsl:attribute> <xsl:text>[</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>]</xsl:text> </a> </common> </template> <!-- This is only required for HTML, as LaTeX does it all for you. --> <template name="footnote-list" match="footnote" mode="list"> <common formats="/html/xhtml/"> <p> <a> <xsl:attribute name="name"> <xsl:text>footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-target</xsl:text> </xsl:attribute> <sup> <xsl:text>[</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>]</xsl:text> </sup> </a> <xsl:text> </xsl:text> <xsl:apply-templates /> <xsl:text> </xsl:text> <!-- Provide a back link to the original footnote marker. --> <a> <xsl:attribute name="href"> <xsl:text>#footnote-</xsl:text> <xsl:number level="any" count="footnote" /> <xsl:text>-source</xsl:text> </xsl:attribute> <xsl:text>[Back]</xsl:text> </a> </p> </common> </template> <!-- Document preamble stuff: title, author, date. --> <template name="preamble-title" match="document/title" mode="preamble"> <common formats="/latex/xelatex/"> <xsl:text>\title{</xsl:text> <xsl:if test="/document/@class = 'assignment'"> <xsl:if test="$showanswers='yes'">Sample Solution for </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:text> Assignment </xsl:text> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: \\</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <!-- For HTML, strip out any raw HTML formatting (e.g., emphasis), as this is not interpreted within the <title> tag, resulting in raw HTML markup in the window title. Ick. We do this by switching to "strip" mode. --> <common formats="/html/xhtml/"> <xsl:if test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' ) or ( /document/@class = 'assignment' )"> <xsl:if test="$showanswers='yes'"> <xsl:choose> <xsl:when test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' )"> <xsl:text>Selected Answers for </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text>Sample Solution for </xsl:text> </xsl:when> </xsl:choose> </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text> Tutorial </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text> Lab </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text> Assignment </xsl:text> </xsl:when> </xsl:choose> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: </xsl:text> </xsl:if> <xsl:apply-templates mode="strip" /> </common> </template> <template name="preamble-author" match="document/author" mode="preamble"> <common formats="/latex/xelatex/">\author{<xsl:apply-templates />}</common> </template> <template name="preamble-date" match="document/date" mode="preamble"> <common formats="/latex/xelatex/">\date{<xsl:apply-templates />}</common> </template> <template name="document-title" match="document/title"> <!-- Need to do something sensible for LaTeX here. --> <common formats="/latex/xelatex/"> <!-- Under the LaTeX framework, the rest of the chapter title text is generated by LaTeX macros, so this is pretty simple. I think this is broken? In fact, I think that for LaTeX documents, this template isn't called at all?? Looking at xml2xslt.xsl, if the document's standalone, "preamble-title" is used, and otherwise, "chapter-title" is used. --> <xsl:if test="/document/@standalone = 'yes'"><xsl:apply-templates /></xsl:if> </common> <common formats="/html/xhtml/"> <h1> <xsl:if test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' ) or ( /document/@class = 'assignment' )"> <xsl:if test="$showanswers='yes'"> <xsl:choose> <xsl:when test="( /document/@class = 'tutorial' ) or ( /document/@class = 'laboratory' )"> <xsl:text>Selected Answers for </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text>Sample Solution for </xsl:text> </xsl:when> </xsl:choose> </xsl:if> <xsl:call-template name="PaperCode" /> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text> Tutorial </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text> Lab </xsl:text> </xsl:when> <xsl:when test="/document/@class = 'assignment'"> <xsl:text> Assignment </xsl:text> </xsl:when> </xsl:choose> <xsl:value-of select="/document/@sequence-number" /> <xsl:text>: </xsl:text> </xsl:if> <xsl:apply-templates /> </h1> </common> </template> <!-- New template for tutorials and labs, which are essentially chapters when included in a course book, but are marked up as documents in themselves. --> <template name="chapter-title" match="document/title" mode="chapter"> <!-- TODO: For LaTeX, filling in the "INFO XXX Tutorial", etc., is currently done in the LaTeX layer in the infrastructure surrounding the \lab and \tutorial macros (i.e., it's magic). This derives from the historical origins of the handbook, and should be moved here for consistency. An initial attempt to just replace calls to \tutorial, etc., with \chapter didn't work properly, as these macros do other things as well, including internal munging of chapter handling. This Will Be Complicated :(. --> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <xsl:text>\tutorial{</xsl:text> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <xsl:text>\lab{</xsl:text> </xsl:when> <xsl:otherwise> <!-- maybe we should assume that we're in a book documentclass and issue a \chapter here? --> <xsl:text>\general{</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:apply-templates /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:choose> <xsl:when test="/document/@class = 'tutorial'"> <h1><xsl:call-template name="PaperCode" /> Tutorial <xsl:value-of select="/document/@sequence-number" /><xsl:if test="$showanswers='yes'"> Sample Answers</xsl:if>: <br /><xsl:apply-templates /></h1> </xsl:when> <xsl:when test="/document/@class = 'laboratory'"> <h1><xsl:call-template name="PaperCode" /> Lab <xsl:value-of select="/document/@sequence-number" /><xsl:if test="$showanswers='yes'"> Sample Answers</xsl:if>: <br /><xsl:apply-templates /></h1> </xsl:when> <xsl:otherwise> <h1><xsl:apply-templates /></h1> </xsl:otherwise> </xsl:choose> </common> </template> <template name="document-author" match="document/author"> <common formats="/html/xhtml/"><p><xsl:apply-templates /></p></common> </template> <template name="document-date" match="document/date" /> <!-- Generate some number of "sub"s so we can produce, e.g., "subsubsection" for LaTeX. $depth: the number of repetitions (0 to 2, which maps to 1 to 3 below due to counting ancestor section elements coming out one more than expected). --> <template name="generate-subs"> <common formats="/latex/xelatex/"> <xsl:param name="depth">1</xsl:param> <xsl:if test="$depth > 1"> <xsl:if test="$depth < 4"> <xsl:text>sub</xsl:text> </xsl:if> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth" select="$depth - 1" /> </xsl:call-template> </xsl:if> </common> </template> <!-- Generate section title with nested numbering, e.g., 1.1.3. --> <template name="section-title" match="section/title"> <common formats="/latex/xelatex/"> <xsl:param name="label" /> <xsl:text>\</xsl:text> <!-- Generate the correct number of "sub"s for LaTeX. --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth" select="count( ancestor::section )" /> </xsl:call-template> <xsl:text>section</xsl:text> <!-- Unnumbered section. We reference the @number attribute of the parent section element. (We are guaranteed that the parent is a section element by the match context for this template.) --> <xsl:if test="../@number = 'no'"> <xsl:text>*</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:apply-templates /><xsl:text>}</xsl:text> <xsl:if test="$label != 'THERE_IS_NO_LABEL'"> \label{<xsl:value-of select="$label" />} </xsl:if> </common> <common formats="/html/xhtml/"> <!-- The depth is used in a couple of places, so we pre-calculate it. --> <xsl:variable name="depth"> <xsl:number value="1 + count(ancestor::section)" /> <xsl:if test="1 + count(ancestor::section) > 6">6</xsl:if> </xsl:variable> <xsl:text disable-output-escaping="yes"><h</xsl:text><xsl:number value="$depth" /><xsl:text disable-output-escaping="yes">></xsl:text> <!-- Unnumbered section, as per above. Note that the sense of the test is reversed: with LaTeX we output _additional_ text to get an unnumbered section, where as with HTML, we _suppress_ the additional text (i.e., the section number, which is generated here). We also only count sections that _are_ numbered. --> <xsl:if test="not( ../@number ) or ( ../@number != 'no' )"> <xsl:number count="section[not( @number ) or ( @number != 'no' )]" level="multiple" format="1.1.1.1.1.1" /> <xsl:text> </xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:text disable-output-escaping="yes"></h</xsl:text><xsl:number value="$depth" /><xsl:text disable-output-escaping="yes">></xsl:text> </common> </template> <!-- A quotation. @align: The alignment of the quotation paragraph. 'left' [default] 'center' | 'centre' 'right' --> <template name="quotation" match="quotation"> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>\begin{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{flush</xsl:text> <xsl:value-of select="@align" /> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>\begin{center}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{center}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>\begin{quote}\itshape </xsl:text> <xsl:apply-templates /> <xsl:text>\end{quote}</xsl:text> </xsl:otherwise> </xsl:choose> </common> <!-- Nominally we should use <blockquote>, but it doesn't have alignment. --> <common formats="/html/xhtml/"> <p> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <i><xsl:apply-templates /></i> </p> </common> </template> <!-- Anything inside a <metadata> is ignored completely. (More accurately, we pick bits out of it manually as required; it's only ignored by apply-templates.) If we move to using attributes of "document" for all metadata, this will become redundant. --> <template name="metadata" match="metadata"> <common> <xsl:message><xsl:text>Use of metadata element obsolete!</xsl:text></xsl:message> </common> </template> <!-- Anything inside an <omit> is also ignored completely. --> <template name="omit" match="omit" /> <!-- ...and the legacy id tags inside figures. --> <template match="figure/id" /> <template match="figure/label" /> <!-- Comments are not quite ignored completely, as they're carried through to the output document (kind of: "It is an error if instantiating the content of xsl:comment creates nodes other than text nodes.") --> <template name="comment" match="comment"> <common formats="/latex/xelatex/"> <xsl:text> \begin{comment}</xsl:text> <xsl:apply-templates /> <xsl:text>\end{comment} </xsl:text> </common> <common formats="/html/xhtml/"> <xsl:comment> <xsl:apply-templates /> </xsl:comment> </common> </template> <!-- Meta-element for items that are not yet completed. --> <template name="todo" match="todo|to-do|incomplete|check"> <common formats="/latex/xelatex/"> <xsl:text>\fbox{\textbf{!!</xsl:text> <xsl:apply-templates /> <xsl:text>!!}}</xsl:text> </common> <common formats="/html/xhtml/"> <strong style="border: 1px solid black;">!!<xsl:apply-templates />!!</strong> </common> </template> <!-- Tabular structures (LaTeX {tabular}, HTML <table>). @align: The alignment of the table as a whole. 'left' [default] 'center' | 'centre' 'right' @valign (LaTeX only): Vertical alignment of the tabular within the paragraph. 'top' 'center' | 'centre' [default] 'bottom' @border: Width of cell border for HTML tables. @scale (LaTeX only): Scaling factor for the tabular. @rotate (LaTeX only): Rotation angle of tabular in degrees anti-clockwise. --> <template name="tabular" match="tabular"> <common formats="/latex/xelatex/"> <!-- spacing --> <xsl:text> </xsl:text> <!-- Overall tabular alignment. --> <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <!-- tabular rotation --> <xsl:if test="@rotate"> <xsl:text>\rotatebox{</xsl:text> <xsl:value-of select="@rotate" /> <xsl:text>}{</xsl:text> </xsl:if> <!-- tabular scaling --> <xsl:if test="@scale"> <xsl:text>\scalebox{</xsl:text> <xsl:value-of select="@scale" /> <xsl:text>}{</xsl:text> </xsl:if> <xsl:text>\begin{tabular}</xsl:text> <!-- vertical alignment --> <xsl:if test="@valign = 'top' or @valign = 'bottom'"> <xsl:text>[</xsl:text> <xsl:value-of select="substring(@valign, 1, 1)" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <xsl:apply-templates select="tabular-columns" /> <xsl:text>}</xsl:text> <xsl:apply-templates select="tabular-header" /> <xsl:apply-templates select="tabular-body" /> <xsl:apply-templates select="tabular-footer" /> <xsl:text>\end{tabular}</xsl:text> <xsl:if test="@scale"><xsl:text>}</xsl:text></xsl:if> <xsl:if test="@rotate"><xsl:text>}</xsl:text></xsl:if> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <!-- spacing --> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <table> <xsl:attribute name="border"> <xsl:value-of select="@border" /> <xsl:if test="not(@border)">0</xsl:if> </xsl:attribute> <xsl:attribute name="cellspacing">0</xsl:attribute> <xsl:attribute name="style"> <xsl:text>border-collapse: collapse; </xsl:text> <xsl:choose> <xsl:when test="@align='center'"> <xsl:text>margin-left:auto; margin-right: auto; </xsl:text> </xsl:when> <xsl:when test="@align='right'"> <xsl:text>margin-left:auto; </xsl:text> </xsl:when> <xsl:otherwise /> </xsl:choose> </xsl:attribute> <!-- Note different ordering of tabular components: HTML requires THEAD and TFOOT to precede TBODY. --> <xsl:apply-templates select="tabular-header" /> <xsl:apply-templates select="tabular-footer" /> <xsl:apply-templates select="tabular-body" /> </table> </common> </template> <!-- Specify column formatting, mainly for LaTeX, although HTML does get <td> ALIGN values from here. @align: The alignment of this particular column. 'left' [default] 'center' | 'centre' 'right' @left-border: Set to '|' to include a column separator to the left of this column. @right-border: Set to '|' to include a column separator to the right of this column. Careful: including a right-border on a cell and a left-border on the next cell will produce '||', not '|'. BUT, when doing multi-column or multi-row cells, always include both borders if required, because \multicolumn overrides the default border specification. --> <template name="aligned-tabular-column" match="tabular-columns/column[@align]"> <common formats="/latex/xelatex/"> <xsl:value-of select="@left-border" /> <xsl:value-of select="substring(@align, 1, 1)" /> <xsl:value-of select="@right-border" /> </common> </template> <template name="unaligned-tabular-column" match="tabular-columns/column[not(@align)]"> <common formats="/latex/xelatex/"> <xsl:value-of select="@left-border" /> <xsl:text>l</xsl:text> <xsl:value-of select="@right-border" /> </common> </template> <template name="tabular-header" match="tabular-header"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <thead> <xsl:apply-templates /> </thead> </common> </template> <template name="tabular-footer" match="tabular-footer"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <tfoot> <xsl:apply-templates /> </tfoot> </common> </template> <template name="tabular-body" match="tabular-body"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <tbody> <xsl:apply-templates /> </tbody> </common> </template> <!-- @no-page-break: Inhibit page breaks after this row (LaTeX only). --> <template name="row" match="row"> <common formats="/latex/xelatex/"> <xsl:apply-templates /> <!-- TODO: Don't put a \\ on the last row of a tabular. --> <xsl:text> \\</xsl:text> <xsl:if test="@no-page-break = 'yes'">*</xsl:if> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <tr> <xsl:if test="@valign"> <xsl:attribute name="valign"><xsl:value-of select="@valign" /></xsl:attribute> </xsl:if> <xsl:apply-templates /> </tr> </common> </template> <!-- Horizontal rules (LaTeX only). @columns: The column range to draw the rule across. Specify as you would for a \cline in LaTeX, e.g., '3-5'. If omitted, the rule is drawn across all columns. @weight: The weight of the rule. Note that double weight isn't available for partial rules in LaTeX, because repeated \cline macros simply draw over the top of each other. 'single' [default] 'double' = a double rule --> <template name="row-rule-full" match="row-rule[not(@columns)]"> <common formats="/latex/xelatex/"> <xsl:text>\hline</xsl:text> <xsl:if test="@weight = 'double'"><xsl:text>\hline</xsl:text></xsl:if> <xsl:text> </xsl:text> </common> <common formats="/html/xhtml/"> <tr> <td> <xsl:attribute name="style"> <xsl:text>border-bottom: 1px solid black; </xsl:text> <!-- This is a bit of a hack to get a double border, as some browsers don't support the "double" border style yet. It looks slightly ugly, but works. --> <xsl:if test="@weight = 'double'"> <xsl:text>border-top: 1px solid black; </xsl:text> </xsl:if> </xsl:attribute> <xsl:attribute name="colspan"> <xsl:value-of select="count(ancestor::tabular/tabular-columns/column)" /> </xsl:attribute> </td> </tr> </common> </template> <template name="row-rule-partial" match="row-rule[@columns]"> <common formats="/latex/xelatex/"> <!-- Tokenise the column specifications for later reference. --> <xsl:variable name="column-specs" select="tokenize(@columns, ',')" /> <xsl:for-each select="$column-specs"> <xsl:text>\cline{</xsl:text> <xsl:value-of select="." /> <!-- Normalise the value to a range if necessary. --> <xsl:if test="not(contains(., '-'))"> <xsl:text>-</xsl:text> <xsl:value-of select="." /> </xsl:if> <xsl:text>}</xsl:text> </xsl:for-each> </common> <common formats="/html/xhtml/"> <!-- Tokenise the column specifications for later reference. --> <xsl:variable name="column-specs" select="tokenize(@columns, '[-,]')" /> <!-- We need to store the value of @weight, because the context will be changed by the for-each loop below. Default to "single" in any case. --> <xsl:variable name="weight"> <xsl:value-of select="@weight" /> <xsl:if test="not(@weight)"> <xsl:text>single</xsl:text> </xsl:if> </xsl:variable> <tr> <!-- Loop through all of the columns in the table, testing to see whether the column index exists in $column-specs. If so, add a border to the cell. Note that this loop changes the current context! --> <xsl:for-each select="1 to count(ancestor::tabular/tabular-columns/column)"> <td> <xsl:if test="exists(index-of($column-specs, . cast as xs:string))"> <xsl:attribute name="style"> <xsl:text>border-bottom: 1px solid black; </xsl:text> <xsl:if test="$weight = 'double'"> <xsl:text>border-top: 1px solid black; </xsl:text> </xsl:if> </xsl:attribute> </xsl:if> </td> </xsl:for-each> </tr> </common> </template> <!-- Hmm, the multi-row stuff is somewhat broken in LaTeX, oops. Need to insert missing columns (as was done in the calendar XSL) when a multi-row cell is encountered. Also need to sort out \hlines in the presence of multi-row cells and also what happens to vertical cell borders :( This probably needs reworking. --> <!-- Multi-row cells (LaTeX only, as this is pretty trivial to achieve in HTML). @rows: The number of rows this cell spans. @header: Is this a header cell? [yes, NO] --> <template name="multirow-cell" match="cell" mode="latex-multi-row"> <common formats="/latex/xelatex/"> <xsl:text>\multirow{</xsl:text> <xsl:value-of select="@rows" /> <xsl:text>}{*}{</xsl:text> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> <xsl:text>}</xsl:text> </common> </template> <!-- Multi-column cells (LaTeX only, as this is pretty trivial to achieve in HTML). $num-columns: The number of rows this cell spans. @header: Is this a header cell? [yes, NO] --> <template name="multicolumn-cell" match="cell" mode="latex-multi-column"> <common formats="/latex/xelatex/"> <xsl:param name="num-columns">1</xsl:param> <xsl:text>\multicolumn{</xsl:text> <xsl:value-of select="$num-columns" /> <xsl:text>}{</xsl:text> <xsl:value-of select="@left-border" /> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:value-of select="@right-border" /> <xsl:text>}{</xsl:text> <xsl:choose> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="multi-row" /> </xsl:when> <xsl:otherwise> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </common> </template> <!-- Top-level template for generating cells. @columns: The number of columns this cell spans. @rows: The number of rows this cell spans. @align: The alignment of this cell. [LEFT, center, right] @header: Is this a header cell? [yes, NO] --> <template match="cell"> <common> <!-- position() doesn't seem to work very well in this context. --> <xsl:variable name="column-no"><xsl:number /></xsl:variable> </common> <!-- Doing this sensibly for LaTeX is actually pretty ugly, because different attribute combinations produce different code :( This is the sort of algorithm that can only really be clearly described by a flow chart :) --> <common formats="/latex/xelatex/"> <xsl:choose> <xsl:when test="@columns"> <xsl:apply-templates select="." mode="latex-multi-column"> <xsl:with-param name="num-columns" select="@columns" /> </xsl:apply-templates> </xsl:when> <xsl:when test="@align"> <xsl:apply-templates select="." mode="latex-multi-column" /> </xsl:when> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="latex-multi-row" /> </xsl:when> <xsl:otherwise> <xsl:if test="@header = 'yes'"><xsl:text>\textbf{</xsl:text></xsl:if> <!-- check for embedded line breaks, if so, embed another tabular inside this one --> <xsl:if test="count(child::br) != 0"> <xsl:text>\begin{tabular}{@{}</xsl:text> <xsl:choose> <xsl:when test="@align"> <xsl:value-of select="substring(@align, 1, 1)" /> </xsl:when> <xsl:otherwise> <xsl:text>l</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>@{}}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="count(child::br) != 0"> <xsl:text>\end{tabular} </xsl:text></xsl:if> <xsl:if test="@header = 'yes'"><xsl:text>}</xsl:text></xsl:if> </xsl:otherwise> </xsl:choose> <xsl:if test="$column-no != last()"> & </xsl:if> </common> <!-- It's much easier in HTML, because a <td> is a <td> is a <td>, regardless of the attributes supplied. --> <common formats="/html/xhtml/"> <!-- Hmm, how to generate either a TD or TH as required, including attributes, without repeating code? Aha, the answer is attribute value templates! --> <xsl:variable name="celltype"> <xsl:choose> <xsl:when test="@header = 'yes'">th</xsl:when> <xsl:otherwise>td</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:element name="{$celltype}"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> <xsl:if test="not(@align)"> <xsl:value-of select="ancestor::tabular/tabular-columns/column[position() = $column-no]/@align" /> <xsl:if test="not(ancestor::tabular/tabular-columns/column[position() = $column-no]/@align)">left</xsl:if> </xsl:if> </xsl:attribute> <xsl:attribute name="valign"> <xsl:value-of select="@valign" /> <xsl:if test="not(@valign)">middle</xsl:if> </xsl:attribute> <xsl:attribute name="colspan"> <xsl:value-of select="@columns" /> <xsl:if test="not(@columns)">1</xsl:if> </xsl:attribute> <xsl:attribute name="rowspan"> <xsl:value-of select="@rows" /> <xsl:if test="not(@rows)">1</xsl:if> </xsl:attribute> <xsl:apply-templates /> </xsl:element> </common> </template> <!-- Hyperlinks. The content of the element is the hyperlink text. @label: A label that the hyperlink links to. The value should be an acceptable label in both LaTeX and HTML. [optional] @url: A URL that the hyperlink links to. If no link text is provided, the URL is used as the link text. [optional] --> <template name="hyperlink-label" match="hyperlink[@label and node()]"> <common formats="/latex/xelatex/">\hyperref[<xsl:value-of select="@label" />]{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><a href="#{@label}"><xsl:apply-templates /></a></common> </template> <template name="empty-hyperlink-label" match="hyperlink[@label and not(node())]"> <common> <xsl:message terminate="yes"><hyperlink> with @label must include link text.</xsl:message> </common> </template> <template name="hyperlink-url" match="hyperlink[@url and node()]"> <common formats="/latex/xelatex/">\href{<xsl:value-of select="@url" />}{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><a href="{@url}"><xsl:apply-templates /></a></common> </template> <template name="empty-hyperlink-url" match="hyperlink[@url and not(node())]"> <!-- Note: not safe to use the url package here because \url{...} is fragile. --> <common formats="/latex/xelatex/">\url{<xsl:value-of select="@url" />}</common> <common formats="/html/xhtml/"><a href="{@url}"><code><xsl:value-of select="@url" /></code></a></common> </template> <template name="hyperlink-bogus" match="hyperlink[@url and @label]" priority="2"> <common> <xsl:message terminate="yes">Cannot use both @url and @label in <hyperlink>.</xsl:message> </common> </template> <!-- Internal parameterised hyperlink template to be called by the likes of the empty Oracle documentation elements. --> <template name="hyperlink-internal" match="hyperlink" mode="hyperlink-internal"> <common> <xsl:param name="url" /> <xsl:param name="label" /> </common> <common formats="/latex/xelatex/">\href{<xsl:value-of select="$url" />}{<xsl:apply-templates select="exsl:node-set($label)" />}</common> <common formats="/html/xhtml/"><a href="{$url}"><xsl:apply-templates select="exsl:node-set($label)" /></a></common> </template> <template name="empty-hyperlink-url-internal" match="hyperlink" mode="empty-hyperlink-internal"> <common><xsl:param name="url" /></common> <common formats="/latex/xelatex/">\url{<xsl:value-of select="$url" />}</common> <common formats="/html/xhtml/"><a href="{$url}"><code><xsl:value-of select="$url" /></code></a></common> </template> <!-- A plain URL (i.e., not necessarily a hyperlink). --> <template name="url" match="url|uri|email|e-mail|email-address|e-mail-address"> <!-- Hmm, \url{...} appears to turn the URL into a non-functional link in PDF output (probably an interaction with hyperref). Not really what we want (as the link aspect is already dealt with by the <hyperlink> templates), so we'll just use \texttt{...}. --> <common formats="/latex/xelatex/">\nolinkurl{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><code><xsl:apply-templates /></code></common> </template> <!-- References. Note the distinction betwen these and hyperlinks: a reference is merely something like "see Section 2.3", and doesn't necessarily imply a hyperlink, or vice versa. @label: The label of the item that we're referencing. It must be a valid label in both LaTeX and HTML. [required] @include-pageref: If "yes", also append a page reference (LaTeX only; this is handled by the "item-page-reference" template below). --> <template name="reference" match="reference[@label]"> <common> <!-- Find the element whose label is the same as our label. --> <xsl:apply-templates select="//*[@label = current()/@label]" mode="reference" /> <xsl:if test="@include-pageref = 'yes'"> <xsl:apply-templates select="//*[@label = current()/@label]" mode="page-reference" /> </xsl:if> </common> </template> <template name="broken-reference" match="reference[not( @label )]"> <common> <xsl:message terminate="yes">Reference elements must include a label attribute.</xsl:message> </common> </template> <!-- Do a separate template for each type of referenced item; easier. --> <template name="section-reference" match="section" mode="reference"> <!-- It's probably more consistent to just use \ref* and insert "Section" ourselves rather than let LaTeX do it. --> <common formats="/latex/xelatex/"> <xsl:text>Section~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Section&nbsp;</xsl:text> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1" /> </common> </template> <template name="figure-reference" match="figure" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>Figure~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Figure&nbsp;</xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="figure" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="figure[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> </common> </template> <template name="table-reference" match="table" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>Table~\ref*{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">Table&nbsp;</xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="table" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="table[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> </common> </template> <!-- Standalone direct reference to a page (i.e., not associated with some other item like a figure or table). This only really makes sense in LaTeX, as HTML doesn't have page numbers. For HTML, we fudge things by inserting the string "here", which will make sense if the reference is wrapped with a hyperlink (as they usually are). --> <template name="page-reference" match="page[@label]" mode="reference"> <common formats="/latex/xelatex/"> <xsl:text>page~\pageref{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:text disable-output-escaping="yes">here</xsl:text> </common> </template> <!-- Common template for appended page references, as they're identical for all items except for standalone page references, which aren't included in this template. The include-pageref attribute is therefore ignored on standalone page references. --> <template name="item-page-reference" match="section|figure|table" mode="page-reference"> <common formats="/latex/xelatex/"> <xsl:text> on page~\pageref{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> </template> <!-- Generate a standalone label for use in direct page references. TODO: Hmm, this seems to generate the correct page number in LaTeX but the hyperlink is to the wrong page (one lower?). Something to worry about later. @label: The label to be inserted. It must be a valid label in both LaTeX and HTML. [required] --> <template name="page" match="page[@label]"> <common formats="/latex/xelatex/"> <xsl:text>\label{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> </common> <common formats="/html/xhtml/"> <a id="{@label}"></a> </common> </template> <template name="broken-page" match="page[not( @label )]"> <common> <xsl:message terminate="yes">Page elements must include a label attribute.</xsl:message> </common> </template> <!-- Figures & tables (in the LaTeX sense, i.e., "floating" items). @border-placement: The style of border to place around the figure or table. 'none' [default] 'box' or: any combination of 'top', 'left', 'bottom', 'right', e.g., 'bottom, left' (not all options may be available) --> <template name="figure" match="figure"> <common formats="/latex/xelatex/"> \begin{figure}<xsl:if test="@latex-placement">[<xsl:value-of select="@latex-placement" />]</xsl:if> \centering <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(caption) != 0"> \caption{<xsl:apply-templates select="caption" />} <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> <xsl:if test="count(id) != 0">\label{<xsl:value-of select="id" />}</xsl:if> </xsl:if> \end{figure} </common> <common formats="/html/xhtml/"> <div class="figure" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:if test="count(id) != 0"><a id="{id}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <template name="table" match="table"> <common formats="/latex/xelatex/"> \begin{table}<xsl:if test="@latex-placement">[<xsl:value-of select="@latex-placement" />]</xsl:if> \centering <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(caption) != 0"> \caption{<xsl:apply-templates select="caption" />} <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> </xsl:if> \end{table} </common> <common formats="/html/xhtml/"> <div class="table" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:if test="count(id) != 0"><a id="{id}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <template name="multipart-table" match="table[count(part) > 0]"> <common formats="/latex/xelatex/"> <xsl:for-each select="part"> \begin{table}[p] \centering <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="../@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> </xsl:when> </xsl:choose> <xsl:apply-templates /> <xsl:choose> <xsl:when test="../@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:if test="count(../caption) != 0"> <xsl:text>\caption{</xsl:text> <xsl:apply-templates select="../caption" /> <xsl:choose> <xsl:when test="position() > 1"> <xsl:text> \emph{(continued)}}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> \emph{(continues over)}}</xsl:text> <xsl:if test="../@label">\label{<xsl:value-of select="../@label" />}</xsl:if> </xsl:otherwise> </xsl:choose> <!-- Consider the possibility of labels for each part? --> <!-- <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> --> </xsl:if> \end{table} \addtocounter{table}{-1} \clearpage </xsl:for-each> \stepcounter{table} </common> </template> <template name="figure-caption" match="figure/caption"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Figure </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="figure" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="figure[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> <template name="table-caption" match="table/caption"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Table </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="table" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="table[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> <!-- Images. Includes a scaling factor for LaTeX. To do: alternatively, allow defining the scaling factor by specifying what proportion of the page width the image should occupy (a la LaTeX [width] parameter). How about a <latex-attributes> element that can be used to specify \includegraphics arguments? <width keepaspectratio="yes">0.5\columnwidth</width> <height>2cm</height> <scale>0.5</scale> etc. To do: if no description is given, use the basename as the content of the ALT element. Ideally, I think we should be able to define two image formats (PDF, EPS, PNG, ...) when marking up an image: one for LaTeX output, another for HTML. Mind you, if the generation of the various formats from a single master is handled outside of the XSLT processing...? --> <!-- LaTeX images are always handled the same way regardless. --> <template name="latex-image" match="image" mode="latex"> <common formats="/latex/xelatex/"> <xsl:text>\includegraphics</xsl:text> <xsl:if test="count(latex-scaling) != 0"> <xsl:message terminate="no"><latex-scaling> element is deprecated in <image>; please use latex-options attribute instead.</xsl:message> <xsl:text>[scale=</xsl:text> <xsl:value-of select="latex-scaling" /> <xsl:text>]</xsl:text> </xsl:if> <!-- Adding general-purpose latex pass-through arguments for \includegraphics; this should eventually subsume the "scale"-only handler above. --> <!-- If providing multiple arguments, these should be comma-separated in the source XML, but do not need the enclosing square brackets. --> <xsl:if test="@latex-options"> <xsl:text>[</xsl:text> <xsl:value-of select="@latex-options" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{</xsl:text> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <!-- need to phase out "basename" as an element and switch to using an attribute --> <xsl:if test="count(basename) != 0"> <xsl:message terminate="no"><basename> element is deprecated in <image>; please use basename attribute instead.</xsl:message> <xsl:value-of select="basename" /> </xsl:if> <xsl:if test="@basename"> <xsl:value-of select="@basename" /> </xsl:if> <xsl:text>-print.</xsl:text> <!-- Figure out the image format. --> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </common> </template> <template name="normal-image" match="image[count(provide-large-version) = 0]"> <common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common> <common formats="/html/xhtml/"> <img class="padded" style="border-style: none;"> <xsl:attribute name="src"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="alt"><xsl:apply-templates select="description" /></xsl:attribute> </img> </common> </template> <template name="zoomable-image" match="image[count(provide-large-version) != 0]"> <common formats="/latex/xelatex/"><xsl:apply-templates select="." mode="latex" /></common> <common formats="/html/xhtml/"> <a> <xsl:attribute name="href"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web-zoom.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <img class="padded" style="border-style: none;"> <xsl:attribute name="src"> <!-- Work out the full path specification for the file to be included = base-path + location (if specified) + basename. --> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <!-- Check whether the location attribute is included. --> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="basename|@basename" /> <xsl:text>-web.</xsl:text> <xsl:choose> <!-- CME: oops, I'd originally used the "format" tag to identify the format used in the LaTeX version, not the HTML! --> <xsl:when test="count(format) != 0"> <xsl:message terminate="no"><format> element is deprecated in <image>; please use format attribute instead.</xsl:message> <xsl:value-of select="format" /> </xsl:when> <xsl:when test="@format"> <xsl:value-of select="@format" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format" /> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="alt"> <xsl:apply-templates select="description" /> </xsl:attribute> </img> <br clear="right" /> <xsl:text>(Larger version)</xsl:text> </a> </common> </template> <!-- Include another XML/HTML/LaTeX document into the current one. If you don't specify @type, it assumes the type of document that you're currently generating (HTML or LaTeX). LaTeX documents are simply included using \input{...}. The old <latex-input> element is now deprecated. HTML documents are a little trickier, as there's no equivalent of \input{} in HTML, plus the XSLT processor always seems to generate a DOCTYPE when producing HTML, whether you want it or not, which means that you can only really include entire HTML documents, rather than HTML fragments (maybe you can turn this off?). The workaround currently is to embed the HTML document inside an <object>. A similar argument applies for plain text documents (such as code listings) that we want to include, but are externally generated and so can't just be embedded in the source XML. @type: The type of the document to be included. [optional] Valid values are: "xml" "html" [default for HTML] "latex" [default for LaTeX] "plain" (as in text/plain) @basename: Name of file to include (including suffix!). [required] @location: Path to file to include. Note that this gets a / appended to it. However, this shouldn't make any difference in normal usage. [optional] --> <template name="include-document" match="include-document"> <common> <!-- Work out the full path specification for the file to be included = base-path + location + basename. --> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> </common> <common formats="/html/xhtml/"> <div> <xsl:attribute name="align"> <xsl:choose> <xsl:when test="@align"><xsl:value-of select="@align" /></xsl:when> <xsl:otherwise>left</xsl:otherwise> </xsl:choose> </xsl:attribute> <object data="{$file}"> <!-- Output text/html or text/plain as appropriate. --> <xsl:attribute name="type"> <xsl:text>text/</xsl:text> <xsl:choose> <xsl:when test="@type"><xsl:value-of select="@type" /></xsl:when> <xsl:otherwise><xsl:text>html</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="height"> <xsl:choose> <xsl:when test="@height"><xsl:value-of select="@height" /></xsl:when> <xsl:otherwise><xsl:text>100%</xsl:text></xsl:otherwise> </xsl:choose> </xsl:attribute> </object> </div> </common> <common formats="/latex/xelatex/"> <xsl:text>\</xsl:text> <!-- Note that input text files are currently verbatim'd in LaTeX. We may want to change this in future? --> <xsl:if test="@type = 'plain'"> <xsl:text>verbatim</xsl:text> </xsl:if> <xsl:text>input{</xsl:text> <xsl:value-of select="$file" /> <xsl:text>}</xsl:text> </common> </template> <!-- Note that including XML documents is currently problematic, as the document() function expects a valid XML document. Including XML fragments is impossible. XInclude will fix this, once it is widely supported (not yet). Best to avoid this completely for now. --> <template name="include-xml" match="include-document[@type='xml']"> <common> <xsl:variable name="file"> <xsl:value-of select="$base-path" /> <xsl:text>/</xsl:text> <xsl:if test="@location"> <xsl:value-of select="@location" /> <xsl:text>/</xsl:text> </xsl:if> <xsl:value-of select="@basename" /> </xsl:variable> <xsl:apply-templates select="document($file,/)" /> </common> </template> <!-- Environment setup. This enables you to define environment settings (e.g., required LaTeX packages, etc.). We normally explicitly call the sub-elements within this, so this template is empty to prevent unwanted stuff accidentally being included in the output. --> <template name="environment" match="environment" /> <!-- Load a LaTeX package. @options: Any arguments to the package. [optional] --> <template name="latex-package" match="latex-packages/package"> <common formats="/latex/xelatex/">\usepackage<xsl:if test="@options">[<xsl:value-of select="@options" />]</xsl:if>{<xsl:value-of select="." />}</common> </template> <!-- Execute a preamble LaTeX command. Use to set up things like counters, fonts, hyperref options, etc. --> <template name="latex-command" match="latex-commands/command"> <common formats="/latex/xelatex/"><xsl:value-of select="." /></common> </template> <!-- LaTeX hyphenation. A space-delimited list of hyphenated words. --> <template name="latex-hyphenation" match="latex-commands/hyphenation"> <common formats="/latex/xelatex/">\hyphenation{<xsl:value-of select="." />}</common> </template> <!-- Hmm, the following may be more complex than I thought... External environment files sort of stuff it up. Perhaps LaTeX document class stuff should be in attributes of the document element? --> <!-- Specify LaTeX document class and options. The master stylesheet specifies \documentclass[a4paper,12pt]{article}. Anything you specify here will override that completely, so be sure to set a4paper and 12pt if that's what you want. @options: The required document class options. [optional] --> <template name="latex-documentclass" match="latex-documentclass|documentclass"> <common formats="/latex/xelatex/">\documentclass[<xsl:value-of select="@options" />]{<xsl:value-of select="." />}</common> </template> <template name="latex-documentclass-options" match="latex-documentclass[@options]|documentclass[@options]"> <common formats="/latex/xelatex/">\documentclass[<xsl:value-of select="@options" />]{<xsl:value-of select="." />}</common> </template> <!-- Specify additional LaTeX document class options (i.e., in addition to the defaults). These should be a comma-separated list of the required options. These will be appended to the standard defaults (a4paper, 12pt). --> <template name="latex-document-options" match="latex-document-options"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <!-- Sometimes we might need to embed raw code to handle something tricky. --> <template name="raw-latex" match="raw-code[@format = 'latex']|raw-latex"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <!-- This can be a tricky if the document being processed declares any namespaces, as they generally end up attached to the first element of the raw HTML. I haven't discovered a workaround yet :(. --> <template name="raw-html" match="raw-code[@format = 'html']|raw-html"> <common formats="/html/xhtml/"><xsl:copy-of select="*" /></common> </template> <!-- Generate a LaTeX \input{} macro. --> <template name="latex-input" match="latex-input"> <common formats="/latex/xelatex/"> <xsl:message>Use of latex-input is deprecated. Please use include-document instead.</xsl:message> \input{<xsl:value-of select="." />} </common> </template> <!-- Conditional processing depending on the format. It may appear redundant to have two templates, but this is the only way to ensure that the LaTeX template is empty in the HTML style sheet, and vice versa. Note the assumption that all LaTeX format names include the string 'latex' and all HTML format names include the string 'html'. @format: the format under which this XML is to be processed. [required] --> <template name="process-when-latex" match="process-when[ contains( @format, 'latex' ) ]"> <common formats="/latex/xelatex/"><xsl:apply-templates /></common> </template> <template name="process-when-html" match="process-when[ contains( @format, 'html' ) ]"> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Basic maths stuff. Anything more complicated is... complicated. We should probably be using MathML, but we still have to mangle it into HTML regardless. @style: How to format the maths expression. Valid values are: 'inline' [default] display expression inline 'display' display expression in its own paragraph --> <template name="math-inline" match="math|math[@style='inline']"> <common formats="/latex/xelatex/">\(<xsl:apply-templates />\)</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <template name="math-display" match="math[@style='display']"> <common formats="/latex/xelatex/">\[<xsl:apply-templates />\]</common> <common formats="/html/xhtml/"><p style="text-align: center;"><xsl:apply-templates /></p></common> </template> <!-- Equation arrays --> <template name="equation-array" match="equation-array"> <common formats="/latex/xelatex/"> <xsl:text>\begin{eqnarray*} </xsl:text> <xsl:apply-templates /> <xsl:text>\end{eqnarray*}</xsl:text> </common> <common formats="/html/xhtml/"> <table class="equation" border="0" style="margin-left: auto; margin-right: auto;"><xsl:apply-templates /></table> </common> </template> <!-- Hmm, LaTeX uses "&" as separators: how do we know if there's another cell coming? Ah, but the LaTeX eqnarray can have no more than three columns, so there's no need to generalise. --> <template match="equation-array/row"> <common formats="/latex/xelatex/"> <xsl:apply-templates select="left" /><xsl:text disable-output-escaping="yes"> & </xsl:text><xsl:apply-templates select="middle" /><xsl:text disable-output-escaping="yes"> & </xsl:text><xsl:apply-templates select="right" /><xsl:text> \\ \\ </xsl:text> </common> <common formats="/html/xhtml/"> <tr><td align="right"><xsl:apply-templates select="left" /></td><td align="center"><xsl:apply-templates select="middle" /></td><td align="left"><xsl:apply-templates select="right" /></td></tr> </common> </template> <!-- Roman (upright) text inside math environments. \mathrm sounds like it's probably more correct, but doesn't retain spaces (which \textup does). --> <template name="math-text" match="text"> <common formats="/latex/xelatex/">\textup{<xsl:apply-templates />}</common> <common formats="/html/xhtml/"><xsl:apply-templates /></common> </template> <!-- Calligraphic letters (upper case only for LaTeX). --> <template name="calligraphic-text" match="calligraphic|cursive"> <common formats="/latex/xelatex/">\ensuremath{\mathcal{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><font face="cursive"><xsl:apply-templates /></font></common> </template> <!-- Digit grouping separator character for large numbers. SI conventions say this should be a space (but we could make it a comma if desired). --> <template name="digit-group-separator" match="digit-group-separator|digitsep"> <common><xsl:call-template name="thin-space" /></common> </template> <!-- Mathematical super- and subscript. --> <template name="superscript-math" match="math//superscript"> <common formats="/latex/xelatex/">\ensuremath{^{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><sup><xsl:apply-templates /></sup></common> </template> <template name="subscript-math" match="math//subscript"> <common formats="/latex/xelatex/">\ensuremath{_{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><sub><xsl:apply-templates /></sub></common> </template> <!-- Basic mathematical operators. We get around the problem of math vs. non-math mode operators in LaTeX by liberally sprinkling \ensuremath around. If we're not in math mode, it enables it, and if we're already in math mode, it ignores it. This means we don't need identical templates for math and non-math modes. Yay! Do we really need <left-parenthesis> and <right-parenthesis>? Maybe we're getting a little carried away with these :). --> <template name="plus-operator" match="plus"> <common>+</common> </template> <template name="minus-operator" match="minus|subtract|minus-sign"> <common formats="/latex/xelatex/">\ensuremath{-}</common> <html><xsl:text disable-output-escaping="yes">&minus;</xsl:text></html> <!-- U+2212 MINUS SIGN --> <xhtml><span class="unicode"><xsl:text>−</xsl:text></span></xhtml> </template> <template name="times-operator" match="times|multiply|multiplication|multiplication-sign"> <common formats="/latex/xelatex/">\ensuremath{\times}</common> <html><xsl:text disable-output-escaping="yes">&times;</xsl:text></html> <!-- U+00D7 MULTIPLICATION SIGN --> <xhtml><span class="unicode"><xsl:text>×</xsl:text></span></xhtml> </template> <template name="divide-operator" match="divide|division|division-slash"> <common formats="/latex/xelatex/">\ensuremath{/}</common> <html><xsl:text>/</xsl:text></html> <!-- U+2215 DIVISION SLASH --> <xhtml><span class="unicode"><xsl:text>∕</xsl:text></span></xhtml> </template> <template name="equals-operator" match="equals|eq|equals-sign|equality"> <common formats="/latex/xelatex/">\ensuremath{=}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <!-- U+003D EQUALS SIGN --> <common formats="/html/xhtml/"><xsl:text> = </xsl:text></common> </template> <template name="not-equals-operator" match="not-equals|ne|inequality|not-equal-to"> <common formats="/latex/xelatex/">\ensuremath{\neq}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &ne; </xsl:text></html> <!-- U+2260 NOT EQUAL TO --> <xhtml><xsl:text> ≠ </xsl:text></xhtml> </template> <template name="greater-than-operator" match="greater-than|gt|greater-than-sign"> <common formats="/latex/xelatex/">\ensuremath{>}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &gt; </xsl:text></common> </template> <template name="greater-equals-operator" match="greater-equals|ge|greater-than-or-equal-to"> <common formats="/latex/xelatex/">\ensuremath{\geq}</common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &ge; </xsl:text></html> <!-- U+2265 GREATER-THAN OR EQUAL TO --> <xhtml><xsl:text> ≥ </xsl:text></xhtml> </template> <template name="less-than-operator" match="less-than|lt|less-than-sign"> <common formats="/latex/xelatex/"> \ensuremath{<} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &lt; </xsl:text></common> </template> <template name="less-equals-operator" match="less-equals|le"> <common formats="/latex/xelatex/"> \ensuremath{\leq} </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html><xsl:text disable-output-escaping="yes"> &le; </xsl:text></html> <!-- U+2264 LESS-THAN OR EQUAL TO --> <xhtml><xsl:text> ≤ </xsl:text></xhtml> </template> <template name="approximately-equals-operator" match="approximately-equals|approximately-equal-to|approx"> <common formats="/latex/xelatex/">\ensuremath{\approx}</common> <html><xsl:text disable-output-escaping="yes">&asymp;</xsl:text></html> <xhtml><xsl:text>≈</xsl:text></xhtml> </template> <!-- Can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "rightwards-arrow". --> <template name="right-arrow" match="right-arrow|rightarrow|implies|rarr|rarrow|rightwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight='double'">R</xsl:when> <xsl:otherwise>r</xsl:otherwise> </xsl:choose> <xsl:text>ightarrow}</xsl:text> </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:choose> <xsl:when test="@weight='double'"> <xsl:text disable-output-escaping="yes"> &rArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &rarr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight='double'"> <!-- U+21D2 RIGHTWARDS DOUBLE ARROW --> <span class="unicode"> <xsl:text> ⇒ </xsl:text> </span> </xsl:when> <xsl:otherwise> <!-- U+2192 RIGHTWARDS ARROW --> <xsl:text> → </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> <!-- Can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "leftwards-arrow". --> <template name="left-arrow" match="left-arrow|leftarrow|larr|larrow|leftwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight='double'">L</xsl:when> <xsl:otherwise>l</xsl:otherwise> </xsl:choose> <xsl:text>eftarrow}</xsl:text> </common> <!-- Need spaces for HTML as they seem to get munched otherwise. --> <html> <xsl:choose> <xsl:when test="@weight='double'"> <xsl:text disable-output-escaping="yes"> &lArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &larr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight='double'"> <!-- U+21D0 LEFTWARDS DOUBLE ARROW --> <xsl:text> ⇐ </xsl:text> </xsl:when> <xsl:otherwise> <!-- U+2190 LEFTWARDS ARROW --> <xsl:text> ← </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> <!-- The equivalent of LaTeX's "log-like functions". @name: The name of the function. We assume the names used by LaTeX here, as they work out correct anyway. There's actually nothing to stop you using any name you like, except that it'll probably die horribly in LaTeX :) [required] --> <template name="log-like-function" match="function"> <common formats="/latex/xelatex/">\ensuremath{\<xsl:value-of select="@name" />}</common> <common formats="/html/xhtml/"><xsl:value-of select="@name" /></common> </template> <!-- Any mathematical variable names. --> <template name="math-variable" match="variable|var"> <common formats="/latex/xelatex/">\ensuremath{\mathit{<xsl:apply-templates />}}</common> <common formats="/html/xhtml/"><i><xsl:apply-templates /></i></common> </template> <!-- A displayed fraction. Is there a nicer way of doing this in HTML? --> <template name="math-fraction" match="fraction"> <common formats="/latex/xelatex/">\ensuremath{\frac{<xsl:apply-templates select="numerator" />}{<xsl:apply-templates select="denominator" />}}</common> <html> <sup><xsl:apply-templates select="numerator" /></sup> <xsl:text disable-output-escaping="yes">&frasl;</xsl:text> <sub><xsl:apply-templates select="denominator" /></sub> </html> <xhtml> <sup><xsl:apply-templates select="numerator" /></sup> <span class="unicode"> <!-- U+2044 FRACTION SLASH --> <xsl:text>⁄</xsl:text> </span> <sub><xsl:apply-templates select="denominator" /></sub> </xhtml> </template> <!-- Format a University paper code. These normally appear in the form "SPOD 123", i.e., a space between the subject code and the paper number. --> <template name="paper" match="paper"> <common> <xsl:apply-templates select="subject-code" /> <xsl:text> </xsl:text> <xsl:apply-templates select="paper-number" /> </common> </template> <template name="subject-code" match="paper/subject-code"> <common><xsl:apply-templates /></common> </template> <template name="paper-number" match="paper/paper-number"> <common><xsl:apply-templates /></common> </template> <!-- Create a layout of multiple columns across the page. By default, columns are of equal width, but may be varied on a column-by-column basis. Each column is totally independent of the others, i.e., you can't have text automatically flowing from one column to the next (yet). @vspace: The amount of vertical space to put around the multi-column elements. [small, medium, big, LaTeX length, NONE] @align: Overall alignment of the columns (only relevant if the total width of the columns is less than the page width). [LEFT, center, right] @width: Total width of the column set, expressed as a fraction of the usable page width between 0 and 1 (this will be multiplied by 100 for HTML). Individual column widths are then expressed as a fraction of this total width. [default is 1] --> <template name="multi-column" match="multi-column"> <common formats="/latex/xelatex/"> <xsl:variable name="total-width"> <xsl:value-of select="1" /> <xsl:if test="@width"><xsl:value-of select="@width" /></xsl:if> </xsl:variable> <xsl:choose> <xsl:when test="@vspace = 'small'">\smallskip</xsl:when> <xsl:when test="@vspace = 'medium'">\medskip</xsl:when> <xsl:when test="@vspace = 'big'">\bigskip</xsl:when> <xsl:when test="@vspace">\vskip<xsl:value-of select="@vspace" /></xsl:when> </xsl:choose> \noindent <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates> <xsl:with-param name="default-width"> <xsl:value-of select="format-number($total-width div count(column),'0.00')" /> </xsl:with-param> </xsl:apply-templates> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:choose> <xsl:when test="@vspace = 'small'">\smallskip</xsl:when> <xsl:when test="@vspace = 'medium'">\medskip</xsl:when> <xsl:when test="@vspace = 'big'">\bigskip</xsl:when> <xsl:when test="@vspace">\vskip<xsl:value-of select="@vspace" /></xsl:when> </xsl:choose> </common> <common formats="/html/xhtml/"> <xsl:variable name="total-width"> <xsl:value-of select="100" /> <xsl:if test="@width"><xsl:value-of select="@width * 100" /></xsl:if> </xsl:variable> <xsl:if test="@vspace"><br /></xsl:if> <table border="0" width="{$total-width}%"> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <tr> <xsl:apply-templates> <xsl:with-param name="default-width"> <xsl:value-of select="round($total-width div count(column))" /> </xsl:with-param> </xsl:apply-templates> </tr> </table> <xsl:if test="@vspace"><br /></xsl:if> </common> </template> <!-- A column within a multi-column element. $default-width: The default width of the column, expressed as a fraction of the total column set width. This is calculated by the <multi-column> template and should be 1/n of the column set width, where n is the number of columns. @width: The width of this particular column (overrides the default). This should be expressed as a fraction between 0 and 1 (which is then multipled by 100 for HTML). Make sure that all widths add up! @align: How each individual column is to be aligned internally. --> <template name="multi-column-column" match="multi-column/column"> <common formats="/latex/xelatex/"> <xsl:param name="default-width">1</xsl:param> <xsl:text>\begin{minipage}{</xsl:text> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width" /></xsl:when> <xsl:otherwise><xsl:value-of select="$default-width" /></xsl:otherwise> </xsl:choose> <xsl:text>\columnwidth}</xsl:text> <xsl:if test="@align"> <xsl:text>\begin{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:apply-templates /> <xsl:if test="@align"> <xsl:text>\end{</xsl:text> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> <xsl:text>flush</xsl:text><xsl:value-of select="@align" /> </xsl:when> <xsl:when test="(@align = 'center') or (@align = 'centre')"> <xsl:text>center</xsl:text> </xsl:when> </xsl:choose> <xsl:text>}</xsl:text> </xsl:if> <xsl:text>\end{minipage}</xsl:text> </common> <common formats="/html/xhtml/"> <xsl:param name="default-width">100</xsl:param> <td> <xsl:attribute name="width"> <xsl:choose> <xsl:when test="@width"><xsl:value-of select="@width * 100" /></xsl:when> <xsl:otherwise><xsl:value-of select="$default-width" /></xsl:otherwise> </xsl:choose> <xsl:text>%</xsl:text> </xsl:attribute> <xsl:if test="@align"> <xsl:attribute name="align"> <xsl:value-of select="@align" /> </xsl:attribute> </xsl:if> <xsl:apply-templates /> </td> </common> </template> <!-- Center stuff on the page. --> <template name="center" match="center|centering|centre|centring"> <common formats="/latex/xelatex/"> \begin{center} <xsl:apply-templates /> \end{center} </common> <common formats="/html/xhtml/"> <div style="text-align: center;"> <xsl:apply-templates /> </div> </common> </template> <!-- Simple numbered bibliographies and reference lists (equivalent to LaTeX "plain" style biblipgraphies). We could go the whole hog and try to do something BibTeX-like, but I can't be bothered :) This is essentially similar to manually creating a LaTeX bibliography, so it's up to the writer to ensure that items are correctly sorted and formatted. An important point to note is that all items will be included, regardless of whether they are cited or not. This should suffice for most of what we want to do for teaching, though. @name: The name of the section as it should appear in print. "References" is used if not specified. --> <template name="bibliography" match="bibliography"> <common formats="/latex/xelatex/"> <xsl:if test="@name"> \renewcommand{\refname}{<xsl:value-of select="@name" />} </xsl:if> \bibliographystyle{plain} \begin{thebibliography}{99} <xsl:apply-templates /> \end{thebibliography} </common> <common formats="/html/xhtml/"> <h1> <xsl:value-of select="@name" /> <xsl:if test="not(@name)">References</xsl:if> </h1> <ol> <xsl:apply-templates /> </ol> </common> </template> <!-- An item within a bibliography. @label: The unique label of the bibliography item, so it can be cited. [REQUIRED] --> <template name="bibitem" match="bibliography/item"> <common formats="/latex/xelatex/">\bibitem{<xsl:value-of select="@label" />} <xsl:apply-templates /></common> <common formats="/html/xhtml/"> <li><a id="{@label}"></a><xsl:apply-templates /></li> </common> </template> <!-- A citation. To cater for multiple cited items, the items are specified using nested <item> elements rather than a "label" attribute. There must be at least one item. Each item must have a "label" attribute. --> <template name="citation" match="cite"> <common formats="/latex/xelatex/">\cite{<xsl:apply-templates select="item" />}</common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <xsl:text> [</xsl:text> <xsl:apply-templates select="item" /> <xsl:text>]</xsl:text> </common> </template> <!-- A cited item. @label: The unique label of the cited item. [REQUIRED] --> <template name="citation-item" match="cite/item"> <common formats="/latex/xelatex/"> <xsl:value-of select="@label" /> <xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if> </common> <common formats="/html/xhtml/"> <xsl:variable name="id"> <xsl:value-of select="@label" /> </xsl:variable> <a href="#{@label}"><xsl:value-of select="1 + count(//bibliography/item[@label = $id]/preceding-sibling::*)" /></a> <xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if> </common> </template> <!-- Format numbers. --> <include href="modules/number-formatting.xml" /> </stylesheet>
Ignore Space
Show notes
View
modules/generate-greek.php
0 → 100755
<?php // Quick and dirty, but it does the job! $char_data = array( // Unicode name (lower case), char, U+xxxx, LaTeX, XSLT template match, Unicode name (upper case), char, U+xxxx, LaTeX, XSLT template match, "alpha" => array( "GREEK SMALL LETTER ALPHA", "α", "03B1", "\\alpha", "greek-small-letter-alpha", "GREEK CAPITAL LETTER ALPHA", "Α", "0391", "A", "greek-capital-letter-alpha" ), "beta" => array( "GREEK SMALL LETTER BETA", "β", "03B2", "\\beta", "greek-small-letter-beta", "GREEK CAPITAL LETTER BETA", "Β", "0392", "B", "greek-capital-letter-beta" ), "gamma" => array( "GREEK SMALL LETTER GAMMA", "γ", "03B3", "\\gamma", "greek-small-letter-gamma", "GREEK CAPITAL LETTER GAMMA", "Γ", "0393", "\\Gamma", "greek-capital-letter-gamma" ), "delta" => array( "GREEK SMALL LETTER DELTA", "δ", "03B4", "\\delta", "greek-small-letter-delta", "GREEK CAPITAL LETTER DELTA", "Δ", "0394", "\\Delta", "greek-capital-letter-delta" ), "epsilon" => array( "GREEK SMALL LETTER EPSILON", "ε", "03B5", "\\varepsilon", "greek-small-letter-epsilon", "GREEK CAPITAL LETTER EPSILON", "Ε", "0395", "E", "greek-capital-letter-epsilon" ), "zeta" => array( "GREEK SMALL LETTER ZETA", "ζ", "03B6", "\\zeta", "greek-small-letter-zeta", "GREEK CAPITAL LETTER ZETA", "Ζ", "0396", "Z", "greek-capital-letter-zeta" ), "eta" => array( "GREEK SMALL LETTER ETA", "η", "03B7", "\\eta", "greek-small-letter-eta", "GREEK CAPITAL LETTER ETA", "Η", "0397", "H", "greek-capital-letter-eta" ), "theta" => array( "GREEK SMALL LETTER THETA", "θ", "03B8", "\\theta", "greek-small-letter-theta", "GREEK CAPITAL LETTER THETA", "Θ", "0398", "\\Theta", "greek-capital-letter-theta" ), "iota" => array( "GREEK SMALL LETTER IOTA", "ι", "03B9", "\\iota", "greek-small-letter-iota", "GREEK CAPITAL LETTER IOTA", "Ι", "0399", "I", "greek-capital-letter-iota" ), "kappa" => array( "GREEK SMALL LETTER KAPPA", "κ", "03BA", "\\kappa", "greek-small-letter-kappa", "GREEK CAPITAL LETTER KAPPA", "Κ", "039A", "K", "greek-capital-letter-kappa" ), "lambda" => array( "GREEK SMALL LETTER LAMBDA", "λ", "03BB", "\\lambda", "greek-small-letter-lambda", "GREEK CAPITAL LETTER LAMBDA", "Λ", "039B", "\\Lambda", "greek-capital-letter-lambda" ), "mu" => array( "GREEK SMALL LETTER MU", "μ", "03BC", "\\mu", "greek-small-letter-mu", "GREEK CAPITAL LETTER MU", "Μ", "039C", "M", "greek-capital-letter-mu" ), "nu" => array( "GREEK SMALL LETTER NU", "ν", "03BD", "\\nu", "greek-small-letter-nu", "GREEK CAPITAL LETTER NU", "Ν", "039D", "N", "greek-capital-letter-nu" ), "xi" => array( "GREEK SMALL LETTER XI", "ξ", "03BE", "\\xi", "greek-small-letter-xi", "GREEK CAPITAL LETTER XI", "Ξ", "039E", "\\Xi", "greek-capital-letter-xi" ), "omicron" => array( "GREEK SMALL LETTER OMICRON", "ο", "03BF", "o", "greek-small-letter-omicron", "GREEK CAPITAL LETTER OMICRON", "Ο", "039F", "O", "greek-capital-letter-omicron" ), "pi" => array( "GREEK SMALL LETTER PI", "π", "03C0", "\\pi", "greek-small-letter-pi", "GREEK CAPITAL LETTER PI", "Π", "03A0", "\\Pi", "greek-capital-letter-pi" ), "rho" => array( "GREEK SMALL LETTER RHO", "ρ", "03C1", "\\rho", "greek-small-letter-rho", "GREEK CAPITAL LETTER RHO", "Ρ", "03A1", "P", "greek-capital-letter-rho" ), "sigma" => array( "GREEK SMALL LETTER SIGMA", "σ", "03C2", "\\sigma", "greek-small-letter-sigma", "GREEK CAPITAL LETTER SIGMA", "Σ", "03A3", "\\Sigma", "greek-capital-letter-sigma" ), "tau" => array( "GREEK SMALL LETTER TAU", "τ", "03C4", "\\tau", "greek-small-letter-tau", "GREEK CAPITAL LETTER TAU", "Τ", "03A4", "T", "greek-capital-letter-tau" ), "upsilon" => array( "GREEK SMALL LETTER UPSILON", "υ", "03C5", "\\upsilon", "greek-small-letter-upsilon", "GREEK CAPITAL LETTER UPSILON", "Υ", "03A5", "\\Upsilon", "greek-capital-letter-upsilon" ), "phi" => array( "GREEK PHI SYMBOL", "ϕ", "03C6", "\\phi", "greek-phi-symbol", "GREEK CAPITAL LETTER PHI", "Φ", "03A6", "\\Phi", "greek-capital-letter-phi" ), "chi" => array( "GREEK SMALL LETTER CHI", "χ", "03C7", "\\chi", "greek-small-letter-chi", "GREEK CAPITAL LETTER CHI", "Χ", "03A7", "X", "greek-capital-letter-chi" ), "psi" => array( "GREEK SMALL LETTER PSI", "ψ", "03C8", "\\psi", "greek-small-letter-psi", "GREEK CAPITAL LETTER PSI", "Ψ", "03A8", "\\Psi", "greek-capital-letter-psi" ), "omega" => array( "GREEK SMALL LETTER OMEGA", "ω", "03C9", "\\omega", "greek-small-letter-omega", "GREEK CAPITAL LETTER OMEGA", "Ω", "03A9", "\\Omega", "greek-capital-letter-omega" ), ); foreach ( $char_data as $name => $data ) { // The upper case HTML entity names have the first character capitalised. $upper_name = ucfirst( $name ); print <<<EOT <!-- Lower case {$name}. --> <template name="{$name}" match="{$name}|{$data[4]}"> <common formats="/latex/xelatex/">\\ensuremath{{$data[3]}}</common> <html><xsl:text disable-output-escaping="yes">&{$name};</xsl:text></html> <!-- U+{$data[2]} {$data[0]} --> <xhtml><span class="unicode"><xsl:text>{$data[1]}</xsl:text></span></xhtml> </template> <template name="{$name}-strip" match="{$name}|{$data[4]}" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="{$name}" /> </common> </template> <!-- Upper case {$name}. --> <template name="capital-{$name}" match="{$name}|{$data[9]}"> <common formats="/latex/xelatex/">\\ensuremath{{$data[8]}}</common> <html><xsl:text disable-output-escaping="yes">&{$upper_name};</xsl:text></html> <!-- U+{$data[7]} {$data[5]} --> <xhtml><span class="unicode"><xsl:text>{$data[6]}</xsl:text></span></xhtml> </template> <template name="capital-{$name}-strip" match="{$name}|{$data[9]}" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-{$name}" /> </common> </template> EOT; } ?>
Ignore Space
Show notes
View
modules/greek-characters.xml
0 → 100755
<?xml version="1.0" encoding="utf-8"?> <!-- Greek characters. The "strip" mode forms of the templates are for use in the context of an HTML <title> element (so the mode is only relevant to the HTML formats). Embedding HTML markup inside the <title> element causes the markup to appear verbatim in the window title, i.e., <title><em>foo</em> bar</title> will appear in the window title as "<em>foo</em> bar", not "foo bar". Putting the stylesheet into strip mode means that it will only output text nodes unless otherwise specified for a particular element. Generally the "strip" templates will simply call-template to the original, unless the original contains markup that needs to be eliminated (e.g., see space below). The downside of this approach, of course, is that you need "strip" mode templates for quite a lot of things, but that can't really be helped. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Lower case alpha. --> <template name="alpha" match="alpha|greek-small-letter-alpha"> <common formats="/latex/xelatex/">\ensuremath{\alpha}</common> <html><xsl:text disable-output-escaping="yes">&alpha;</xsl:text></html> <!-- U+03B1 GREEK SMALL LETTER ALPHA --> <xhtml><span class="unicode"><xsl:text>α</xsl:text></span></xhtml> </template> <template name="alpha-strip" match="alpha|greek-small-letter-alpha" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="alpha" /> </common> </template> <!-- Upper case alpha. --> <template name="capital-alpha" match="alpha|greek-capital-letter-alpha"> <common formats="/latex/xelatex/">\ensuremath{A}</common> <html><xsl:text disable-output-escaping="yes">&Alpha;</xsl:text></html> <!-- U+0391 GREEK CAPITAL LETTER ALPHA --> <xhtml><span class="unicode"><xsl:text>Α</xsl:text></span></xhtml> </template> <template name="capital-alpha-strip" match="alpha|greek-capital-letter-alpha" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-alpha" /> </common> </template> <!-- Lower case beta. --> <template name="beta" match="beta|greek-small-letter-beta"> <common formats="/latex/xelatex/">\ensuremath{\beta}</common> <html><xsl:text disable-output-escaping="yes">&beta;</xsl:text></html> <!-- U+03B2 GREEK SMALL LETTER BETA --> <xhtml><span class="unicode"><xsl:text>β</xsl:text></span></xhtml> </template> <template name="beta-strip" match="beta|greek-small-letter-beta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="beta" /> </common> </template> <!-- Upper case beta. --> <template name="capital-beta" match="beta|greek-capital-letter-beta"> <common formats="/latex/xelatex/">\ensuremath{B}</common> <html><xsl:text disable-output-escaping="yes">&Beta;</xsl:text></html> <!-- U+0392 GREEK CAPITAL LETTER BETA --> <xhtml><span class="unicode"><xsl:text>Β</xsl:text></span></xhtml> </template> <template name="capital-beta-strip" match="beta|greek-capital-letter-beta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-beta" /> </common> </template> <!-- Lower case gamma. --> <template name="gamma" match="gamma|greek-small-letter-gamma"> <common formats="/latex/xelatex/">\ensuremath{\gamma}</common> <html><xsl:text disable-output-escaping="yes">&gamma;</xsl:text></html> <!-- U+03B3 GREEK SMALL LETTER GAMMA --> <xhtml><span class="unicode"><xsl:text>γ</xsl:text></span></xhtml> </template> <template name="gamma-strip" match="gamma|greek-small-letter-gamma" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="gamma" /> </common> </template> <!-- Upper case gamma. --> <template name="capital-gamma" match="gamma|greek-capital-letter-gamma"> <common formats="/latex/xelatex/">\ensuremath{\Gamma}</common> <html><xsl:text disable-output-escaping="yes">&Gamma;</xsl:text></html> <!-- U+0393 GREEK CAPITAL LETTER GAMMA --> <xhtml><span class="unicode"><xsl:text>Γ</xsl:text></span></xhtml> </template> <template name="capital-gamma-strip" match="gamma|greek-capital-letter-gamma" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-gamma" /> </common> </template> <!-- Lower case delta. --> <template name="delta" match="delta|greek-small-letter-delta"> <common formats="/latex/xelatex/">\ensuremath{\delta}</common> <html><xsl:text disable-output-escaping="yes">&delta;</xsl:text></html> <!-- U+03B4 GREEK SMALL LETTER DELTA --> <xhtml><span class="unicode"><xsl:text>δ</xsl:text></span></xhtml> </template> <template name="delta-strip" match="delta|greek-small-letter-delta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="delta" /> </common> </template> <!-- Upper case delta. --> <template name="capital-delta" match="delta|greek-capital-letter-delta"> <common formats="/latex/xelatex/">\ensuremath{\Delta}</common> <html><xsl:text disable-output-escaping="yes">&Delta;</xsl:text></html> <!-- U+0394 GREEK CAPITAL LETTER DELTA --> <xhtml><span class="unicode"><xsl:text>Δ</xsl:text></span></xhtml> </template> <template name="capital-delta-strip" match="delta|greek-capital-letter-delta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-delta" /> </common> </template> <!-- Lower case epsilon. --> <template name="epsilon" match="epsilon|greek-small-letter-epsilon"> <common formats="/latex/xelatex/">\ensuremath{\varepsilon}</common> <html><xsl:text disable-output-escaping="yes">&epsilon;</xsl:text></html> <!-- U+03B5 GREEK SMALL LETTER EPSILON --> <xhtml><span class="unicode"><xsl:text>ε</xsl:text></span></xhtml> </template> <template name="epsilon-strip" match="epsilon|greek-small-letter-epsilon" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="epsilon" /> </common> </template> <!-- Upper case epsilon. --> <template name="capital-epsilon" match="epsilon|greek-capital-letter-epsilon"> <common formats="/latex/xelatex/">\ensuremath{E}</common> <html><xsl:text disable-output-escaping="yes">&Epsilon;</xsl:text></html> <!-- U+0395 GREEK CAPITAL LETTER EPSILON --> <xhtml><span class="unicode"><xsl:text>Ε</xsl:text></span></xhtml> </template> <template name="capital-epsilon-strip" match="epsilon|greek-capital-letter-epsilon" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-epsilon" /> </common> </template> <!-- Lower case zeta. --> <template name="zeta" match="zeta|greek-small-letter-zeta"> <common formats="/latex/xelatex/">\ensuremath{\zeta}</common> <html><xsl:text disable-output-escaping="yes">&zeta;</xsl:text></html> <!-- U+03B6 GREEK SMALL LETTER ZETA --> <xhtml><span class="unicode"><xsl:text>ζ</xsl:text></span></xhtml> </template> <template name="zeta-strip" match="zeta|greek-small-letter-zeta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="zeta" /> </common> </template> <!-- Upper case zeta. --> <template name="capital-zeta" match="zeta|greek-capital-letter-zeta"> <common formats="/latex/xelatex/">\ensuremath{Z}</common> <html><xsl:text disable-output-escaping="yes">&Zeta;</xsl:text></html> <!-- U+0396 GREEK CAPITAL LETTER ZETA --> <xhtml><span class="unicode"><xsl:text>Ζ</xsl:text></span></xhtml> </template> <template name="capital-zeta-strip" match="zeta|greek-capital-letter-zeta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-zeta" /> </common> </template> <!-- Lower case eta. --> <template name="eta" match="eta|greek-small-letter-eta"> <common formats="/latex/xelatex/">\ensuremath{\eta}</common> <html><xsl:text disable-output-escaping="yes">&eta;</xsl:text></html> <!-- U+03B7 GREEK SMALL LETTER ETA --> <xhtml><span class="unicode"><xsl:text>η</xsl:text></span></xhtml> </template> <template name="eta-strip" match="eta|greek-small-letter-eta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="eta" /> </common> </template> <!-- Upper case eta. --> <template name="capital-eta" match="eta|greek-capital-letter-eta"> <common formats="/latex/xelatex/">\ensuremath{H}</common> <html><xsl:text disable-output-escaping="yes">&Eta;</xsl:text></html> <!-- U+0397 GREEK CAPITAL LETTER ETA --> <xhtml><span class="unicode"><xsl:text>Η</xsl:text></span></xhtml> </template> <template name="capital-eta-strip" match="eta|greek-capital-letter-eta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-eta" /> </common> </template> <!-- Lower case theta. --> <template name="theta" match="theta|greek-small-letter-theta"> <common formats="/latex/xelatex/">\ensuremath{\theta}</common> <html><xsl:text disable-output-escaping="yes">&theta;</xsl:text></html> <!-- U+03B8 GREEK SMALL LETTER THETA --> <xhtml><span class="unicode"><xsl:text>θ</xsl:text></span></xhtml> </template> <template name="theta-strip" match="theta|greek-small-letter-theta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="theta" /> </common> </template> <!-- Upper case theta. --> <template name="capital-theta" match="theta|greek-capital-letter-theta"> <common formats="/latex/xelatex/">\ensuremath{\Theta}</common> <html><xsl:text disable-output-escaping="yes">&Theta;</xsl:text></html> <!-- U+0398 GREEK CAPITAL LETTER THETA --> <xhtml><span class="unicode"><xsl:text>Θ</xsl:text></span></xhtml> </template> <template name="capital-theta-strip" match="theta|greek-capital-letter-theta" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-theta" /> </common> </template> <!-- Lower case iota. --> <template name="iota" match="iota|greek-small-letter-iota"> <common formats="/latex/xelatex/">\ensuremath{\iota}</common> <html><xsl:text disable-output-escaping="yes">&iota;</xsl:text></html> <!-- U+03B9 GREEK SMALL LETTER IOTA --> <xhtml><span class="unicode"><xsl:text>ι</xsl:text></span></xhtml> </template> <template name="iota-strip" match="iota|greek-small-letter-iota" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="iota" /> </common> </template> <!-- Upper case iota. --> <template name="capital-iota" match="iota|greek-capital-letter-iota"> <common formats="/latex/xelatex/">\ensuremath{I}</common> <html><xsl:text disable-output-escaping="yes">&Iota;</xsl:text></html> <!-- U+0399 GREEK CAPITAL LETTER IOTA --> <xhtml><span class="unicode"><xsl:text>Ι</xsl:text></span></xhtml> </template> <template name="capital-iota-strip" match="iota|greek-capital-letter-iota" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-iota" /> </common> </template> <!-- Lower case kappa. --> <template name="kappa" match="kappa|greek-small-letter-kappa"> <common formats="/latex/xelatex/">\ensuremath{\kappa}</common> <html><xsl:text disable-output-escaping="yes">&kappa;</xsl:text></html> <!-- U+03BA GREEK SMALL LETTER KAPPA --> <xhtml><span class="unicode"><xsl:text>κ</xsl:text></span></xhtml> </template> <template name="kappa-strip" match="kappa|greek-small-letter-kappa" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="kappa" /> </common> </template> <!-- Upper case kappa. --> <template name="capital-kappa" match="kappa|greek-capital-letter-kappa"> <common formats="/latex/xelatex/">\ensuremath{K}</common> <html><xsl:text disable-output-escaping="yes">&Kappa;</xsl:text></html> <!-- U+039A GREEK CAPITAL LETTER KAPPA --> <xhtml><span class="unicode"><xsl:text>Κ</xsl:text></span></xhtml> </template> <template name="capital-kappa-strip" match="kappa|greek-capital-letter-kappa" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-kappa" /> </common> </template> <!-- Lower case lambda. --> <template name="lambda" match="lambda|greek-small-letter-lambda"> <common formats="/latex/xelatex/">\ensuremath{\lambda}</common> <html><xsl:text disable-output-escaping="yes">&lambda;</xsl:text></html> <!-- U+03BB GREEK SMALL LETTER LAMBDA --> <xhtml><span class="unicode"><xsl:text>λ</xsl:text></span></xhtml> </template> <template name="lambda-strip" match="lambda|greek-small-letter-lambda" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="lambda" /> </common> </template> <!-- Upper case lambda. --> <template name="capital-lambda" match="lambda|greek-capital-letter-lambda"> <common formats="/latex/xelatex/">\ensuremath{\Lambda}</common> <html><xsl:text disable-output-escaping="yes">&Lambda;</xsl:text></html> <!-- U+039B GREEK CAPITAL LETTER LAMBDA --> <xhtml><span class="unicode"><xsl:text>Λ</xsl:text></span></xhtml> </template> <template name="capital-lambda-strip" match="lambda|greek-capital-letter-lambda" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-lambda" /> </common> </template> <!-- Lower case mu. --> <template name="mu" match="mu|greek-small-letter-mu"> <common formats="/latex/xelatex/">\ensuremath{\mu}</common> <html><xsl:text disable-output-escaping="yes">&mu;</xsl:text></html> <!-- U+03BC GREEK SMALL LETTER MU --> <xhtml><span class="unicode"><xsl:text>μ</xsl:text></span></xhtml> </template> <template name="mu-strip" match="mu|greek-small-letter-mu" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="mu" /> </common> </template> <!-- Upper case mu. --> <template name="capital-mu" match="mu|greek-capital-letter-mu"> <common formats="/latex/xelatex/">\ensuremath{M}</common> <html><xsl:text disable-output-escaping="yes">&Mu;</xsl:text></html> <!-- U+039C GREEK CAPITAL LETTER MU --> <xhtml><span class="unicode"><xsl:text>Μ</xsl:text></span></xhtml> </template> <template name="capital-mu-strip" match="mu|greek-capital-letter-mu" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-mu" /> </common> </template> <!-- Lower case nu. --> <template name="nu" match="nu|greek-small-letter-nu"> <common formats="/latex/xelatex/">\ensuremath{\nu}</common> <html><xsl:text disable-output-escaping="yes">&nu;</xsl:text></html> <!-- U+03BD GREEK SMALL LETTER NU --> <xhtml><span class="unicode"><xsl:text>ν</xsl:text></span></xhtml> </template> <template name="nu-strip" match="nu|greek-small-letter-nu" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="nu" /> </common> </template> <!-- Upper case nu. --> <template name="capital-nu" match="nu|greek-capital-letter-nu"> <common formats="/latex/xelatex/">\ensuremath{N}</common> <html><xsl:text disable-output-escaping="yes">&Nu;</xsl:text></html> <!-- U+039D GREEK CAPITAL LETTER NU --> <xhtml><span class="unicode"><xsl:text>Ν</xsl:text></span></xhtml> </template> <template name="capital-nu-strip" match="nu|greek-capital-letter-nu" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-nu" /> </common> </template> <!-- Lower case xi. --> <template name="xi" match="xi|greek-small-letter-xi"> <common formats="/latex/xelatex/">\ensuremath{\xi}</common> <html><xsl:text disable-output-escaping="yes">&xi;</xsl:text></html> <!-- U+03BE GREEK SMALL LETTER XI --> <xhtml><span class="unicode"><xsl:text>ξ</xsl:text></span></xhtml> </template> <template name="xi-strip" match="xi|greek-small-letter-xi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="xi" /> </common> </template> <!-- Upper case xi. --> <template name="capital-xi" match="xi|greek-capital-letter-xi"> <common formats="/latex/xelatex/">\ensuremath{\Xi}</common> <html><xsl:text disable-output-escaping="yes">&Xi;</xsl:text></html> <!-- U+039E GREEK CAPITAL LETTER XI --> <xhtml><span class="unicode"><xsl:text>Ξ</xsl:text></span></xhtml> </template> <template name="capital-xi-strip" match="xi|greek-capital-letter-xi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-xi" /> </common> </template> <!-- Lower case omicron. --> <template name="omicron" match="omicron|greek-small-letter-omicron"> <common formats="/latex/xelatex/">\ensuremath{o}</common> <html><xsl:text disable-output-escaping="yes">&omicron;</xsl:text></html> <!-- U+03BF GREEK SMALL LETTER OMICRON --> <xhtml><span class="unicode"><xsl:text>ο</xsl:text></span></xhtml> </template> <template name="omicron-strip" match="omicron|greek-small-letter-omicron" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="omicron" /> </common> </template> <!-- Upper case omicron. --> <template name="capital-omicron" match="omicron|greek-capital-letter-omicron"> <common formats="/latex/xelatex/">\ensuremath{O}</common> <html><xsl:text disable-output-escaping="yes">&Omicron;</xsl:text></html> <!-- U+039F GREEK CAPITAL LETTER OMICRON --> <xhtml><span class="unicode"><xsl:text>Ο</xsl:text></span></xhtml> </template> <template name="capital-omicron-strip" match="omicron|greek-capital-letter-omicron" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-omicron" /> </common> </template> <!-- Lower case pi. --> <template name="pi" match="pi|greek-small-letter-pi"> <common formats="/latex/xelatex/">\ensuremath{\pi}</common> <html><xsl:text disable-output-escaping="yes">&pi;</xsl:text></html> <!-- U+03C0 GREEK SMALL LETTER PI --> <xhtml><span class="unicode"><xsl:text>π</xsl:text></span></xhtml> </template> <template name="pi-strip" match="pi|greek-small-letter-pi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="pi" /> </common> </template> <!-- Upper case pi. --> <template name="capital-pi" match="pi|greek-capital-letter-pi"> <common formats="/latex/xelatex/">\ensuremath{\Pi}</common> <html><xsl:text disable-output-escaping="yes">&Pi;</xsl:text></html> <!-- U+03A0 GREEK CAPITAL LETTER PI --> <xhtml><span class="unicode"><xsl:text>Π</xsl:text></span></xhtml> </template> <template name="capital-pi-strip" match="pi|greek-capital-letter-pi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-pi" /> </common> </template> <!-- Lower case rho. --> <template name="rho" match="rho|greek-small-letter-rho"> <common formats="/latex/xelatex/">\ensuremath{\rho}</common> <html><xsl:text disable-output-escaping="yes">&rho;</xsl:text></html> <!-- U+03C1 GREEK SMALL LETTER RHO --> <xhtml><span class="unicode"><xsl:text>ρ</xsl:text></span></xhtml> </template> <template name="rho-strip" match="rho|greek-small-letter-rho" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="rho" /> </common> </template> <!-- Upper case rho. --> <template name="capital-rho" match="rho|greek-capital-letter-rho"> <common formats="/latex/xelatex/">\ensuremath{P}</common> <html><xsl:text disable-output-escaping="yes">&Rho;</xsl:text></html> <!-- U+03A1 GREEK CAPITAL LETTER RHO --> <xhtml><span class="unicode"><xsl:text>Ρ</xsl:text></span></xhtml> </template> <template name="capital-rho-strip" match="rho|greek-capital-letter-rho" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-rho" /> </common> </template> <!-- Lower case sigma. --> <template name="sigma" match="sigma|greek-small-letter-sigma"> <common formats="/latex/xelatex/">\ensuremath{\sigma}</common> <html><xsl:text disable-output-escaping="yes">&sigma;</xsl:text></html> <!-- U+03C2 GREEK SMALL LETTER SIGMA --> <xhtml><span class="unicode"><xsl:text>σ</xsl:text></span></xhtml> </template> <template name="sigma-strip" match="sigma|greek-small-letter-sigma" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="sigma" /> </common> </template> <!-- Upper case sigma. --> <template name="capital-sigma" match="sigma|greek-capital-letter-sigma"> <common formats="/latex/xelatex/">\ensuremath{\Sigma}</common> <html><xsl:text disable-output-escaping="yes">&Sigma;</xsl:text></html> <!-- U+03A3 GREEK CAPITAL LETTER SIGMA --> <xhtml><span class="unicode"><xsl:text>Σ</xsl:text></span></xhtml> </template> <template name="capital-sigma-strip" match="sigma|greek-capital-letter-sigma" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-sigma" /> </common> </template> <!-- Lower case tau. --> <template name="tau" match="tau|greek-small-letter-tau"> <common formats="/latex/xelatex/">\ensuremath{\tau}</common> <html><xsl:text disable-output-escaping="yes">&tau;</xsl:text></html> <!-- U+03C4 GREEK SMALL LETTER TAU --> <xhtml><span class="unicode"><xsl:text>τ</xsl:text></span></xhtml> </template> <template name="tau-strip" match="tau|greek-small-letter-tau" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="tau" /> </common> </template> <!-- Upper case tau. --> <template name="capital-tau" match="tau|greek-capital-letter-tau"> <common formats="/latex/xelatex/">\ensuremath{T}</common> <html><xsl:text disable-output-escaping="yes">&Tau;</xsl:text></html> <!-- U+03A4 GREEK CAPITAL LETTER TAU --> <xhtml><span class="unicode"><xsl:text>Τ</xsl:text></span></xhtml> </template> <template name="capital-tau-strip" match="tau|greek-capital-letter-tau" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-tau" /> </common> </template> <!-- Lower case upsilon. --> <template name="upsilon" match="upsilon|greek-small-letter-upsilon"> <common formats="/latex/xelatex/">\ensuremath{\upsilon}</common> <html><xsl:text disable-output-escaping="yes">&upsilon;</xsl:text></html> <!-- U+03C5 GREEK SMALL LETTER UPSILON --> <xhtml><span class="unicode"><xsl:text>υ</xsl:text></span></xhtml> </template> <template name="upsilon-strip" match="upsilon|greek-small-letter-upsilon" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="upsilon" /> </common> </template> <!-- Upper case upsilon. --> <template name="capital-upsilon" match="upsilon|greek-capital-letter-upsilon"> <common formats="/latex/xelatex/">\ensuremath{\Upsilon}</common> <html><xsl:text disable-output-escaping="yes">&Upsilon;</xsl:text></html> <!-- U+03A5 GREEK CAPITAL LETTER UPSILON --> <xhtml><span class="unicode"><xsl:text>Υ</xsl:text></span></xhtml> </template> <template name="capital-upsilon-strip" match="upsilon|greek-capital-letter-upsilon" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-upsilon" /> </common> </template> <!-- Lower case phi. --> <template name="phi" match="phi|greek-phi-symbol"> <common formats="/latex/xelatex/">\ensuremath{\phi}</common> <html><xsl:text disable-output-escaping="yes">&phi;</xsl:text></html> <!-- U+03C6 GREEK PHI SYMBOL --> <xhtml><span class="unicode"><xsl:text>ϕ</xsl:text></span></xhtml> </template> <template name="phi-strip" match="phi|greek-phi-symbol" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="phi" /> </common> </template> <!-- Upper case phi. --> <template name="capital-phi" match="phi|greek-capital-letter-phi"> <common formats="/latex/xelatex/">\ensuremath{\Phi}</common> <html><xsl:text disable-output-escaping="yes">&Phi;</xsl:text></html> <!-- U+03A6 GREEK CAPITAL LETTER PHI --> <xhtml><span class="unicode"><xsl:text>Φ</xsl:text></span></xhtml> </template> <template name="capital-phi-strip" match="phi|greek-capital-letter-phi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-phi" /> </common> </template> <!-- Lower case chi. --> <template name="chi" match="chi|greek-small-letter-chi"> <common formats="/latex/xelatex/">\ensuremath{\chi}</common> <html><xsl:text disable-output-escaping="yes">&chi;</xsl:text></html> <!-- U+03C7 GREEK SMALL LETTER CHI --> <xhtml><span class="unicode"><xsl:text>χ</xsl:text></span></xhtml> </template> <template name="chi-strip" match="chi|greek-small-letter-chi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="chi" /> </common> </template> <!-- Upper case chi. --> <template name="capital-chi" match="chi|greek-capital-letter-chi"> <common formats="/latex/xelatex/">\ensuremath{X}</common> <html><xsl:text disable-output-escaping="yes">&Chi;</xsl:text></html> <!-- U+03A7 GREEK CAPITAL LETTER CHI --> <xhtml><span class="unicode"><xsl:text>Χ</xsl:text></span></xhtml> </template> <template name="capital-chi-strip" match="chi|greek-capital-letter-chi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-chi" /> </common> </template> <!-- Lower case psi. --> <template name="psi" match="psi|greek-small-letter-psi"> <common formats="/latex/xelatex/">\ensuremath{\psi}</common> <html><xsl:text disable-output-escaping="yes">&psi;</xsl:text></html> <!-- U+03C8 GREEK SMALL LETTER PSI --> <xhtml><span class="unicode"><xsl:text>ψ</xsl:text></span></xhtml> </template> <template name="psi-strip" match="psi|greek-small-letter-psi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="psi" /> </common> </template> <!-- Upper case psi. --> <template name="capital-psi" match="psi|greek-capital-letter-psi"> <common formats="/latex/xelatex/">\ensuremath{\Psi}</common> <html><xsl:text disable-output-escaping="yes">&Psi;</xsl:text></html> <!-- U+03A8 GREEK CAPITAL LETTER PSI --> <xhtml><span class="unicode"><xsl:text>Ψ</xsl:text></span></xhtml> </template> <template name="capital-psi-strip" match="psi|greek-capital-letter-psi" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-psi" /> </common> </template> <!-- Lower case omega. --> <template name="omega" match="omega|greek-small-letter-omega"> <common formats="/latex/xelatex/">\ensuremath{\omega}</common> <html><xsl:text disable-output-escaping="yes">&omega;</xsl:text></html> <!-- U+03C9 GREEK SMALL LETTER OMEGA --> <xhtml><span class="unicode"><xsl:text>ω</xsl:text></span></xhtml> </template> <template name="omega-strip" match="omega|greek-small-letter-omega" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="omega" /> </common> </template> <!-- Upper case omega. --> <template name="capital-omega" match="omega|greek-capital-letter-omega"> <common formats="/latex/xelatex/">\ensuremath{\Omega}</common> <html><xsl:text disable-output-escaping="yes">&Omega;</xsl:text></html> <!-- U+03A9 GREEK CAPITAL LETTER OMEGA --> <xhtml><span class="unicode"><xsl:text>Ω</xsl:text></span></xhtml> </template> <template name="capital-omega-strip" match="omega|greek-capital-letter-omega" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="capital-omega" /> </common> </template> </stylesheet>
Show line notes below