Initial commit of mal2latex stylesheets

This commit is contained in:
Shaun McCance 2010-07-10 13:06:30 -04:00
commit c21a0c8c42
4 changed files with 700 additions and 0 deletions

167
mal2latex-block.xsl Normal file
View File

@ -0,0 +1,167 @@
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mal="http://projectmallard.org/1.0/"
exclude-result-prefixes="mal"
version="1.0">
<xsl:template mode="mal2latex.block.mode" match="mal:comment"/>
<xsl:template mode="mal2latex.block.mode" match="mal:code">
<xsl:variable name="first" select="node()[1]/self::text()"/>
<xsl:variable name="last" select="node()[last()]/self::text()"/>
<xsl:text>\begin{boxedminipage}{\textwidth}&#x000A;</xsl:text>
<xsl:text>\begin{alltt}&#x000A;</xsl:text>
<xsl:if test="$first">
<xsl:variable name="text">
<xsl:call-template name="utils.strip_newlines">
<xsl:with-param name="string" select="$first"/>
<xsl:with-param name="leading" select="true()"/>
<xsl:with-param name="trailing" select="count(node()) = 1"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="mal2latex.inline.escape">
<xsl:with-param name="node" select="$first"/>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates mode="mal2latex.inline.mode"
select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
<xsl:if test="$last and (count(node()) != 1)">
<xsl:variable name="text">
<xsl:call-template name="utils.strip_newlines">
<xsl:with-param name="string" select="$last"/>
<xsl:with-param name="leading" select="false()"/>
<xsl:with-param name="trailing" select="true()"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="mal2latex.inline.escape">
<xsl:with-param name="node" select="$last"/>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:if>
<xsl:text>\end{alltt}&#x000A;</xsl:text>
<xsl:text>\end{boxedminipage}&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:example">
<xsl:text>\begin{malexample}&#x000A;</xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"/>
<xsl:text>\end{malexample}&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:list">
<xsl:choose>
<xsl:when test="@type = 'numbered'">
<xsl:text>\begin{enumerate}&#x000A;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\begin{itemize}&#x000A;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="mal:item">
<xsl:text>\item </xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"/>
</xsl:for-each>
<xsl:choose>
<xsl:when test="@type = 'numbered'">
<xsl:text>\end{enumerate}&#x000A;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\end{itemize}&#x000A;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:note">
<xsl:text>\begin{malnote}&#x000A;</xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"/>
<xsl:text>\end{malnote}&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:screen">
<xsl:variable name="first" select="node()[1]/self::text()"/>
<xsl:variable name="last" select="node()[last()]/self::text()"/>
<xsl:text>\begin{malscreen}&#x000A;</xsl:text>
<xsl:if test="$first">
<xsl:variable name="text">
<xsl:call-template name="utils.strip_newlines">
<xsl:with-param name="string" select="$first"/>
<xsl:with-param name="leading" select="true()"/>
<xsl:with-param name="trailing" select="count(node()) = 1"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="mal2latex.inline.escape">
<xsl:with-param name="node" select="$first"/>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates mode="mal2latex.inline.mode"
select="node()[not(self::text() and (position() = 1 or position() = last()))]"/>
<xsl:if test="$last and (count(node()) != 1)">
<xsl:variable name="text">
<xsl:call-template name="utils.strip_newlines">
<xsl:with-param name="string" select="$last"/>
<xsl:with-param name="leading" select="false()"/>
<xsl:with-param name="trailing" select="true()"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="mal2latex.inline.escape">
<xsl:with-param name="node" select="$last"/>
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:if>
<xsl:text>\end{malscreen}&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:steps">
<xsl:text>\begin{malsteps}&#x000A;</xsl:text>
<xsl:for-each select="mal:item">
<xsl:text>\item </xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"/>
</xsl:for-each>
<xsl:text>\end{malsteps}&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:synopsis">
<xsl:message>
<xsl:text>FIXME: synopsis</xsl:text>
</xsl:message>
<xsl:apply-templates mode="mal2latex.block.mode"/>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:p">
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>&#x000A;&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:title">
<xsl:text>{\bf </xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}&#x000A;&#x000A;</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="*">
<xsl:message>
<xsl:text>Unmatched block element: </xsl:text>
<xsl:value-of select="local-name(.)"/>
</xsl:message>
</xsl:template>
</xsl:stylesheet>

192
mal2latex-inline.xsl Normal file
View File

