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
- Tweaked spacing of list items so that they look nicer. <DL>s still need work.
- Fixed figure & table numbering. - Enhanced image handling (added zoom capability).
master
OLD_GRAPHICS_HANDLING
1 parent
00a54f2
commit
792e8799d7646dbf7116f02ae2025537cd416748
nstanger
authored
on 19 Dec 2003
Patch
Showing
1 changed file
format-master.xml
Ignore Space
Show notes
View
format-master.xml
<?xml version="1.0"?> <!-- 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"> <hyperlink> <element>OraAdmin</element> <url>http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm</url> <label>test<!--<xsl:call-template name="OracleServer"/> Database Administrator<xsl:call-template name="apostrophe"/>s Guide--></label> </hyperlink> <template name="PaperCode" match="PaperCode"> <latex><xsl:value-of select="$department"/>~<xsl:value-of select="$paper"/></latex> <html> <xsl:value-of select="$department"/> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> <xsl:value-of select="$paper"/> </html> </template> <template name="OracleServer" match="OracleServer"> <latex>Oracle9\textit{i}</latex> <html>Oracle9<I>i</I></html> </template> <template name="paragraph" match="paragraph"> <latex><xsl:text> </xsl:text><xsl:if test="@indent = 'no'">\noindent </xsl:if><xsl:apply-templates/><xsl:text> </xsl:text></latex> <!-- 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. --> <html><P><xsl:apply-templates/></P></html> </template> <alias source="para" target="paragraph"/> <alias source="p" target="paragraph"/> <!-- 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"> <latex> \\</latex> <html><BR/></html> </template> <template name="page-break" match="page-break"> <latex>\newpage</latex> </template> <alias source="new-page" target="page-break"/> <template name="non-breaking-space" match="non-breaking-space"> <latex>~</latex> <html><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></html> </template> <alias source="nbsp" target="non-breaking-space"/> <!-- 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"> <latex>{\ldots}</latex> <html><xsl:text disable-output-escaping="yes">&#8230;</xsl:text></html> </template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <alias source="dots" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex>--</latex> <html><xsl:text disable-output-escaping="yes">&#8211;</xsl:text></html> </template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex>---</latex> <html><xsl:text disable-output-escaping="yes">&#8212;</xsl:text></html> </template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex>'</latex> <html><xsl:text disable-output-escaping="yes">&#8217;</xsl:text></html> </template> <template name="dollar" match="dollar"> <latex>\$</latex> <html>$</html> </template> <template name="percent-sign" match="percent-sign"> <latex>\%</latex> <html>%</html> </template> <template name="ampersand" match="ampersand"> <latex>\&</latex> <html><xsl:text disable-output-escaping="yes">&amp;</xsl:text></html> </template> <template name="trademark-sign" match="trademark-sign"> <latex>\texttrademark</latex> <html><xsl:text disable-output-escaping="yes">&#8482;</xsl:text></html> </template> <alias source="trademark" target="trademark-sign"/> <alias source="TM" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex>\copyright</latex> <html><xsl:text disable-output-escaping="yes">&#169;</xsl:text></html> </template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex>$^{\circ}$</latex> <html><xsl:text disable-output-escaping="yes">&#176;</xsl:text></html> </template> <alias source="degrees" target="degree-sign"/> <template name="section-sign" match="section-sign"> <latex>{\S}</latex> <html><xsl:text disable-output-escaping="yes">&#167;</xsl:text></html> </template> <template name="paragraph-sign" match="paragraph-sign"> <latex>{\P}</latex> <html><xsl:text disable-output-escaping="yes">&#182;</xsl:text></html> </template> <template name="pi" match="pi"> <latex>$\pi$</latex> <html><xsl:text disable-output-escaping="yes">&#960;</xsl:text></html> </template> <template name="LaTeX" match="LaTeX"> <latex>{\latex}</latex> <html>LaTeX</html> </template> <alias source="latex" target="LaTeX"/> <!-- Note: no equivalent of \triangleright in HTML, use right arrow instead. --> <template name="menu-separator" match="menu-separator"> <latex>$\triangleright$</latex> <html><xsl:text disable-output-escaping="yes">&#8594;</xsl:text></html> </template> <!-- Special styles --> <template name="emph" match="emph"> <latex>\emph{<xsl:apply-templates/>}</latex> <html><EM><xsl:apply-templates/></EM></html> </template> <template name="italic" match="italic"> <latex>\textit{<xsl:apply-templates/>}</latex> <html><I><xsl:apply-templates/></I></html> </template> <template name="strong" match="strong"> <latex>\textbf{<xsl:apply-templates/>}</latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <template name="bold" match="bold"> <latex>\textbf{<xsl:apply-templates/>}</latex> <html><B><xsl:apply-templates/></B></html> </template> <template name="term" match="term"> <latex>\term<xsl:apply-templates/>}</latex> <html><I CLASS="term"><xsl:apply-templates/></I></html> </template> <template name="foreign" match="foreign"> <latex>\foreign{<xsl:apply-templates/>}</latex> <html><I CLASS="foreign"><xsl:apply-templates/></I></html> </template> <template name="code" match="code"> <latex>\code{<xsl:apply-templates/>}</latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <template name="code-block" match="code-block"> <latex> \begin{verbatim} <xsl:apply-templates/> \end{verbatim} </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- Quoted text. Handles nested quotes correctly. --> <template name="single-quote" match="quote[@single='yes']"> <latex>`<xsl:apply-templates/>'</latex> <html> <xsl:text disable-output-escaping="yes">&#8216;</xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&#8217;</xsl:text> </html> </template> <template name="double-quote" match="quote"> <latex>``<xsl:apply-templates/>''</latex> <html> <xsl:text disable-output-escaping="yes">&#8220;</xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&#8221;</xsl:text> </html> </template> <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> <alias source="q" target="single-quote"/> <alias source="qq" target="double-quote"/> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list"> <latex> \begin{itemize} <xsl:apply-templates/> \end{itemize} </latex> <html> <UL> <xsl:apply-templates/> </UL> </html> </template> <alias source="itemize" target="itemised-list"/> <alias source="unordered-list" target="itemised-list"/> <alias source="bulleted-list" target="itemised-list"/> <alias source="bullet-list" target="itemised-list"/> <alias source="bullet-points" target="itemised-list"/> <!-- Ordered lists --> <template name="enumerated-list" match="enumerated-list"> <latex> \begin{enumerate} <xsl:apply-templates/> \end{enumerate} </latex> <html> <OL> <xsl:apply-templates/> </OL> </html> </template> <alias source="enumerate" target="enumerated-list"/> <alias source="ordered-list" target="enumerated-list"/> <alias source="numbered-list" target="enumerated-list"/> <!-- Definition or description lists. --> <template name="definition-list" match="definition-list"> <latex> \begin{description} <xsl:apply-templates/> \end{description} </latex> <html> <!-- Hmm, <DL>s in HTML tend to come out with the spacing a bit wrong (or maybe it's just my browser?). Might using a table be better? Messy if the keyword is long, though... --> <!-- <DL> --> <!-- <xsl:apply-templates/> --> <!-- </DL> --> <TABLE BORDER="0" CELLPADDING="10"> <xsl:apply-templates/> </TABLE> </html> </template> <alias source="description-list" target="definition-list"/> <!-- List elements --> <template name="item" match="item"> <latex>\item <xsl:apply-templates/></latex> <html> <xsl:choose> <xsl:when test="count(paragraph|para|p) != 0"> <LI><xsl:apply-templates/></LI> </xsl:when> <xsl:otherwise> <LI><P><xsl:apply-templates/></P></LI> </xsl:otherwise> </xsl:choose> </html> </template> <template name="definition-item" match="definition-list/item"> <latex>\item[<xsl:apply-templates select="keyword"/>] <xsl:apply-templates select="definition"/></latex> <html> <!-- <DT><P><xsl:apply-templates select="keyword"/></P></DT> --> <!-- <DD><xsl:apply-templates select="definition|description|discourse"/></DD> --> <TR VALIGN="TOP"> <TD><P><xsl:apply-templates select="keyword"/></P></TD> <TD><xsl:apply-templates select="definition|description|discourse"/></TD> </TR> </html> </template> <template name="keyword" match="keyword"> <latex><xsl:apply-templates/></latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <alias source="topic" target="keyword"/> <!-- 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"> <html> <xsl:choose> <xsl:when test="count(paragraph|para|p) != 0"> <xsl:apply-templates/> </xsl:when> <xsl:otherwise> <P><xsl:apply-templates/></P> </xsl:otherwise> </xsl:choose> </html> </template> <!-- Sections, subsections, subsubsections, ... --> <template name="section" match="section"> <latex> <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> </latex> <html> <xsl:if test="@label"><A NAME="{@label}"></A></xsl:if> <xsl:apply-templates/> </html> </template> <!-- Document preamble stuff: title, author, date. --> <template name="preamble-title" match="document/title" mode="preamble"> <latex>\title{<xsl:apply-templates/>}</latex> <html> <xsl:apply-templates/> </html> </template> <template name="preamble-author" match="document/author" mode="preamble"> <latex>\author{<xsl:apply-templates/>}</latex> </template> <template name="preamble-date" match="document/date" mode="preamble"> <latex>\date{<xsl:apply-templates/>}</latex> </template> <template name="document-title" match="document/title"> <!-- Need to do something sensible for LaTeX here. --> <latex><xsl:if test="$standalone = 'no'"></xsl:if></latex> <html> <H1><xsl:apply-templates/></H1> </html> </template> <template name="document-author" match="document/author"/> <template name="document-date" match="document/date"/> <!-- Generate some number of "sub" so we can produce, e.g., "subsubsection" for LaTeX. Parameter: $depth Meaning: the number of repetitions (0 <= $depth <= 2, but there's no need to do bounds checking at the upper end, because that's already dealt with in the "section-title" template below). --> <template name="generate-subs"> <latex> <xsl:param name="depth">1</xsl:param> <xsl:if test="$depth > 1"> <xsl:text>sub</xsl:text> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"><xsl:value-of select="$depth - 1"/></xsl:with-param> </xsl:call-template> </xsl:if> </latex> </template> <template name="section-title" match="section/title"> <latex> <xsl:param name="label"/> <xsl:text>\</xsl:text> <!-- Depth calculation for LaTeX hasn't been tested! --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"> <xsl:number value="count(ancestor::section)"/> <xsl:if test="count(ancestor::section) > 3">3</xsl:if> </xsl:with-param> </xsl:call-template> <xsl:text>section{</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> </latex> <html> <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> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1"/> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"></H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> </html> </template> <!-- A quotation. --> <template name="quotation" match="quotation"> <latex> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> \begin{flush<xsl:value-of select="@align"/>}\itshape <xsl:apply-templates/>\end{flush<xsl:value-of select="@align"/>} </xsl:when> <xsl:when test="@align = 'center'"> \begin{center}\itshape <xsl:apply-templates/>\end{center} </xsl:when> <xsl:otherwise> \begin{quote}\itshape <xsl:apply-templates/>\end{quote} </xsl:otherwise> </xsl:choose> </latex> <html> <P> <xsl:if test="@align"> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> </xsl:attribute> </xsl:if> <I><xsl:apply-templates/></I> </P> </html> </template> <!-- Anything inside an ID element is ignored completely. (More accurately, we pick bits out of it manually as required; it's only ignored by apply-templates.) --> <template name="id" match="id"/> <!-- Anything inside an OMIT element is also ignored completely. --> <template name="omit" match="omit"/> <!-- Tabular structures (LaTeX {tabular}, HTML <TABLE>). --> <template name="tabular" match="tabular"> <latex> <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'"> <xsl:text>center</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>flushleft</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> \begin{tabular}{<xsl:apply-templates select="columns"/>} <xsl:apply-templates select="tabular-header"/> <xsl:apply-templates select="tabular-body"/> <xsl:apply-templates select="tabular-footer"/> \end{tabular} <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'"> <xsl:text>center</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>flushleft</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </latex> <html> <TABLE> <xsl:attribute name="BORDER"> <xsl:value-of select="@border"/> <xsl:if test="not(@border)">0</xsl:if> </xsl:attribute> <xsl:if test="@align"> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> </xsl:attribute> </xsl:if> <!-- 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> </html> </template> <!-- Set left- or right-border to "|" to include a column separator. --> <template name="aligned-column" match="column[@align]"> <latex> <xsl:value-of select="@left-border"/> <xsl:value-of select="substring(@align, 1, 1)"/> <xsl:value-of select="@right-border"/> </latex> </template> <template name="unaligned-column" match="column[not(@align)]"> <latex> <xsl:value-of select="@left-border"/> <xsl:text>l</xsl:text> <xsl:value-of select="@right-border"/> </latex> </template> <template name="tabular-header" match="tabular-header"> <latex></latex> <html> <THEAD> <xsl:apply-templates/> </THEAD> </html> </template> <template name="tabular-footer" match="tabular-footer"> <latex></latex> <html> <TFOOT> <xsl:apply-templates/> </TFOOT> </html> </template> <template name="tabular-body" match="tabular-body"> <latex><xsl:apply-templates/></latex> <html> <TBODY> <xsl:apply-templates/> </TBODY> </html> </template> <template name="row" match="row"> <latex><xsl:apply-templates/> \\<xsl:if test="@no-page-break = 'yes'">*</xsl:if><xsl:text> </xsl:text></latex> <html> <TR> <xsl:apply-templates/> </TR> </html> </template> <template name="row-rule-full" match="row-rule[not(@columns)]"> <latex>\hline</latex> </template> <template name="row-rule-partial" match="row-rule[@columns]"> <latex>\cline{<xsl:value-of select="@columns"/>}</latex> </template> <template match="cell" mode="multi-row"> <latex> <xsl:text>\multirow{</xsl:text> <xsl:value-of select="@rows"/> <xsl:text>}{*}{</xsl:text> <xsl:apply-templates/> <xsl:text>}</xsl:text> </latex> </template> <template match="cell" mode="multi-column"> <latex> <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="@align"/> </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:apply-templates/> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </latex> </template> <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 :) --> <latex> <xsl:choose> <xsl:when test="@columns"> <xsl:apply-templates select="." mode="multi-column"> <xsl:with-param name="num-columns" select="@columns"/> </xsl:apply-templates> </xsl:when> <xsl:when test="@align"> <xsl:apply-templates select="." mode="multi-column"/> </xsl:when> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="multi-row"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> <xsl:if test="$column-no != last()"> & </xsl:if> </latex> <!-- It's much easier in HTML, because a <TD> is a <TD> is a <TD>, regardless of the attributes supplied. --> <html> <TD> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> <xsl:if test="not(@align)"> <xsl:value-of select="ancestor::tabular/columns/column[position() = $column-no]/@align"/> <xsl:if test="not(ancestor::tabular/columns/column[position() = $column-no]/@align)">left</xsl:if> </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/> </TD> </html> </template> <!-- Hyperlinks. --> <template name="hyperlink-label" match="hyperlink[@label]"> <latex>\hyperref[<xsl:value-of select="@label"/>]{<xsl:apply-templates/>}</latex> <html><A HREF="#{@label}"><xsl:apply-templates/></A></html> </template> <template name="hyperlink-url" match="hyperlink[@url and node()]"> <latex>\href{<xsl:value-of select="@url"/>}{<xsl:apply-templates/>}</latex> <html><A HREF="{@url}"><xsl:apply-templates/></A></html> </template> <!-- An empty <hyperlink> element with a URL defaults to the URL as the link text. --> <template name="empty-hyperlink-url" match="hyperlink[@url and not(node())]"> <!-- Maybe we should be using the url package and \url{...}? --> <latex>\href{<xsl:value-of select="@url"/>}{\texttt{<xsl:value-of select="@url"/>}}</latex> <html><A HREF="{@url}"><CODE><xsl:value-of select="@url"/></CODE></A></html> </template> <!-- A plain URL. --> <template name="url" match="url"> <!-- Maybe we should be using the url package and \url{...}? --> <latex>\texttt{<xsl:apply-templates/>}</latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <alias source="uri" target="url"/> <alias source="email" target="url"/> <alias source="email-address" target="url"/> <!-- References. --> <template name="reference" match="reference"> <common> <!-- Find the element whose label is the same as our label. --> <xsl:apply-templates select="//*[@label = current()/@label]" mode="reference"/> </common> </template> <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. --> <latex>Section~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Section&#160;</xsl:text> <xsl:number count="figure" level="multiple" format="1.1.1.1.1.1"/> </html> </template> <template name="figure-reference" match="figure" mode="reference"> <latex>Figure~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Figure&#160;</xsl:text> <xsl:number count="figure" level="any" format="1"/> </html> </template> <template name="table-reference" match="table" mode="reference"> <latex>Table~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Table&#160;</xsl:text> <xsl:number count="table" level="any" format="1"/> </html> </template> <!-- Figures & tables. --> <template name="figure" match="figure"> <latex> \begin{figure} \centering <xsl:apply-templates select="*[not(self::caption)]"/> <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{figure} </latex> <html> <DIV CLASS="figure"> <xsl:if test="@label"><A NAME="{@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> </html> </template> <template name="table" match="table"> <latex> \begin{table} \centering <xsl:apply-templates select="*[not(self::caption)]"/> <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} </latex> <html> <DIV CLASS="table"> <xsl:if test="@label"><A NAME="{@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> </html> </template> <template name="figure-caption" match="figure/caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Figure <xsl:number count="figure" level="any" format="1"/>. </STRONG><xsl:apply-templates/> </html> </template> <template name="table-caption" match="table/caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Table <xsl:number count="table" level="any" format="1"/>. </STRONG><xsl:apply-templates/> </html> </template> <!-- Images. Includes a scaling factor for LaTeX. --> <!-- LaTeX images are always handled the same way regardless. --> <template match="image" mode="latex"> <latex> <xsl:text>\includegraphics</xsl:text> <xsl:if test="count(latex-scaling) != 0"> <xsl:text>[scale=</xsl:text> <xsl:value-of select="latex-scaling"/> <xsl:text>]</xsl:text> </xsl:if> <xsl:text>{images/</xsl:text> <xsl:value-of select="basename"/> <xsl:text>.</xsl:text> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:value-of select="format"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$image-format"/> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </latex> </template> <template match="image[count(provide-large-version) = 0]"> <latex><xsl:apply-templates select="." mode="latex"/></latex> <html> <IMG BORDER="0"> <xsl:attribute name="SRC"> <xsl:text>images/</xsl:text> <xsl:value-of select="basename"/> <xsl:text>.</xsl:text> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:value-of select="format"/> </xsl:when> <xsl:otherwise> <xsl:text>png</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:attribute name="ALT"><xsl:apply-templates select="description"/></xsl:attribute> </IMG> </html> </template> <template match="image[count(provide-large-version) != 0]"> <latex><xsl:apply-templates select="." mode="latex"/></latex> <html> <A> <xsl:attribute name="HREF"> <xsl:text>images/</xsl:text> <xsl:value-of select="basename"/> <xsl:text>-zoom.</xsl:text> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:value-of select="format"/> </xsl:when> <xsl:otherwise> <xsl:text>png</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:attribute> <IMG BORDER="0"> <xsl:attribute name="SRC"> <xsl:text>images/</xsl:text> <xsl:value-of select="basename"/> <xsl:text>.</xsl:text> <xsl:choose> <xsl:when test="count(format) != 0"> <xsl:value-of select="format"/> </xsl:when> <xsl:otherwise> <xsl:text>png</xsl:text> </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> </html> </template> <!-- Include another document into the current one. The @inline attribute specifies whether the document is to be included inline (note that this really only makes sense for HTML). Possible values: yes, no (default no). If the document is not inlined, then an appropriate link to the document is generated. Inlined files must be document fragments, not standalone documents! Currently somewhat broken. Needs more work. --> <template name="include-noinline" match="include-document[not(@inline) or (@inline = 'no')]"> <latex>\input{<xsl:value-of select="@basename"/>}</latex> <html> <P><A> <xsl:attribute name="HREF"> <xsl:value-of select="@baseurl"/> <xsl:value-of select="@basename"/> <xsl:text>.html</xsl:text> </xsl:attribute> <xsl:apply-templates/> </A></P> </html> </template> <template name="include-inline" match="include-document[@inline = 'yes']"> <latex>\input{<xsl:value-of select="@basename"/>}</latex> <html><xsl:copy-of select="document(concat(@basename, '.html'))/html/body/*"/></html> </template> <!-- Environment setup. This enables you to load environment settings (e.g., required LaTeX packages, etc.) from an external configuration file. The master style sheet automatically loads a file called "environment.xml"; you don't need to do anything for this file to be loaded. Multiple configuration files may be loaded, as long as they all have different names. --> <template name="environment-file" match="environment[@file]"> <xsl:apply-templates select="document(@file)/environment/*"/> </template> <template name="latex-package" match="latex-packages/package"> <latex>\usepackage<xsl:if test="@options">[<xsl:value-of select="@options"/>]</xsl:if>{<xsl:value-of select="."/>}</latex> </template> <template name="latex-command" match="latex-packages/command"> <latex><xsl:value-of select="."/></latex> </template> <!-- Sometimes we might need to embed raw code to handle something tricky. --> <template name="raw-latex" match="raw-code[@format = 'latex']"> <latex><xsl:apply-templates/></latex> </template> <template name="raw-html" match="raw-code[@format = 'html']"> <html><xsl:copy-of select="*"/></html> </template> </stylesheet>
<?xml version="1.0"?> <!-- 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"> <hyperlink> <element>OraAdmin</element> <url>http://info-nts-05.otago.ac.nz/docs/oracle9i/server.920/a96521/toc.htm</url> <label>test<!--<xsl:call-template name="OracleServer"/> Database Administrator<xsl:call-template name="apostrophe"/>s Guide--></label> </hyperlink> <template name="PaperCode" match="PaperCode"> <latex><xsl:value-of select="$department"/>~<xsl:value-of select="$paper"/></latex> <html> <xsl:value-of select="$department"/> <xsl:text disable-output-escaping="yes">&nbsp;</xsl:text> <xsl:value-of select="$paper"/> </html> </template> <template name="OracleServer" match="OracleServer"> <latex>Oracle9\textit{i}</latex> <html>Oracle9<I>i</I></html> </template> <template name="paragraph" match="paragraph"> <latex><xsl:text> </xsl:text><xsl:if test="@indent = 'no'">\noindent </xsl:if><xsl:apply-templates/><xsl:text> </xsl:text></latex> <!-- 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. --> <html><P><xsl:apply-templates/></P></html> </template> <alias source="para" target="paragraph"/> <alias source="p" target="paragraph"/> <!-- 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"> <latex> \\</latex> <html><BR/></html> </template> <template name="page-break" match="page-break"> <latex>\newpage</latex> </template> <alias source="new-page" target="page-break"/> <template name="non-breaking-space" match="non-breaking-space"> <latex>~</latex> <html><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></html> </template> <alias source="nbsp" target="non-breaking-space"/> <!-- 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"> <latex>{\ldots}</latex> <html><xsl:text disable-output-escaping="yes">&#8230;</xsl:text></html> </template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <alias source="dots" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex>--</latex> <html><xsl:text disable-output-escaping="yes">&#8211;</xsl:text></html> </template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex>---</latex> <html><xsl:text disable-output-escaping="yes">&#8212;</xsl:text></html> </template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex>'</latex> <html><xsl:text disable-output-escaping="yes">&#8217;</xsl:text></html> </template> <template name="dollar" match="dollar"> <latex>\$</latex> <html>$</html> </template> <template name="percent-sign" match="percent-sign"> <latex>\%</latex> <html>%</html> </template> <template name="ampersand" match="ampersand"> <latex>\&</latex> <html><xsl:text disable-output-escaping="yes">&amp;</xsl:text></html> </template> <template name="trademark-sign" match="trademark-sign"> <latex>\texttrademark</latex> <html><xsl:text disable-output-escaping="yes">&#8482;</xsl:text></html> </template> <alias source="trademark" target="trademark-sign"/> <alias source="TM" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex>\copyright</latex> <html><xsl:text disable-output-escaping="yes">&#169;</xsl:text></html> </template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex>$^{\circ}$</latex> <html><xsl:text disable-output-escaping="yes">&#176;</xsl:text></html> </template> <alias source="degrees" target="degree-sign"/> <template name="section-sign" match="section-sign"> <latex>{\S}</latex> <html><xsl:text disable-output-escaping="yes">&#167;</xsl:text></html> </template> <template name="paragraph-sign" match="paragraph-sign"> <latex>{\P}</latex> <html><xsl:text disable-output-escaping="yes">&#182;</xsl:text></html> </template> <template name="pi" match="pi"> <latex>$\pi$</latex> <html><xsl:text disable-output-escaping="yes">&#960;</xsl:text></html> </template> <template name="LaTeX" match="LaTeX"> <latex>{\latex}</latex> <html>LaTeX</html> </template> <alias source="latex" target="LaTeX"/> <!-- Note: no equivalent of \triangleright in HTML, use right arrow instead. --> <template name="menu-separator" match="menu-separator"> <latex>$\triangleright$</latex> <html><xsl:text disable-output-escaping="yes">&#8594;</xsl:text></html> </template> <!-- Special styles --> <template name="emph" match="emph"> <latex>\emph{<xsl:apply-templates/>}</latex> <html><EM><xsl:apply-templates/></EM></html> </template> <template name="italic" match="italic"> <latex>\textit{<xsl:apply-templates/>}</latex> <html><I><xsl:apply-templates/></I></html> </template> <template name="strong" match="strong"> <latex>\textbf{<xsl:apply-templates/>}</latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <template name="bold" match="bold"> <latex>\textbf{<xsl:apply-templates/>}</latex> <html><B><xsl:apply-templates/></B></html> </template> <template name="term" match="term"> <latex>\term<xsl:apply-templates/>}</latex> <html><I CLASS="term"><xsl:apply-templates/></I></html> </template> <template name="foreign" match="foreign"> <latex>\foreign{<xsl:apply-templates/>}</latex> <html><I CLASS="foreign"><xsl:apply-templates/></I></html> </template> <template name="code" match="code"> <latex>\code{<xsl:apply-templates/>}</latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <template name="code-block" match="code-block"> <latex> \begin{verbatim} <xsl:apply-templates/> \end{verbatim} </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- Quoted text. Handles nested quotes correctly. --> <template name="single-quote" match="quote[@single='yes']"> <latex>`<xsl:apply-templates/>'</latex> <html> <xsl:text disable-output-escaping="yes">&#8216;</xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&#8217;</xsl:text> </html> </template> <template name="double-quote" match="quote"> <latex>``<xsl:apply-templates/>''</latex> <html> <xsl:text disable-output-escaping="yes">&#8220;</xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes">&#8221;</xsl:text> </html> </template> <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> <alias source="q" target="single-quote"/> <alias source="qq" target="double-quote"/> <!-- Environments (in the LaTeX terminology): enumerated, ordered, and numbered lists. --> <!-- Unordered lists --> <template name="itemised-list" match="itemised-list"> <latex> \begin{itemize} <xsl:apply-templates/> \end{itemize} </latex> <html> <UL> <xsl:apply-templates/> </UL> </html> </template> <alias source="itemize" target="itemised-list"/> <alias source="unordered-list" target="itemised-list"/> <alias source="bulleted-list" target="itemised-list"/> <alias source="bullet-list" target="itemised-list"/> <alias source="bullet-points" target="itemised-list"/> <!-- Ordered lists --> <template name="enumerated-list" match="enumerated-list"> <latex> \begin{enumerate} <xsl:apply-templates/> \end{enumerate} </latex> <html> <OL> <xsl:apply-templates/> </OL> </html> </template> <alias source="enumerate" target="enumerated-list"/> <alias source="ordered-list" target="enumerated-list"/> <alias source="numbered-list" target="enumerated-list"/> <!-- Definition or description lists. --> <template name="definition-list" match="definition-list"> <latex> \begin{description} <xsl:apply-templates/> \end{description} </latex> <html> <DL> <xsl:apply-templates/> </DL> </html> </template> <alias source="description-list" target="definition-list"/> <!-- List elements --> <template name="item" match="item"> <latex>\item <xsl:apply-templates/></latex> <html><LI><xsl:apply-templates/></LI></html> </template> <template name="definition-item" match="definition-list/item"> <latex>\item[<xsl:apply-templates select="keyword"/>] <xsl:apply-templates select="definition"/></latex> <html> <DT><xsl:apply-templates select="keyword"/></DT> <DD><xsl:apply-templates select="definition|description|discourse"/></DD> </html> </template> <template name="keyword" match="keyword"> <latex><xsl:apply-templates/></latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <alias source="topic" target="keyword"/> <!-- Sections, subsections, subsubsections, ... --> <template name="section" match="section"> <latex> <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> </latex> <html> <xsl:if test="@label"><A NAME="{@label}"></A></xsl:if> <xsl:apply-templates/> </html> </template> <!-- Document preamble stuff: title, author, date. --> <template name="preamble-title" match="document/title" mode="preamble"> <latex>\title{<xsl:apply-templates/>}</latex> <html> <xsl:apply-templates/> </html> </template> <template name="preamble-author" match="document/author" mode="preamble"> <latex>\author{<xsl:apply-templates/>}</latex> </template> <template name="preamble-date" match="document/date" mode="preamble"> <latex>\date{<xsl:apply-templates/>}</latex> </template> <template name="document-title" match="document/title"> <!-- Need to do something sensible for LaTeX here. --> <latex><xsl:if test="$standalone = 'no'"></xsl:if></latex> <html> <H1><xsl:apply-templates/></H1> </html> </template> <template name="document-author" match="document/author"/> <template name="document-date" match="document/date"/> <!-- Generate some number of "sub" so we can produce, e.g., "subsubsection" for LaTeX. Parameter: $depth Meaning: the number of repetitions (0 <= $depth <= 2, but there's no need to do bounds checking at the upper end, because that's already dealt with in the "section-title" template below). --> <template name="generate-subs"> <latex> <xsl:param name="depth">1</xsl:param> <xsl:if test="$depth > 1"> <xsl:text>sub</xsl:text> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"><xsl:value-of select="$depth - 1"/></xsl:with-param> </xsl:call-template> </xsl:if> </latex> </template> <template name="section-title" match="section/title"> <latex> <xsl:param name="label"/> <xsl:text>\</xsl:text> <!-- Depth calculation for LaTeX hasn't been tested! --> <xsl:call-template name="generate-subs"> <xsl:with-param name="depth"> <xsl:number value="count(ancestor::section)"/> <xsl:if test="count(ancestor::section) > 3">3</xsl:if> </xsl:with-param> </xsl:call-template> <xsl:text>section{</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> </latex> <html> <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> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1"/> <xsl:text> </xsl:text> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"></H</xsl:text><xsl:number value="$depth"/><xsl:text disable-output-escaping="yes">></xsl:text> </html> </template> <!-- A quotation. --> <template name="quotation" match="quotation"> <latex> <xsl:choose> <xsl:when test="(@align = 'left') or (@align = 'right')"> \begin{flush<xsl:value-of select="@align"/>}\itshape <xsl:apply-templates/>\end{flush<xsl:value-of select="@align"/>} </xsl:when> <xsl:when test="@align = 'center'"> \begin{center}\itshape <xsl:apply-templates/>\end{center} </xsl:when> <xsl:otherwise> \begin{quote}\itshape <xsl:apply-templates/>\end{quote} </xsl:otherwise> </xsl:choose> </latex> <html> <P> <xsl:if test="@align"> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> </xsl:attribute> </xsl:if> <I><xsl:apply-templates/></I> </P> </html> </template> <!-- Anything inside an ID element is ignored completely. (More accurately, we pick bits out of it manually as required; it's only ignored by apply-templates.) --> <template name="id" match="id"/> <!-- Anything inside an OMIT element is also ignored completely. --> <template name="omit" match="omit"/> <!-- Tabular structures (LaTeX {tabular}, HTML <TABLE>). --> <template name="tabular" match="tabular"> <latex> <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'"> <xsl:text>center</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>flushleft</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> \begin{tabular}{<xsl:apply-templates select="columns"/>} <xsl:apply-templates select="tabular-header"/> <xsl:apply-templates select="tabular-body"/> <xsl:apply-templates select="tabular-footer"/> \end{tabular} <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'"> <xsl:text>center</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>flushleft</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </latex> <html> <TABLE> <xsl:attribute name="BORDER"> <xsl:value-of select="@border"/> <xsl:if test="not(@border)">0</xsl:if> </xsl:attribute> <xsl:if test="@align"> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> </xsl:attribute> </xsl:if> <!-- 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> </html> </template> <!-- Set left- or right-border to "|" to include a column separator. --> <template name="aligned-column" match="column[@align]"> <latex> <xsl:value-of select="@left-border"/> <xsl:value-of select="substring(@align, 1, 1)"/> <xsl:value-of select="@right-border"/> </latex> </template> <template name="unaligned-column" match="column[not(@align)]"> <latex> <xsl:value-of select="@left-border"/> <xsl:text>l</xsl:text> <xsl:value-of select="@right-border"/> </latex> </template> <template name="tabular-header" match="tabular-header"> <latex></latex> <html> <THEAD> <xsl:apply-templates/> </THEAD> </html> </template> <template name="tabular-footer" match="tabular-footer"> <latex></latex> <html> <TFOOT> <xsl:apply-templates/> </TFOOT> </html> </template> <template name="tabular-body" match="tabular-body"> <latex><xsl:apply-templates/></latex> <html> <TBODY> <xsl:apply-templates/> </TBODY> </html> </template> <template name="row" match="row"> <latex><xsl:apply-templates/> \\<xsl:if test="@no-page-break = 'yes'">*</xsl:if><xsl:text> </xsl:text></latex> <html> <TR> <xsl:apply-templates/> </TR> </html> </template> <template name="row-rule-full" match="row-rule[not(@columns)]"> <latex>\hline</latex> </template> <template name="row-rule-partial" match="row-rule[@columns]"> <latex>\cline{<xsl:value-of select="@columns"/>}</latex> </template> <template match="cell" mode="multi-row"> <latex> <xsl:text>\multirow{</xsl:text> <xsl:value-of select="@rows"/> <xsl:text>}{*}{</xsl:text> <xsl:apply-templates/> <xsl:text>}</xsl:text> </latex> </template> <template match="cell" mode="multi-column"> <latex> <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="@align"/> </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:apply-templates/> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text> </latex> </template> <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 :) --> <latex> <xsl:choose> <xsl:when test="@columns"> <xsl:apply-templates select="." mode="multi-column"> <xsl:with-param name="num-columns" select="@columns"/> </xsl:apply-templates> </xsl:when> <xsl:when test="@align"> <xsl:apply-templates select="." mode="multi-column"/> </xsl:when> <xsl:when test="@rows"> <xsl:apply-templates select="." mode="multi-row"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> <xsl:if test="$column-no != last()"> & </xsl:if> </latex> <!-- It's much easier in HTML, because a <TD> is a <TD> is a <TD>, regardless of the attributes supplied. --> <html> <TD> <xsl:attribute name="ALIGN"> <xsl:value-of select="@align"/> <xsl:if test="not(@align)"> <xsl:value-of select="ancestor::tabular/columns/column[position() = $column-no]/@align"/> <xsl:if test="not(ancestor::tabular/columns/column[position() = $column-no]/@align)">left</xsl:if> </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/> </TD> </html> </template> <!-- Hyperlinks. --> <template name="hyperlink-label" match="hyperlink[@label]"> <latex>\hyperref[<xsl:value-of select="@label"/>]{<xsl:apply-templates/>}</latex> <html><A HREF="#{@label}"><xsl:apply-templates/></A></html> </template> <template name="hyperlink-url" match="hyperlink[@url and node()]"> <latex>\href{<xsl:value-of select="@url"/>}{<xsl:apply-templates/>}</latex> <html><A HREF="{@url}"><xsl:apply-templates/></A></html> </template> <!-- An empty <hyperlink> element with a URL defaults to the URL as the link text. --> <template name="empty-hyperlink-url" match="hyperlink[@url and not(node())]"> <!-- Maybe we should be using the url package and \url{...}? --> <latex>\href{<xsl:value-of select="@url"/>}{\texttt{<xsl:value-of select="@url"/>}}</latex> <html><A HREF="{@url}"><CODE><xsl:value-of select="@url"/></CODE></A></html> </template> <!-- A plain URL. --> <template name="url" match="url"> <!-- Maybe we should be using the url package and \url{...}? --> <latex>\texttt{<xsl:apply-templates/>}</latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <alias source="uri" target="url"/> <alias source="email" target="url"/> <alias source="email-address" target="url"/> <!-- References. --> <template name="reference" match="reference"> <common> <!-- Find the element whose label is the same as our label. --> <xsl:apply-templates select="//*[@label = current()/@label]" mode="reference"/> </common> </template> <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. --> <latex>Section~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Section&#160;</xsl:text> <xsl:number count="section" level="multiple" format="1.1.1.1.1.1"/> </html> </template> <template name="figure-reference" match="figure" mode="reference"> <latex>Figure~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Figure&#160;</xsl:text> <xsl:number count="figure" level="multiple" format="1"/> </html> </template> <template name="table-reference" match="table" mode="reference"> <latex>Table~\ref*{<xsl:value-of select="@label"/>}</latex> <html> <xsl:text disable-output-escaping="yes">Table&#160;</xsl:text> <xsl:number count="table" level="multiple" format="1"/> </html> </template> <!-- Figures & tables. --> <template name="figure" match="figure"> <latex> \begin{figure} \centering <xsl:apply-templates select="*[not(self::caption)]"/> <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{figure} </latex> <html> <DIV CLASS="figure"> <xsl:if test="@label"><A NAME="{@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> </html> </template> <template name="table" match="table"> <latex> \begin{table} \centering <xsl:apply-templates select="*[not(self::caption)]"/> <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} </latex> <html> <DIV CLASS="table"> <xsl:if test="@label"><A NAME="{@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> </html> </template> <template name="figure-caption" match="figure/caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Figure <xsl:number count="figure" level="multiple" format="1"/>. </STRONG><xsl:apply-templates/> </html> </template> <template name="table-caption" match="table/caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Table <xsl:number count="table" level="multiple" format="1"/>. </STRONG><xsl:apply-templates/> </html> </template> <!-- Images. Includes a scaling factor for LaTeX. --> <template match="image[not(@print-version)]"> <latex> \includegraphics[scale=<xsl:value-of select="latex-scaling"/>]{images/<xsl:value-of select="basename"/>.<xsl:value-of select="$image-format"/>} </latex> <html> <IMG BORDER="0"> <xsl:attribute name="SRC">images/<xsl:value-of select="basename"/>.png</xsl:attribute> <xsl:attribute name="ALT"><xsl:apply-templates select="description"/></xsl:attribute> </IMG> </html> </template> <template match="image[@print-version = 'yes']"> <latex> \includegraphics[scale=<xsl:value-of select="latex-scaling"/>]{images/<xsl:value-of select="basename"/>.<xsl:value-of select="$image-format"/>} </latex> <html> <A> <xsl:attribute name="HREF">images/<xsl:value-of select="basename"/>-print.png</xsl:attribute> <IMG BORDER="0"> <xsl:attribute name="SRC">images/<xsl:value-of select="basename"/>.png</xsl:attribute> <xsl:attribute name="ALT"><xsl:apply-templates select="description"/></xsl:attribute> </IMG> </A> </html> </template> <!-- Include another document into the current one. The @inline attribute specifies whether the document is to be included inline (note that this really only makes sense for HTML). Possible values: yes, no (default no). If the document is not inlined, then an appropriate link to the document is generated. Inlined files must be document fragments, not standalone documents! Currently somewhat broken. Needs more work. --> <template name="include-noinline" match="include-document[not(@inline) or (@inline = 'no')]"> <latex>\input{<xsl:value-of select="@basename"/>}</latex> <html> <P><A> <xsl:attribute name="HREF"> <xsl:value-of select="@baseurl"/> <xsl:value-of select="@basename"/> <xsl:text>.html</xsl:text> </xsl:attribute> <xsl:apply-templates/> </A></P> </html> </template> <template name="include-inline" match="include-document[@inline = 'yes']"> <latex>\input{<xsl:value-of select="@basename"/>}</latex> <html><xsl:copy-of select="document(concat(@basename, '.html'))/html/body/*"/></html> </template> <!-- Environment setup. This enables you to load environment settings (e.g., required LaTeX packages, etc.) from an external configuration file. The master style sheet automatically loads a file called "environment.xml"; you don't need to do anything for this file to be loaded. Multiple configuration files may be loaded, as long as they all have different names. --> <template name="environment-file" match="environment[@file]"> <xsl:apply-templates select="document(@file)/environment/*"/> </template> <template name="latex-package" match="latex-packages/package"> <latex>\usepackage<xsl:if test="@options">[<xsl:value-of select="@options"/>]</xsl:if>{<xsl:value-of select="."/>}</latex> </template> <template name="latex-command" match="latex-packages/command"> <latex><xsl:value-of select="."/></latex> </template> <!-- Sometimes we might need to embed raw code to handle something tricky. --> <template name="raw-latex" match="raw-code[@format = 'latex']"> <latex><xsl:apply-templates/></latex> </template> <template name="raw-html" match="raw-code[@format = 'html']"> <html><xsl:copy-of select="*"/></html> </template> </stylesheet>
Show line notes below