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
- Fixed broken LaTeX image scaling.
master
OLD_GRAPHICS_HANDLING
1 parent
a9ceeb9
commit
61cab99248dcf0661f026227ae39cc868799d114
nstanger
authored
on 15 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">&#160;</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="non-breaking-space" match="non-breaking-space"><latex>~</latex><html> </html></template> <alias source="nbsp" target="non-breaking-space"/> <template name="ellipsis-sign" match="ellipsis-sign"> <latex><xsl:text>{\ldots}</xsl:text></latex> <html><xsl:text>…</xsl:text></html></template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex><xsl:text>--</xsl:text></latex> <html><xsl:text>–</xsl:text></html></template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex><xsl:text>---</xsl:text></latex> <html><xsl:text>—</xsl:text></html></template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex><xsl:text>'</xsl:text></latex> <html><xsl:text>’</xsl:text></html></template> <template name="dollar" match="dollar"> <latex><xsl:text>\$</xsl:text></latex> <html><xsl:text>$</xsl:text></html></template> <template name="percent-sign" match="percent-sign"> <latex><xsl:text>\%</xsl:text></latex> <html><xsl:text>%</xsl:text></html></template> <template name="ampersand" match="ampersand"> <latex><xsl:text>\&</xsl:text></latex> <html><xsl:text>&</xsl:text></html></template> <template name="trademark-sign" match="trademark-sign"> <latex><xsl:text>(TM)</xsl:text></latex> <html><xsl:text>™</xsl:text></html></template> <alias source="trademark" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex><xsl:text>\copyright</xsl:text></latex> <html><xsl:text>©</xsl:text></html></template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex><xsl:text>deg</xsl:text></latex> <html><xsl:text>°</xsl:text></html></template> <template name="section-sign" match="section-sign"> <latex><xsl:text>{\S}</xsl:text></latex> <html><xsl:text>§</xsl:text></html></template> <template name="paragraph-sign" match="paragraph-sign"> <latex><xsl:text>{\P}</xsl:text></latex> <html><xsl:text>¶</xsl:text></html></template> <template name="pi" match="pi"> <latex><xsl:text>{\pi}</xsl:text></latex> <html><xsl:text>π</xsl:text></html></template> <template name="LaTeX" match="LaTeX"> <latex><xsl:text>{\latex}</xsl:text></latex> <html><xsl:text>LaTeX</xsl:text></html></template> <alias source="latex" target="LaTeX"/> <!-- Could use \triangleright in LaTeX, but is there an equivalent in HTML? --> <template name="menu-separator" match="menu-separator"><latex>$\rightarrow$</latex><html>→</html></template> <!-- Special styles --> <template name="emph" match="emph"><latex><xsl:text>\emph{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><EM><xsl:apply-templates/></EM></html></template> <template name="italic" match="italic"><latex><xsl:text>\textit{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></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><xsl:text>\foreign{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I CLASS="foreign"><xsl:apply-templates/></I></html></template> <template name="code" match="code"> <latex><xsl:text>\code{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <!-- Quoted text. Handles nested quotes correctly. --> <template name="single-quote" match="quote[@single='yes']"> <latex>`{<xsl:apply-templates/>}'</latex> <html>‘<xsl:apply-templates/>’</html> </template> <template name="double-quote" match="quote"> <latex>``{<xsl:apply-templates/>}''</latex> <html>“<xsl:apply-templates/>”</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"/> <template name="code-block" match="code-block"> <latex> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates/> <xsl:text>\end{verbatim}</xsl:text> </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- 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><xsl:text>\item </xsl:text><xsl:apply-templates/></latex> <html><LI><xsl:apply-templates/></LI></html> </template> <template name="definition-item" match="definition-list/item"> <latex><xsl:text>\item[</xsl:text><xsl:apply-templates select="keyword"/><xsl:text>]</xsl:text> <xsl:apply-templates select="definition"/></latex> <html> <DT><xsl:apply-templates select="keyword"/></DT> <DD><xsl:apply-templates select="definition"/></DD> </html> </template> <template name="keyword" match="keyword"> <latex><xsl:apply-templates/></latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <template name="definition" match="definition"> <latex><xsl:apply-templates/></latex> <html><xsl:apply-templates/></html> </template> <alias source="topic" target="keyword"/> <alias source="description" target="definition"/> <alias source="discourse" target="definition"/> <!-- 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"/> <!-- Tables (equivalent to a tabular in LaTeX terms). --> <template name="table" match="table"> <latex></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> <xsl:apply-templates/> </TABLE> </html> </template> <template name="table-body" match="table-body"> <latex></latex> <html> <TBODY> <xsl:apply-templates/> </TBODY> </html> </template> <template name="row" match="row"> <latex></latex> <html> <TR> <xsl:apply-templates/> </TR> </html> </template> <template name="cell" match="cell"> <latex></latex> <html> <xsl:variable name="column-no"> <xsl:number/> </xsl:variable> <TD> <xsl:attribute name="ALIGN"> <xsl:value-of select="ancestor::table/columns/column[position()=$column-no]/@align"/> <xsl:if test="not(ancestor::table/columns/column[position()=$column-no]/@align)">left</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:value-of select="@url"/>}</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> <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>Section <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>Figure <xsl:number count="figure" level="multiple" format="1"/></html> </template> <!-- Figures. --> <template name="figure" match="figure"> <latex> <!-- This should really be more generic, so it can handle figures without graphics. That'll mean more templates... Or perhaps do separate XML tags for different kinds of figure? --> <!-- select="id" and select = "label" so it'll work with either --> \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="caption" match="caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Figure <xsl:number count="figure" 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! --> <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> </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">&#160;</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="non-breaking-space" match="non-breaking-space"><latex>~</latex><html> </html></template> <alias source="nbsp" target="non-breaking-space"/> <template name="ellipsis-sign" match="ellipsis-sign"> <latex><xsl:text>{\ldots}</xsl:text></latex> <html><xsl:text>…</xsl:text></html></template> <alias source="etc" target="ellipsis-sign"/> <alias source="ellipsis" target="ellipsis-sign"/> <!-- Misc typographic symbols --> <template name="endash" match="endash"> <latex><xsl:text>--</xsl:text></latex> <html><xsl:text>–</xsl:text></html></template> <alias source="en-dash" target="endash"/> <template name="emdash" match="emdash"> <latex><xsl:text>---</xsl:text></latex> <html><xsl:text>—</xsl:text></html></template> <alias source="em-dash" target="emdash"/> <template name="apostrophe" match="apostrophe"> <latex><xsl:text>'</xsl:text></latex> <html><xsl:text>’</xsl:text></html></template> <template name="dollar" match="dollar"> <latex><xsl:text>\$</xsl:text></latex> <html><xsl:text>$</xsl:text></html></template> <template name="percent-sign" match="percent-sign"> <latex><xsl:text>\%</xsl:text></latex> <html><xsl:text>%</xsl:text></html></template> <template name="ampersand" match="ampersand"> <latex><xsl:text>\&</xsl:text></latex> <html><xsl:text>&</xsl:text></html></template> <template name="trademark-sign" match="trademark-sign"> <latex><xsl:text>(TM)</xsl:text></latex> <html><xsl:text>™</xsl:text></html></template> <alias source="trademark" target="trademark-sign"/> <template name="copyright-sign" match="copyright-sign"> <latex><xsl:text>\copyright</xsl:text></latex> <html><xsl:text>©</xsl:text></html></template> <!-- <alias source="copyright" target="copyright-sign"/> --> <template name="degree-sign" match="degree-sign"> <latex><xsl:text>deg</xsl:text></latex> <html><xsl:text>°</xsl:text></html></template> <template name="section-sign" match="section-sign"> <latex><xsl:text>{\S}</xsl:text></latex> <html><xsl:text>§</xsl:text></html></template> <template name="paragraph-sign" match="paragraph-sign"> <latex><xsl:text>{\P}</xsl:text></latex> <html><xsl:text>¶</xsl:text></html></template> <template name="pi" match="pi"> <latex><xsl:text>{\pi}</xsl:text></latex> <html><xsl:text>π</xsl:text></html></template> <template name="LaTeX" match="LaTeX"> <latex><xsl:text>{\latex}</xsl:text></latex> <html><xsl:text>LaTeX</xsl:text></html></template> <alias source="latex" target="LaTeX"/> <!-- Could use \triangleright in LaTeX, but is there an equivalent in HTML? --> <template name="menu-separator" match="menu-separator"><latex>$\rightarrow$</latex><html>→</html></template> <!-- Special styles --> <template name="emph" match="emph"><latex><xsl:text>\emph{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><EM><xsl:apply-templates/></EM></html></template> <template name="italic" match="italic"><latex><xsl:text>\textit{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></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><xsl:text>\foreign{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex><html><I CLASS="foreign"><xsl:apply-templates/></I></html></template> <template name="code" match="code"> <latex><xsl:text>\code{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></latex> <html><CODE><xsl:apply-templates/></CODE></html> </template> <!-- Quoted text. Handles nested quotes correctly. --> <template name="single-quote" match="quote[@single='yes']"> <latex>`{<xsl:apply-templates/>}'</latex> <html>‘<xsl:apply-templates/>’</html> </template> <template name="double-quote" match="quote"> <latex>``{<xsl:apply-templates/>}''</latex> <html>“<xsl:apply-templates/>”</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"/> <template name="code-block" match="code-block"> <latex> <xsl:text>\begin{verbatim}</xsl:text> <xsl:apply-templates/> <xsl:text>\end{verbatim}</xsl:text> </latex> <html> <PRE CLASS="code"><xsl:apply-templates/></PRE> </html> </template> <!-- 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><xsl:text>\item </xsl:text><xsl:apply-templates/></latex> <html><LI><xsl:apply-templates/></LI></html> </template> <template name="definition-item" match="definition-list/item"> <latex><xsl:text>\item[</xsl:text><xsl:apply-templates select="keyword"/><xsl:text>]</xsl:text> <xsl:apply-templates select="definition"/></latex> <html> <DT><xsl:apply-templates select="keyword"/></DT> <DD><xsl:apply-templates select="definition"/></DD> </html> </template> <template name="keyword" match="keyword"> <latex><xsl:apply-templates/></latex> <html><STRONG><xsl:apply-templates/></STRONG></html> </template> <template name="definition" match="definition"> <latex><xsl:apply-templates/></latex> <html><xsl:apply-templates/></html> </template> <alias source="topic" target="keyword"/> <alias source="description" target="definition"/> <alias source="discourse" target="definition"/> <!-- 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"/> <!-- Tables (equivalent to a tabular in LaTeX terms). --> <template name="table" match="table"> <latex></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> <xsl:apply-templates/> </TABLE> </html> </template> <template name="table-body" match="table-body"> <latex></latex> <html> <TBODY> <xsl:apply-templates/> </TBODY> </html> </template> <template name="row" match="row"> <latex></latex> <html> <TR> <xsl:apply-templates/> </TR> </html> </template> <template name="cell" match="cell"> <latex></latex> <html> <xsl:variable name="column-no"> <xsl:number/> </xsl:variable> <TD> <xsl:attribute name="ALIGN"> <xsl:value-of select="ancestor::table/columns/column[position()=$column-no]/@align"/> <xsl:if test="not(ancestor::table/columns/column[position()=$column-no]/@align)">left</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:value-of select="@url"/>}</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> <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>Section <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>Figure <xsl:number count="figure" level="multiple" format="1"/></html> </template> <!-- Figures. --> <template name="figure" match="figure"> <latex> <!-- This should really be more generic, so it can handle figures without graphics. That'll mean more templates... Or perhaps do separate XML tags for different kinds of figure? --> <!-- select="id" and select = "label" so it'll work with either --> \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="caption" match="caption"> <latex><xsl:apply-templates/></latex> <html> <STRONG>Figure <xsl:number count="figure" 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"/>\columnwidth]{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"/>\columnwidth]{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! --> <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> </stylesheet>
Show line notes below