| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> |
| 3 |
|
| 4 |
<!--############################################################################ |
| 5 |
XSLT Stylesheet DocBook -> LaTeX |
| 6 |
############################################################################ --> |
| 7 |
|
| 8 |
<!-- ToC/LoT parameters --> |
| 9 |
<xsl:param name="doc.lot.show">figure,table</xsl:param> |
| 10 |
<xsl:param name="doc.toc.show">1</xsl:param> |
| 11 |
|
| 12 |
|
| 13 |
<!-- Noting to do: things are done by latex --> |
| 14 |
<xsl:template match="toc"/> |
| 15 |
<xsl:template match="lot"/> |
| 16 |
<xsl:template match="lotentry"/> |
| 17 |
<xsl:template match="tocpart|tocchap|tocfront|tocback|tocentry"/> |
| 18 |
<xsl:template match="toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/> |
| 19 |
|
| 20 |
|
| 21 |
<!-- Print one LoT --> |
| 22 |
<xsl:template match="book|article" mode="lot"> |
| 23 |
<xsl:param name="lot"/> |
| 24 |
|
| 25 |
<xsl:choose> |
| 26 |
<xsl:when test="$lot='figure' and .//figure"> |
| 27 |
<xsl:text>\listoffigures </xsl:text> |
| 28 |
</xsl:when> |
| 29 |
<xsl:when test="$lot='table' and .//table"> |
| 30 |
<xsl:text>\listoftables </xsl:text> |
| 31 |
</xsl:when> |
| 32 |
<xsl:when test="$lot='example' and .//example"> |
| 33 |
<!-- A non standard float list --> |
| 34 |
<xsl:text>\listof{</xsl:text> |
| 35 |
<xsl:value-of select="$lot"/> |
| 36 |
<xsl:text>}{</xsl:text> |
| 37 |
<xsl:call-template name="gentext"> |
| 38 |
<xsl:with-param name="key" select="'ListofExamples'"/> |
| 39 |
</xsl:call-template> |
| 40 |
<xsl:text>} </xsl:text> |
| 41 |
</xsl:when> |
| 42 |
<xsl:when test="$lot='equation' and .//equation"> |
| 43 |
<!-- A non standard float list --> |
| 44 |
<xsl:text>\listof{dbequation}</xsl:text> |
| 45 |
<xsl:text>{</xsl:text> |
| 46 |
<xsl:call-template name="gentext"> |
| 47 |
<xsl:with-param name="key" select="'ListofEquations'"/> |
| 48 |
</xsl:call-template> |
| 49 |
<xsl:text>} </xsl:text> |
| 50 |
</xsl:when> |
| 51 |
</xsl:choose> |
| 52 |
</xsl:template> |
| 53 |
|
| 54 |
<!-- Print the ToC and all the LoTs listed in $doc.lot.show --> |
| 55 |
<xsl:template match="book|article" mode="toc_lots"> |
| 56 |
<xsl:if test="$doc.toc.show != '0'"> |
| 57 |
<xsl:text>\tableofcontents </xsl:text> |
| 58 |
</xsl:if> |
| 59 |
<xsl:apply-templates select="." mode="lots"/> |
| 60 |
</xsl:template> |
| 61 |
|
| 62 |
<!-- Print all the LoTs listed in $doc.lot.show --> |
| 63 |
<xsl:template match="book|article" mode="lots"> |
| 64 |
<xsl:param name="lots" select="$doc.lot.show"/> |
| 65 |
|
| 66 |
<xsl:choose> |
| 67 |
<xsl:when test="contains($lots, ',')"> |
| 68 |
<xsl:apply-templates select="." mode="lot"> |
| 69 |
<xsl:with-param name="lot" |
| 70 |
select="normalize-space(substring-before($lots, ','))"/> |
| 71 |
</xsl:apply-templates> |
| 72 |
<xsl:apply-templates select="." mode="lots"> |
| 73 |
<xsl:with-param name="lots" select="substring-after($lots, ',')"/> |
| 74 |
</xsl:apply-templates> |
| 75 |
</xsl:when> |
| 76 |
<xsl:otherwise> |
| 77 |
<xsl:apply-templates select="." mode="lot"> |
| 78 |
<xsl:with-param name="lot" select="normalize-space($lots)"/> |
| 79 |
</xsl:apply-templates> |
| 80 |
</xsl:otherwise> |
| 81 |
</xsl:choose> |
| 82 |
</xsl:template> |
| 83 |
|
| 84 |
|
| 85 |
<!-- Update the TOC depth for printed TOC and PDF bookmarks --> |
| 86 |
<xsl:template name="set-tocdepth"> |
| 87 |
<xsl:param name="depth"/> |
| 88 |
<!-- For printed TOC --> |
| 89 |
<xsl:text>\addtocontents{toc}{\protect\setcounter{tocdepth}{</xsl:text> |
| 90 |
<xsl:value-of select="$depth"/> |
| 91 |
<xsl:text>}\ignorespaces} </xsl:text> |
| 92 |
<!-- For bookmarks --> |
| 93 |
<xsl:text>\setcounter{tocdepth}{</xsl:text> |
| 94 |
<xsl:value-of select="$depth"/> |
| 95 |
<xsl:text>} </xsl:text> |
| 96 |
</xsl:template> |
| 97 |
|
| 98 |
</xsl:stylesheet> |