Newer
Older
XML / xml2latex.xsl
cedwards on 7 Jan 2004 30 KB Added some to-dos and questions.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl-out:stylesheet xmlns:xsl-out="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl-out:strip-space elements="*"/><xsl-out:param name="department">INFO</xsl-out:param><xsl-out:param name="paper"/><xsl-out:output method="text" encoding="ISO-8859-1" media-type="text/plain"/><xsl-out:param name="image-format">pdf</xsl-out:param><xsl-out:param name="standalone">yes</xsl-out:param><xsl-out:template match="/document"><xsl-out:choose><xsl-out:when test="$standalone = 'yes'">
% THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!

\documentclass[12pt,a4paper]{article}

\usepackage[margin=1in]{geometry}
\usepackage{mathpple}
\usepackage{multirow}
\usepackage{graphicx}
<xsl-out:apply-templates select="document('environment.xml')/environment/latex-packages"/>
\usepackage[pdftex]{hyperref}

<xsl-out:apply-templates select="document('environment.xml')/environment/latex-commands"/><xsl-out:apply-templates select="title" mode="preamble"/><xsl-out:apply-templates select="author" mode="preamble"/><xsl-out:apply-templates select="date" mode="preamble"/>

\begin{document}
	\maketitle

	<xsl-out:apply-templates/>

	\vfill
	{\scriptsize \hfill \verb+<xsl-out:apply-templates select="id/cvs-id"/>+}
\end{document}
						</xsl-out:when><xsl-out:otherwise><xsl-out:apply-templates/></xsl-out:otherwise></xsl-out:choose></xsl-out:template>
	

	<xsl-out:template name="PaperCode" match="PaperCode"><xsl:value-of select="$department" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>~<xsl:value-of select="$paper" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>

	<xsl-out:template name="OracleServer" match="OracleServer">Oracle9\textit{i}</xsl-out:template>


	<xsl-out:template name="paragraph" match="paragraph"><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


</xsl:text><xsl:if test="@indent = 'no'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\noindent </xsl:if><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
		
