Debian Codegraph @

xsl/component.xsl

raw
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 <xsl:param name="preface.tocdepth">0</xsl:param>
8 <xsl:param name="dedication.tocdepth">0</xsl:param>
9 <xsl:param name="colophon.tocdepth">0</xsl:param>
10 <xsl:param name="beginpage.as.pagebreak" select="1"/>
11
12
13 <xsl:template match="colophon">
14 <xsl:call-template name="section.unnumbered">
15 <xsl:with-param name="tocdepth" select="number($colophon.tocdepth)"/>
16 <xsl:with-param name="title">
17 <xsl:call-template name="gentext">
18 <xsl:with-param name="key" select="'Colophon'"/>
19 </xsl:call-template>
20 </xsl:with-param>
21 </xsl:call-template>
22 </xsl:template>
23
24 <xsl:template match="dedication">
25 <xsl:call-template name="section.unnumbered">
26 <xsl:with-param name="tocdepth" select="number($dedication.tocdepth)"/>
27 <xsl:with-param name="title">
28 <xsl:call-template name="gentext">
29 <xsl:with-param name="key" select="'Dedication'"/>
30 </xsl:call-template>
31 </xsl:with-param>
32 </xsl:call-template>
33 </xsl:template>
34
35 <xsl:template match="preface">
36 <xsl:call-template name="section.unnumbered">
37 <xsl:with-param name="tocdepth" select="number($preface.tocdepth)"/>
38 </xsl:call-template>
39 </xsl:template>
40
41 <xsl:template name="section.unnumbered">
42 <xsl:param name="tocdepth" select="0"/>
43 <xsl:param name="level" select="'0'"/>
44 <xsl:param name="titlenode" select="(title|info/title)[1]"/>
45 <xsl:param name="title"/>
46
47 <xsl:apply-templates select="." mode="endnotes"/>
48
49 <xsl:call-template name="section.unnumbered.begin">
50 <xsl:with-param name="tocdepth" select="$tocdepth"/>
51 <xsl:with-param name="level" select="$level"/>
52 <xsl:with-param name="titlenode" select="$titlenode"/>
53 <xsl:with-param name="title" select="$title"/>
54 </xsl:call-template>
55
56 <xsl:apply-templates select="." mode="section.body"/>
57
58 <xsl:call-template name="section.unnumbered.end">
59 <xsl:with-param name="tocdepth" select="$tocdepth"/>
60 </xsl:call-template>
61 </xsl:template>
62
63 <xsl:template name="section.unnumbered.begin">
64 <xsl:param name="tocdepth" select="0"/>
65 <xsl:param name="level" select="'0'"/>
66 <xsl:param name="titlenode" select="title"/>
67 <xsl:param name="title"/>
68 <xsl:choose>
69 <xsl:when test="number($tocdepth) = -1">
70 <xsl:call-template name="mapheading"/>
71 </xsl:when>
72 <xsl:otherwise>
73 <!-- don't use starred headings, but rely on counters instead -->
74 <xsl:text>\setcounter{secnumdepth}{-1}&#10;</xsl:text>
75 <xsl:if test="$tocdepth &lt;= $toc.section.depth">
76 <xsl:call-template name="set-tocdepth">
77 <xsl:with-param name="depth" select="$tocdepth - 1"/>
78 </xsl:call-template>
79 </xsl:if>
80 <!-- those sections have optional title -->
81 <xsl:choose>
82 <xsl:when test="$titlenode">
83 <xsl:call-template name="makeheading">
84 <xsl:with-param name="level" select="$level"/>
85 <xsl:with-param name="allnum" select="'1'"/>
86 <xsl:with-param name="title" select="$titlenode"/>
87 </xsl:call-template>
88 </xsl:when>
89 <xsl:otherwise>
90 <xsl:call-template name="maketitle">
91 <xsl:with-param name="level" select="$level"/>
92 <xsl:with-param name="allnum" select="'1'"/>
93 <xsl:with-param name="title" select="$title"/>
94 </xsl:call-template>
95 </xsl:otherwise>
96 </xsl:choose>
97 </xsl:otherwise>
98 </xsl:choose>
99 </xsl:template>
100
101 <xsl:template name="section.unnumbered.end">
102 <xsl:param name="tocdepth" select="0"/>
103 <xsl:if test="number($tocdepth) &gt; -1">
104 <!-- restore the initial counters -->
105 <xsl:text>\setcounter{secnumdepth}{</xsl:text>
106 <xsl:value-of select="$doc.section.depth"/>
107 <xsl:text>}&#10;</xsl:text>
108 <xsl:if test="$tocdepth &lt;= $toc.section.depth">
109 <xsl:call-template name="set-tocdepth">
110 <xsl:with-param name="depth" select="$toc.section.depth"/>
111 </xsl:call-template>
112 </xsl:if>
113 </xsl:if>
114 </xsl:template>
115
116 <!-- By default the (unumbered) section body just processes children -->
117 <xsl:template match="*" mode="section.body">
118 <xsl:apply-templates/>
119 </xsl:template>
120
121 <xsl:template match="dedication/title"></xsl:template>
122 <xsl:template match="dedication/subtitle"></xsl:template>
123 <xsl:template match="dedication/titleabbrev"></xsl:template>
124 <xsl:template match="colophon/title"></xsl:template>
125 <xsl:template match="preface/title"></xsl:template>
126 <xsl:template match="preface/titleabbrev"></xsl:template>
127 <xsl:template match="preface/subtitle"></xsl:template>
128 <xsl:template match="preface/docinfo|prefaceinfo"></xsl:template>
129
130 <!-- preface sect{1-5} mapped like sections -->
131
132 <xsl:template match="preface//sect1|
133 preface//sect2|
134 preface//sect3|
135 preface//sect4|
136 preface//sect5">
137 <xsl:choose>
138 <xsl:when test="number($preface.tocdepth) = -1">
139 <xsl:call-template name="makeheading">
140 <xsl:with-param name="name" select="local-name(.)"/>
141 </xsl:call-template>
142 </xsl:when>
143 <xsl:otherwise>
144 <xsl:call-template name="makeheading">
145 <xsl:with-param name="name" select="local-name(.)"/>
146 <xsl:with-param name="allnum" select="'1'"/>
147 </xsl:call-template>
148 </xsl:otherwise>
149 </xsl:choose>
150 <xsl:apply-templates/>
151 </xsl:template>
152
153 <xsl:template match="preface//section">
154 <xsl:variable name="allnum">
155 <xsl:choose>
156 <xsl:when test="number($preface.tocdepth) = -1">0</xsl:when>
157 <xsl:otherwise>1</xsl:otherwise>
158 </xsl:choose>
159 </xsl:variable>
160 <xsl:call-template name="makeheading">
161 <xsl:with-param name="level" select="count(ancestor::section)+1"/>
162 <xsl:with-param name="allnum" select="$allnum"/>
163 </xsl:call-template>
164 <xsl:apply-templates/>
165 </xsl:template>
166
167 <!-- don't know where to put it -->
168 <xsl:template match="beginpage">
169 <xsl:if test="$beginpage.as.pagebreak=1">
170 <xsl:choose>
171 <xsl:when test="@pagenum != ''">
172 <xsl:message>Cannot start a new page at a specific page number</xsl:message>
173 </xsl:when>
174 <xsl:when test="@role = 'openright'">
175 <xsl:text>\cleardoublepage&#10;</xsl:text>
176 </xsl:when>
177 <xsl:otherwise>
178 <xsl:text>\clearpage&#10;</xsl:text>
179 </xsl:otherwise>
180 </xsl:choose>
181 </xsl:if>
182 </xsl:template>
183
184 </xsl:stylesheet>