@ -0,0 +1,192 @@
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mal="http://projectmallard.org/1.0/"
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="mal str"
version="1.0">
<xsl:template mode="mal.link.content.mode" match="*">
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:app">
<xsl:text>\textit{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:cmd">
<xsl:text>\framebox{\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:code">
<xsl:text>\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:em">
<xsl:text>\textit{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:file">
<xsl:text>\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:gui">
<xsl:apply-templates mode="mal2latex.inline.mode"/>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:guiseq">
<xsl:for-each select="* | text()[normalize-space(.) != '']">
<xsl:if test="position() != 1">
<xsl:text> \verb|>| </xsl:text>
</xsl:if>
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
</xsl:for-each>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:input">
<xsl:text>\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:key">
<xsl:apply-templates mode="mal2latex.inline.mode"/>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:keyseq">
<xsl:variable name="joinchar">
<xsl:choose>
<xsl:when test="@type = 'sequence'">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="contains(concat(' ', @style, ' '), ' hyphen ')">
<xsl:text>-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>+</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="* | text()[normalize-space(.) != '']">
<xsl:if test="position() != 1">
<xsl:value-of select="$joinchar"/>
</xsl:if>
<xsl:choose>
<xsl:when test="./self::text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="mal2latex.inline.mode" select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:link">
<xsl:choose>
<xsl:when test="@xref and normalize-space(.) = ''">
<xsl:call-template name="mal.link.content">
<xsl:with-param name="role" select="@role"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:span">
<xsl:apply-templates mode="mal2latex.inline.mode"/>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:output">
<xsl:text>\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:sys">
<xsl:text>\texttt{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="mal:var">
<xsl:text>\textit{</xsl:text>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
<xsl:text>}</xsl:text>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="*">
<xsl:message>
<xsl:text>Unmatched inline element: </xsl:text>
<xsl:value-of select="local-name(.)"/>
</xsl:message>
<xsl:apply-templates mode="mal2latex.inline.mode"/>
</xsl:template>
<xsl:template mode="mal2latex.inline.mode" match="text()"
name="mal2latex.inline.escape">
<xsl:param name="node" select="."/>
<xsl:param name="text" select="string(.)"/>
<xsl:variable name="verbatim"
select="$node/ancestor::mal:code or $node/ancestor::mal:screen "/>
<xsl:for-each select="str:split($text, '')">
<xsl:choose>
<xsl:when test=". = '&#x000A;'">
<xsl:choose>
<xsl:when test="$verbatim">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test=". = '&lt;'">
<xsl:text>{\textless}</xsl:text>
</xsl:when>
<xsl:when test=". = '&gt;'">
<xsl:text>{\textgreater}</xsl:text>
</xsl:when>
<xsl:when test=". = '\'">
<xsl:text>{\textbackslash}</xsl:text>
</xsl:when>
<xsl:when test="contains('$&amp;#_{}', .)">
<xsl:text>\</xsl:text>
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

118
mal2latex-table.xsl Normal file
View File

@ -0,0 +1,118 @@
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:mal="http://projectmallard.org/1.0/"
exclude-result-prefixes="exsl mal"
version="1.0">
<xsl:template name="_repeat_cols">
<xsl:param name="num"/>
<xsl:if test="$num &gt; 0">
<mal:col/>
<xsl:call-template name="_repeat_cols">
<xsl:with-param name="num" select="$num - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template mode="mal2latex.block.mode" match="mal:table">
<xsl:variable name="cols">
<xsl:choose>
<xsl:when test="mal:col | mal:colgroup">
<xsl:copy-of select="mal:col | mal:colgroup"/>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select=".//mal:tr[1]/mal:td">
<xsl:choose>
<xsl:when test="@colspan">
<xsl:call-template name="_repeat_cols">
<xsl:with-param name="num" select="number(@colspan)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<mal:col/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="colrules">
<xsl:choose>
<xsl:when test="contains(concat(' ', @rules, ' '), 'cols')">
<xsl:text>cols</xsl:text>
</xsl:when>
<xsl:when test="contains(concat(' ', @rules, ' '), 'colgroups')">
<xsl:text>colgroups</xsl:text>
</xsl:when>
<xsl:when test="@rules = 'all'">
<xsl:text>cols</xsl:text>
</xsl:when>
<xsl:when test="@rules = 'colgroups'">
<xsl:text>colgroups</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:text>\begin{tabular}{</xsl:text>
<xsl:for-each select="exsl:node-set($cols)/*">
<xsl:choose>
<xsl:when test="self::mal:colgroup">
<xsl:if test="$colrules = 'colgroups'">
<xsl:text>|</xsl:text>
</xsl:if>
<xsl:for-each select="mal:col">
<xsl:if test="$colrules = 'cols'">
<xsl:text>|</xsl:text>
</xsl:if>
<xsl:text>l</xsl:text>
</xsl:for-each>
</xsl:when>
<xsl:when test="self::mal:col">
<xsl:if test="$colrules = 'cols'">
<xsl:text>|</xsl:text>
</xsl:if>
<xsl:text>l</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:for-each>
<xsl:if test="$colrules != ''">
<xsl:text>|</xsl:text>
</xsl:if>
<xsl:text>}&#x000A;</xsl:text>
<xsl:for-each select="mal:tr | mal:thead/mal:tr | mal:tfoot/mal:tr | mal:tbody/mal:tr">
<xsl:for-each select="mal:td">
<xsl:text>\begin{minipage}{1in}&#x000A;</xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"/>
<xsl:text>\end{minipage}</xsl:text>
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:text>\\&#x000A;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> &amp; </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
<xsl:text>\end{tabular}&#x000A;</xsl:text>
<xsl:text>\par&#x000A;</xsl:text>
</xsl:template>
</xsl:stylesheet>

223
mal2latex.xsl Normal file
View File

@ -0,0 +1,223 @@
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:cache="http://projectmallard.org/cache/1.0/"
xmlns:mal="http://projectmallard.org/1.0/"
exclude-result-prefixes="exsl mal"
version="1.0">
<xsl:import href="/usr/share/yelp-xsl/xslt/common/color.xsl"/>
<xsl:import href="/usr/share/yelp-xsl/xslt/common/utils.xsl"/>
<xsl:import href="/usr/share/yelp-xsl/xslt/mallard/common/mal-link.xsl"/>
<xsl:import href="/usr/share/yelp-xsl/xslt/mallard/common/mal-sort.xsl"/>
<xsl:include href="mal2latex-block.xsl"/>
<xsl:include href="mal2latex-inline.xsl"/>
<xsl:include href="mal2latex-table.xsl"/>
<xsl:output method="text"/>
<xsl:param name="mal.cache" select="/cache:cache"/>
<xsl:template name="hex2dec">
<xsl:param name="hex"/>
<xsl:variable name="l">
<xsl:choose>
<xsl:when test="contains('0123456789', substring($hex, 1, 1))">
<xsl:value-of select="number(substring($hex, 1, 1))"/>
</xsl:when>
<xsl:when test="contains('Aa', substring($hex, 1, 1))">
<xsl:value-of select="10"/>
</xsl:when>
<xsl:when test="contains('Bb', substring($hex, 1, 1))">
<xsl:value-of select="11"/>
</xsl:when>
<xsl:when test="contains('Cc', substring($hex, 1, 1))">
<xsl:value-of select="12"/>
</xsl:when>
<xsl:when test="contains('Dd', substring($hex, 1, 1))">
<xsl:value-of select="13"/>
</xsl:when>
<xsl:when test="contains('Ee', substring($hex, 1, 1))">
<xsl:value-of select="14"/>
</xsl:when>
<xsl:when test="contains('Ff', substring($hex, 1, 1))">
<xsl:value-of select="15"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="r">
<xsl:choose>
<xsl:when test="contains('0123456789', substring($hex, 2, 1))">
<xsl:value-of select="number(substring($hex, 2, 1))"/>
</xsl:when>
<xsl:when test="contains('Aa', substring($hex, 2, 1))">
<xsl:value-of select="10"/>
</xsl:when>
<xsl:when test="contains('Bb', substring($hex, 2, 1))">
<xsl:value-of select="11"/>
</xsl:when>
<xsl:when test="contains('Cc', substring($hex, 2, 1))">
<xsl:value-of select="12"/>
</xsl:when>
<xsl:when test="contains('Dd', substring($hex, 2, 1))">
<xsl:value-of select="13"/>
</xsl:when>
<xsl:when test="contains('Ee', substring($hex, 2, 1))">
<xsl:value-of select="14"/>
</xsl:when>
<xsl:when test="contains('Ff', substring($hex, 2, 1))">
<xsl:value-of select="15"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="(16 * $l) + $r"/>
</xsl:template>
<xsl:template name="convert.color">
<xsl:param name="color"/>
<xsl:call-template name="hex2dec">
<xsl:with-param name="hex" select="substring($color, 2, 2)"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="hex2dec">
<xsl:with-param name="hex" select="substring($color, 4, 2)"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="hex2dec">
<xsl:with-param name="hex" select="substring($color, 6, 2)"/>
</xsl:call-template>
</xsl:template>
<xsl:variable name="blue_border">
<xsl:call-template name="convert.color">
<xsl:with-param name="color" select="$color.blue_border"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="gray_background">
<xsl:call-template name="convert.color">
<xsl:with-param name="color" select="$color.gray_background"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="yellow_background">
<xsl:call-template name="convert.color">
<xsl:with-param name="color" select="$color.yellow_background"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="yellow_border">
<xsl:call-template name="convert.color">
<xsl:with-param name="color" select="$color.yellow_border"/>
</xsl:call-template>
</xsl:variable>
<xsl:template name="sty">
<xsl:text>
\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\usepackage{alltt}
\usepackage{boxedminipage}
\usepackage{color}
\definecolor{blueborder}{RGB}{</xsl:text><xsl:value-of select="$blue_border"/><xsl:text>}
\definecolor{grayback}{RGB}{</xsl:text><xsl:value-of select="$gray_background"/><xsl:text>}
\definecolor{yellowback}{RGB}{</xsl:text><xsl:value-of select="$yellow_background"/><xsl:text>}
\definecolor{yellowborder}{RGB}{</xsl:text><xsl:value-of select="$yellow_border"/><xsl:text>}
\setlength{\parindent}{0in}
\setlength{\parskip}{1em}
\newenvironment{malexample}%
{\hskip -10pt \vrule width 2pt \hskip 8pt%
\begin{minipage}{\textwidth}%
\setlength{\parskip}{1em}}%
{\end{minipage}%
\par}
\newsavebox{\malnotecontainer}
\newenvironment{malnote}{%
\begin{lrbox}{\malnotecontainer}%
\begin{minipage}{\textwidth}}%
{\end{minipage}%
\end{lrbox}%
\fcolorbox{yellowborder}{yellowback}{\usebox{\malnotecontainer}}\par}
\newsavebox{\malscreencontainer}
\newenvironment{malscreen}{%
\begin{lrbox}{\malscreencontainer}%
\begin{minipage}{\textwidth}%
\begin{alltt}}%
{\end{alltt}%
\end{minipage}%
\end{lrbox}%
\fcolorbox{grayback}{grayback}{\usebox{\malscreencontainer}}\par}
\newsavebox{\malstepscontainer}
\newenvironment{malsteps}{%
\begin{lrbox}{\malstepscontainer}%
\begin{minipage}{\textwidth}%
\begin{enumerate}}%
{\end{enumerate}%
\end{minipage}%
\end{lrbox}%
\fcolorbox{blueborder}{yellowback}{\usebox{\malstepscontainer}}\par}
</xsl:text>
</xsl:template>
<xsl:template match="/cache:cache">
<xsl:text>\documentclass{article}&#x000A;</xsl:text>
<xsl:call-template name="sty"/>
<xsl:text>\begin{document}&#x000A;</xsl:text>
<xsl:variable name="sorted">
<xsl:call-template name="mal.sort.tsort"/>
</xsl:variable>
<xsl:for-each select="exsl:node-set($sorted)/mal:link">
<xsl:variable name="linkid">
<xsl:call-template name="mal.link.xref.linkid"/>
</xsl:variable>
<xsl:for-each select="$mal.cache">
<xsl:apply-templates select="document(key('mal.cache.key', $linkid)/@cache:href, /)/mal:page"/>
</xsl:for-each>
</xsl:for-each>
<xsl:text>&#x000A;\end{document}&#x000A;</xsl:text>
</xsl:template>
<xsl:template match="mal:page">
<xsl:text>\pagebreak&#x000A;\section{</xsl:text>
<xsl:value-of select="mal:title"/>
<xsl:text>}&#x000A;</xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"
select="*[not(self::mal:info or self::mal:title or self::mal:subtitle or self::mal:section)]"/>
<xsl:apply-templates select="mal:section"/>
</xsl:template>
<xsl:template match="mal:section">
<xsl:choose>
<xsl:when test="count(ancestor::mal:section) = 0">
<xsl:text>\subsection*{</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\subsubsection*{</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="mal:title"/>
<xsl:text>}&#x000A;</xsl:text>
<xsl:apply-templates mode="mal2latex.block.mode"
select="*[not(self::mal:info or self::mal:title or self::mal:subtitle or self::mal:section)]"/>
<xsl:apply-templates select="mal:section"/>
</xsl:template>
</xsl:stylesheet>