</xsl:text></xsl-out:template>
	<xsl-out:template name="para" match="para"><xsl-out:call-template name="paragraph"/></xsl-out:template>
	<xsl-out:template name="p" match="p"><xsl-out:call-template name="paragraph"/></xsl-out:template>
	
	
	
	
	<xsl-out:template name="newline" match="newline"> \\</xsl-out:template>
	
	<xsl-out:template name="page-break" match="page-break">\newpage</xsl-out:template>
	<xsl-out:template name="new-page" match="new-page"><xsl-out:call-template name="page-break"/></xsl-out:template>

	<xsl-out:template name="non-breaking-space" match="non-breaking-space">~</xsl-out:template>	
	<xsl-out:template name="nbsp" match="nbsp"><xsl-out:call-template name="non-breaking-space"/></xsl-out:template>

	
	<xsl-out:template name="ellipsis-sign" match="ellipsis-sign">{\ldots}</xsl-out:template>
	<xsl-out:template name="etc" match="etc"><xsl-out:call-template name="ellipsis-sign"/></xsl-out:template>
	<xsl-out:template name="ellipsis" match="ellipsis"><xsl-out:call-template name="ellipsis-sign"/></xsl-out:template>
	<xsl-out:template name="dots" match="dots"><xsl-out:call-template name="ellipsis-sign"/></xsl-out:template>

	
	<xsl-out:template name="endash" match="endash">--</xsl-out:template>
	<xsl-out:template name="en-dash" match="en-dash"><xsl-out:call-template name="endash"/></xsl-out:template>

	<xsl-out:template name="emdash" match="emdash">---</xsl-out:template>
	<xsl-out:template name="em-dash" match="em-dash"><xsl-out:call-template name="emdash"/></xsl-out:template>

	<xsl-out:template name="apostrophe" match="apostrophe">'</xsl-out:template>

	<xsl-out:template name="dollar" match="dollar">\$</xsl-out:template>

	<xsl-out:template name="percent-sign" match="percent-sign">\%</xsl-out:template>

	<xsl-out:template name="ampersand" match="ampersand">\&amp;</xsl-out:template>

	<xsl-out:template name="trademark-sign" match="trademark-sign">\texttrademark</xsl-out:template>
	<xsl-out:template name="trademark" match="trademark"><xsl-out:call-template name="trademark-sign"/></xsl-out:template>
	<xsl-out:template name="TM" match="TM"><xsl-out:call-template name="trademark-sign"/></xsl-out:template>

	<xsl-out:template name="copyright-sign" match="copyright-sign">\copyright</xsl-out:template>
	

	<xsl-out:template name="degree-sign" match="degree-sign">$^{\circ}$</xsl-out:template>
	<xsl-out:template name="degrees" match="degrees"><xsl-out:call-template name="degree-sign"/></xsl-out:template>

	<xsl-out:template name="section-sign" match="section-sign">{\S}</xsl-out:template>

	<xsl-out:template name="paragraph-sign" match="paragraph-sign">{\P}</xsl-out:template>

	
	
	<xsl-out:template name="pi" match="pi">\pi</xsl-out:template>

	<xsl-out:template name="LaTeX" match="LaTeX">{\LaTeX}</xsl-out:template>
	<xsl-out:template name="latex" match="latex"><xsl-out:call-template name="LaTeX"/></xsl-out:template>

	
	<xsl-out:template name="menu-separator" match="menu-separator">$\triangleright$</xsl-out:template>
	<xsl-out:template name="menusep" match="menusep"><xsl-out:call-template name="menu-separator"/></xsl-out:template>

	<xsl-out:template name="menu-item" match="menu/item">\menuitem{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	
	<xsl-out:template name="emph" match="emph">\emph{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="italic" match="italic">\textit{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="strong" match="strong">\textbf{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="bold" match="bold">\textbf{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="term" match="term">\term{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="foreign" match="foreign">\foreign{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	<xsl-out:template name="code" match="code">\verb+<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>+</xsl-out:template>

	
	<xsl-out:template name="code-block" match="code-block">
			\begin{verbatim}
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{verbatim}
		</xsl-out:template>

	
	<xsl-out:template name="verbatim" match="verbatim">
			\begin{verbatim}
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{verbatim}
		</xsl-out:template>

	
	
	<xsl-out:template name="single-quote" match="quote[@single='yes']">`<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>'</xsl-out:template>
	<xsl-out:template name="double-quote" match="quote">``<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>''</xsl-out:template>
	<xsl-out:template name="nested-double-quote" match="quote//quote">
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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>
		</xsl-out:template>
	<xsl-out:template name="nested-single-quote" match="quote[@single='yes']//quote" priority="2">
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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>
		</xsl-out:template>
	<xsl-out:template name="q" match="q"><xsl-out:call-template name="single-quote"/></xsl-out:template>
	<xsl-out:template name="qq" match="qq"><xsl-out:call-template name="double-quote"/></xsl-out:template>


	

	
	
	<xsl-out:template name="itemised-list" match="itemised-list">
			\begin{itemize}
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{itemize}
		</xsl-out:template>
	
	<xsl-out:template name="itemize" match="itemize"><xsl-out:call-template name="itemised-list"/></xsl-out:template>
	<xsl-out:template name="unordered-list" match="unordered-list"><xsl-out:call-template name="itemised-list"/></xsl-out:template>
	<xsl-out:template name="bulleted-list" match="bulleted-list"><xsl-out:call-template name="itemised-list"/></xsl-out:template>
	<xsl-out:template name="bullet-list" match="bullet-list"><xsl-out:call-template name="itemised-list"/></xsl-out:template>
	<xsl-out:template name="bullet-points" match="bullet-points"><xsl-out:call-template name="itemised-list"/></xsl-out:template>


	
	
	<xsl-out:template name="enumerated-list" match="enumerated-list">
			\begin{enumerate}
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{enumerate}
		</xsl-out:template>

	<xsl-out:template name="enumerate" match="enumerate"><xsl-out:call-template name="enumerated-list"/></xsl-out:template>
	<xsl-out:template name="ordered-list" match="ordered-list"><xsl-out:call-template name="enumerated-list"/></xsl-out:template>
	<xsl-out:template name="numbered-list" match="numbered-list"><xsl-out:call-template name="enumerated-list"/></xsl-out:template>
	<xsl-out:template name="question-list" match="question-list"><xsl-out:call-template name="enumerated-list"/></xsl-out:template>
	
	
	
	<xsl-out:template name="definition-list" match="definition-list">
			\begin{description}
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{description}
		</xsl-out:template>
	
	<xsl-out:template name="description-list" match="description-list"><xsl-out:call-template name="definition-list"/></xsl-out:template>


	
	<xsl-out:template name="item" match="item">\item <xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>

	<xsl-out:template name="definition-item" match="definition-list/item">\item[<xsl:apply-templates select="keyword" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>] <xsl:apply-templates select="definition" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	<xsl-out:template name="keyword" match="keyword"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	<xsl-out:template name="topic" match="topic"><xsl-out:call-template name="keyword"/></xsl-out:template>
	
	
	<xsl-out:template name="definition" match="item/definition|item/description|item/discourse"/>
	
	
	
	<xsl-out:template name="section" match="section">
			<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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>
		</xsl-out:template>
	
	
	
	<xsl-out:template name="footnote" match="footnote">\footnote{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	
	<xsl-out:template name="footnote-list" match="footnote" mode="list"/>

	
	
	<xsl-out:template name="preamble-title" match="document/title" mode="preamble">\title{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	<xsl-out:template name="preamble-author" match="document/author" mode="preamble">\author{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	<xsl-out:template name="preamble-date" match="document/date" mode="preamble">\date{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	<xsl-out:template name="document-title" match="document/title"><xsl:if test="$standalone = 'no'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	<xsl-out:template name="document-author" match="document/author"/>
	<xsl-out:template name="document-date" match="document/date"/>

	
	<xsl-out:template name="generate-subs">
			<xsl:param name="depth" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">1</xsl:param>
			<xsl:if test="$depth &gt; 1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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>
		</xsl-out:template>
	
	<xsl-out:template name="section-title" match="section/title">
			<xsl:param name="label" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\</xsl:text>
			<!-- Depth calculation for LaTeX hasn't been tested! -->
			<xsl:call-template name="generate-subs" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<xsl:with-param name="depth">
					<xsl:number value="count(ancestor::section)"/>
					<xsl:if test="count(ancestor::section) &gt; 3">3</xsl:if>
				</xsl:with-param>
			</xsl:call-template>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">section{</xsl:text>
			<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
			<xsl:if test="$label != 'THERE_IS_NO_LABEL'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				\label{<xsl:value-of select="$label"/>}
			</xsl:if>
		</xsl-out:template>


	
	<xsl-out:template name="quotation" match="quotation">
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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>
		</xsl-out:template>
	
	
	
	<xsl-out:template name="id" match="id"/>
	
	
	
	<xsl-out:template name="omit" match="omit"/>

	
	
	<xsl-out:template name="comment" match="comment">
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
\begin{comment}</xsl:text>
				<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
				<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\end{comment}
</xsl:text>
		</xsl-out:template>
	
	
	
	<xsl-out:template name="tabular" match="tabular">
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\begin{</xsl:text>
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
			\begin{tabular}{<xsl:apply-templates select="columns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}
				<xsl:apply-templates select="tabular-header" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
				<xsl:apply-templates select="tabular-body" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
				<xsl:apply-templates select="tabular-footer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			\end{tabular}
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\end{</xsl:text>
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
		</xsl-out:template>
	
	
	<xsl-out:template name="aligned-column" match="column[@align]">
			<xsl:value-of select="@left-border" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:value-of select="substring(@align, 1, 1)" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:value-of select="@right-border" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
		</xsl-out:template>
	
	<xsl-out:template name="unaligned-column" match="column[not(@align)]">
			<xsl:value-of select="@left-border" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">l</xsl:text>
			<xsl:value-of select="@right-border" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
		</xsl-out:template>
	
	<xsl-out:template name="tabular-header" match="tabular-header"/>

	<xsl-out:template name="tabular-footer" match="tabular-footer"/>

	<xsl-out:template name="tabular-body" match="tabular-body"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>

	<xsl-out:template name="row" match="row"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/> \\<xsl:if test="@no-page-break = 'yes'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">*</xsl:if><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> </xsl:text></xsl-out:template>

	<xsl-out:template name="row-rule-full" match="row-rule[not(@columns)]">\hline</xsl-out:template>

	<xsl-out:template name="row-rule-partial" match="row-rule[@columns]">\cline{<xsl:value-of select="@columns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	<xsl-out:template match="cell" mode="multi-row">
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\multirow{</xsl:text>
			<xsl:value-of select="@rows" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}{*}{</xsl:text>
			<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
		</xsl-out:template>
	
	<xsl-out:template match="cell" mode="multi-column">
			<xsl:param name="num-columns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">1</xsl:param>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\multicolumn{</xsl:text>
			<xsl:value-of select="$num-columns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}{</xsl:text>
			<xsl:value-of select="@left-border" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}{</xsl:text>
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<xsl:when test="@rows">
					<xsl:apply-templates select="." mode="multi-row"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates/>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
		</xsl-out:template>
	
	<xsl-out:template match="cell">
			<!-- position() doesn't seem to work very well in this context -->
			<xsl:variable name="column-no" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:number/></xsl:variable>
		
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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()" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> &amp; </xsl:if>
		</xsl-out:template>
	
	
	
	<xsl-out:template name="hyperlink-label" match="hyperlink[@label]">\hyperref[<xsl:value-of select="@label" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>]{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	<xsl-out:template name="hyperlink-url" match="hyperlink[@url and node()]">\href{<xsl:value-of select="@url" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	
	<xsl-out:template name="empty-hyperlink-url" match="hyperlink[@url and not(node())]">\href{<xsl:value-of select="@url" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}{\texttt{<xsl:value-of select="@url" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}}</xsl-out:template>
	
	
	<xsl-out:template name="url" match="url">\texttt{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	<xsl-out:template name="uri" match="uri"><xsl-out:call-template name="url"/></xsl-out:template>
	<xsl-out:template name="email" match="email"><xsl-out:call-template name="url"/></xsl-out:template>
	<xsl-out:template name="email-address" match="email-address"><xsl-out:call-template name="url"/></xsl-out:template>


	
	<xsl-out:template name="reference" match="reference">
			<!-- Find the element whose label is the same as our label. -->
			<xsl:apply-templates select="//*[@label = current()/@label]" mode="reference" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
		</xsl-out:template>
	
	<xsl-out:template name="section-reference" match="section" mode="reference">Section~\ref*{<xsl:value-of select="@label" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	<xsl-out:template name="figure-reference" match="figure" mode="reference">Figure~\ref*{<xsl:value-of select="@label" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	<xsl-out:template name="table-reference" match="table" mode="reference">Table~\ref*{<xsl:value-of select="@label" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	
	
	<xsl-out:template name="figure" match="figure">
			\begin{figure}
				\centering
				<xsl:apply-templates select="*[not(self::caption)]" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
				<xsl:if test="count(caption) != 0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
					\caption{<xsl:apply-templates select="caption"/>}
					<xsl:if test="@label">\label{<xsl:value-of select="@label"/>}</xsl:if>
				</xsl:if>
			\end{figure}
		</xsl-out:template>
	
	<xsl-out:template name="table" match="table">
			\begin{table}
				\centering
				<xsl:apply-templates select="*[not(self::caption)]" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
				<xsl:if test="count(caption) != 0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
					\caption{<xsl:apply-templates select="caption"/>}
					<xsl:if test="@label">\label{<xsl:value-of select="@label"/>}</xsl:if>
				</xsl:if>
			\end{table}
		</xsl-out:template>
	
	<xsl-out:template name="figure-caption" match="figure/caption"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	<xsl-out:template name="table-caption" match="table/caption"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	
	
	
	

	
	<xsl-out:template match="image" mode="latex">
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\includegraphics</xsl:text>
			<xsl:if test="count(latex-scaling) != 0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<xsl:text>[scale=</xsl:text>
				<xsl:value-of select="latex-scaling"/>
				<xsl:text>]</xsl:text>
			</xsl:if>
			<!-- Use whatever standard image folder is appropriate for the context. -->
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<xsl:when test="name(/child::node()[1])='tutorial'">
					<xsl:text>{\tutroot/</xsl:text><xsl:value-of select="/tutorial/id/number-code"/><xsl:text>-</xsl:text><xsl:value-of select="/tutorial/id/title-code"/><xsl:text>/Graphics/</xsl:text>
				</xsl:when>
				<xsl:when test="name(/child::node()[1])='laboratory'">
					<xsl:text>{\labroot/</xsl:text><xsl:value-of select="/laboratory/id/number-code"/><xsl:text>-</xsl:text><xsl:value-of select="/laboratory/id/title-code"/><xsl:text>/Graphics/</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>{images/</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:value-of select="basename" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">.</xsl:text>
			<xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
				<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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">}</xsl:text>
		</xsl-out:template>
	
	<xsl-out:template match="image[count(provide-large-version) = 0]"><xsl:apply-templates select="." mode="latex" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>

	<xsl-out:template match="image[count(provide-large-version) != 0]"><xsl:apply-templates select="." mode="latex" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	
	
	<xsl-out:template name="include-xml" match="include-document">
			<xsl:apply-templates select="document(@file)" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
		</xsl-out:template>
	
	
	
	<xsl-out:template name="environment" match="environment[@file]"/>
	
	<xsl-out:template name="latex-package" match="latex-packages/package">\usepackage<xsl:if test="@options" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">[<xsl:value-of select="@options"/>]</xsl:if>{<xsl:value-of select="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
		
	<xsl-out:template name="latex-command" match="latex-packages/command"><xsl:value-of select="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	
	
	<xsl-out:template name="raw-latex" match="raw-code[@format = 'latex']"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
		
	<xsl-out:template name="raw-html" match="raw-code[@format = 'html']"/>
		
	
	<xsl-out:template name="latex-input" match="latex-input">\input{<xsl:value-of select="." xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>

	
	
	<xsl-out:template name="process-when-latex" match="process-when[@format = 'latex']"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	<xsl-out:template name="process-when-html" match="process-when[@format = 'html']"/>
	
	
	
	<xsl-out:template name="math-inline" match="paragraph//math|para//math|p//math">\(<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>\)</xsl-out:template>
	
	<xsl-out:template name="math-display" match="math">\[<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>\]</xsl-out:template>

	
	
	
	<xsl-out:template name="equation-array" match="equation-array">
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\begin{eqnarray*}
</xsl:text>
			<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
			<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
\end{eqnarray*}</xsl:text>
		</xsl-out:template>


	
	
	<xsl-out:template match="equation-array/row">
			<xsl:apply-templates select="left" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:text disable-output-escaping="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	&amp;	</xsl:text><xsl:apply-templates select="middle" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:text disable-output-escaping="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	&amp;	</xsl:text><xsl:apply-templates select="right" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	\\
		\\ </xsl:text>
		</xsl-out:template>
	

	
	<xsl-out:template name="digit-group-separator" match="digit-group-separator">
			<xsl:call-template name="non-breaking-space" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
		</xsl-out:template>
	<xsl-out:template name="digitsep" match="digitsep"><xsl-out:call-template name="digit-group-separator"/></xsl-out:template>
	
	
	<xsl-out:template name="superscript" match="math//superscript">^{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	<xsl-out:template name="subscript" match="math//subscript">_{<xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	
	
	<xsl-out:template name="plus-operator" match="math//plus">+</xsl-out:template>
	
	<xsl-out:template name="minus-operator" match="math//minus">-</xsl-out:template>
	
	<xsl-out:template name="times-operator" match="math//times">\times</xsl-out:template>
	<xsl-out:template name="times" match="times"><xsl-out:call-template name="times-operator"/></xsl-out:template>
	
	<xsl-out:template name="divide-operator" match="math//divide">/</xsl-out:template>
	
	<xsl-out:template name="equals-operator" match="math//equals"> = </xsl-out:template>
	
	
	<xsl-out:template name="log-like-function" match="math//function">\<xsl:value-of select="@name" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	
	<xsl-out:template name="math-variable" match="math//variable"><xsl:apply-templates xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/></xsl-out:template>
	
	
	<xsl-out:template name="math-fraction" match="math//fraction">\frac{<xsl:apply-templates select="numerator" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}{<xsl:apply-templates select="denominator" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>}</xsl-out:template>
	

</xsl-out:stylesheet>