toc_lot.xsl coverage = 34/69 (49.28%)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

<!--############################################################################
    XSLT Stylesheet DocBook -> LaTeX 
    ############################################################################ -->

<!-- ToC/LoT parameters -->
<xsl:param name="doc.lot.show">figure,table</xsl:param>
<xsl:param name="doc.toc.show">1</xsl:param>


<!-- Noting to do: things are done by latex -->
<xsl:template match="toc"/>
<xsl:template match="lot"/>
<xsl:template match="lotentry"/>
<xsl:template match="tocpart|tocchap|tocfront|tocback|tocentry"/>
<xsl:template match="toclevel1|toclevel2|toclevel3|toclevel4|toclevel5"/>


<!-- Print one LoT -->
<xsl:template match="book|article" mode="lot">
  <xsl:param name="lot"/>

  <xsl:choose>
  <xsl:when test="$lot='figure' and .//figure">
    <xsl:text>\listoffigures&#10;</xsl:text>
  </xsl:when>
  <xsl:when test="$lot='table' and .//table">
    <xsl:text>\listoftables&#10;</xsl:text>
  </xsl:when>
  <xsl:when test="$lot='example' and .//example">
    <!-- A non standard float list -->
    <xsl:text>\listof{</xsl:text>
    <xsl:value-of select="$lot"/>
    <xsl:text>}{</xsl:text>
    <xsl:call-template name="gentext">
      <xsl:with-param name="key" select="'ListofExamples'"/>
    </xsl:call-template>
    <xsl:text>}&#10;</xsl:text>
  </xsl:when>
  <xsl:when test="$lot='equation' and .//equation">
    <!-- A non standard float list -->
    <xsl:text>\listof{dbequation}</xsl:text>
    <xsl:text>{</xsl:text>
    <xsl:call-template name="gentext">
      <xsl:with-param name="key" select="'ListofEquations'"/>
    </xsl:call-template>
    <xsl:text>}&#10;</xsl:text>
  </xsl:when>
  </xsl:choose>
</xsl:template>

<!-- Print the ToC and all the LoTs listed in $doc.lot.show -->
<xsl:template match="book|article" mode="toc_lots">
  <xsl:if test="$doc.toc.show != '0'">
    <xsl:text>\tableofcontents&#10;</xsl:text>
  </xsl:if>
  <xsl:apply-templates select="." mode="lots"/>
</xsl:template>

<!-- Print all the LoTs listed in $doc.lot.show -->
<xsl:template match="book|article" mode="lots">
  <xsl:param name="lots" select="$doc.lot.show"/>

  <xsl:choose>
  <xsl:when test="contains($lots, ',')">
    <xsl:apply-templates select="." mode="lot">
      <xsl:with-param name="lot"
                      select="normalize-space(substring-before($lots, ','))"/>
    </xsl:apply-templates>
    <xsl:apply-templates select="." mode="lots">
      <xsl:with-param name="lots" select="substring-after($lots, ',')"/>
    </xsl:apply-templates>
  </xsl:when>
  <xsl:otherwise>
    <xsl:apply-templates select="." mode="lot">
      <xsl:with-param name="lot" select="normalize-space($lots)"/>
    </xsl:apply-templates>
  </xsl:otherwise>
  </xsl:choose>
</xsl:template>


<!-- Update the TOC depth for printed TOC and PDF bookmarks -->
<xsl:template name="set-tocdepth">
  <xsl:param name="depth"/>
  <!-- For printed TOC -->
  <xsl:text>\addtocontents{toc}{\protect\setcounter{tocdepth}{</xsl:text>
  <xsl:value-of select="$depth"/>
  <xsl:text>}\ignorespaces}&#10;</xsl:text>
  <!-- For bookmarks -->
  <xsl:text>\setcounter{tocdepth}{</xsl:text>
  <xsl:value-of select="$depth"/>
  <xsl:text>}&#10;</xsl:text>
</xsl:template>

</xsl:stylesheet>