2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: component.xsl 9356 2012-05-12 23:33:15Z bobstayton $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://docbook.sf.net/release/xsl/current/ for
11 copyright and other information.
13 ******************************************************************** -->
15 <!-- ==================================================================== -->
17 <!-- Set to 2 for backwards compatibility -->
18 <xsl:param name="component.heading.level" select="2"/>
20 <xsl:template name="component.title">
21 <xsl:param name="node" select="."/>
23 <!-- This handles the case where a component (bibliography, for example)
24 occurs inside a section; will we need parameters for this? -->
26 <!-- This "level" is a section level. To compute <h> level, add 1. -->
27 <xsl:variable name="level">
29 <!-- chapters and other book children should get <h1> -->
30 <xsl:when test="$node/parent::book">0</xsl:when>
31 <xsl:when test="ancestor::section">
32 <xsl:value-of select="count(ancestor::section)+1"/>
34 <xsl:when test="ancestor::sect5">6</xsl:when>
35 <xsl:when test="ancestor::sect4">5</xsl:when>
36 <xsl:when test="ancestor::sect3">4</xsl:when>
37 <xsl:when test="ancestor::sect2">3</xsl:when>
38 <xsl:when test="ancestor::sect1">2</xsl:when>
39 <xsl:otherwise>1</xsl:otherwise>
43 <xsl:element name="h{$level+1}">
44 <xsl:attribute name="class">title</xsl:attribute>
45 <xsl:call-template name="id.attribute"/>
46 <xsl:call-template name="anchor">
47 <xsl:with-param name="node" select="$node"/>
48 <xsl:with-param name="conditional" select="0"/>
50 <xsl:apply-templates select="$node" mode="object.title.markup">
51 <xsl:with-param name="allow-anchors" select="1"/>
52 </xsl:apply-templates>
56 <xsl:template name="component.subtitle">
57 <xsl:param name="node" select="."/>
58 <xsl:variable name="subtitle"
59 select="($node/docinfo/subtitle
61 |$node/prefaceinfo/subtitle
62 |$node/chapterinfo/subtitle
63 |$node/appendixinfo/subtitle
64 |$node/articleinfo/subtitle
65 |$node/artheader/subtitle
66 |$node/subtitle)[1]"/>
68 <xsl:if test="$subtitle">
70 <xsl:call-template name="id.attribute"/>
72 <xsl:apply-templates select="$node" mode="object.subtitle.markup"/>
78 <xsl:template name="component.separator">
81 <!-- ==================================================================== -->
83 <xsl:template match="dedication" mode="dedication">
84 <xsl:call-template name="id.warning"/>
87 <xsl:call-template name="common.html.attributes">
88 <xsl:with-param name="inherit" select="1"/>
90 <xsl:call-template name="id.attribute">
91 <xsl:with-param name="conditional" select="0"/>
93 <xsl:call-template name="dedication.titlepage"/>
94 <xsl:apply-templates/>
95 <xsl:call-template name="process.footnotes"/>
99 <xsl:template match="dedication/title|dedication/info/title"
100 mode="titlepage.mode" priority="2">
101 <xsl:call-template name="component.title">
102 <xsl:with-param name="node" select="ancestor::dedication[1]"/>
106 <xsl:template match="dedication/subtitle|dedication/info/subtitle"
107 mode="titlepage.mode" priority="2">
108 <xsl:call-template name="component.subtitle">
109 <xsl:with-param name="node" select="ancestor::dedication[1]"/>
113 <xsl:template match="dedication"></xsl:template> <!-- see mode="dedication" -->
114 <xsl:template match="dedication/title"></xsl:template>
115 <xsl:template match="dedication/subtitle"></xsl:template>
116 <xsl:template match="dedication/titleabbrev"></xsl:template>
118 <!-- ==================================================================== -->
120 <xsl:template match="acknowledgements" mode="acknowledgements">
121 <xsl:call-template name="id.warning"/>
124 <xsl:call-template name="common.html.attributes">
125 <xsl:with-param name="inherit" select="1"/>
127 <xsl:call-template name="id.attribute">
128 <xsl:with-param name="conditional" select="0"/>
130 <xsl:call-template name="acknowledgements.titlepage"/>
131 <xsl:apply-templates/>
132 <xsl:call-template name="process.footnotes"/>
136 <xsl:template match="acknowledgements/title|acknowledgements/info/title"
137 mode="titlepage.mode" priority="2">
138 <xsl:call-template name="component.title">
139 <xsl:with-param name="node" select="ancestor::acknowledgements[1]"/>
143 <xsl:template match="acknowledgements/subtitle|acknowledgements/info/subtitle"
144 mode="titlepage.mode" priority="2">
145 <xsl:call-template name="component.subtitle">
146 <xsl:with-param name="node" select="ancestor::acknowledgements[1]"/>
150 <xsl:template match="acknowledgements"></xsl:template> <!-- see mode="acknowledgements" -->
151 <xsl:template match="acknowledgements/title"></xsl:template>
152 <xsl:template match="acknowledgements/subtitle"></xsl:template>
153 <xsl:template match="acknowledgements/titleabbrev"></xsl:template>
155 <!-- ==================================================================== -->
157 <xsl:template match="colophon">
158 <xsl:call-template name="id.warning"/>
161 <xsl:call-template name="common.html.attributes">
162 <xsl:with-param name="inherit" select="1"/>
164 <xsl:call-template name="id.attribute">
165 <xsl:with-param name="conditional" select="0"/>
168 <xsl:call-template name="component.separator"/>
169 <xsl:call-template name="component.title"/>
170 <xsl:call-template name="component.subtitle"/>
172 <xsl:apply-templates/>
173 <xsl:call-template name="process.footnotes"/>
177 <xsl:template match="colophon/title"></xsl:template>
178 <xsl:template match="colophon/subtitle"></xsl:template>
179 <xsl:template match="colophon/titleabbrev"></xsl:template>
181 <!-- ==================================================================== -->
183 <xsl:template match="preface">
184 <xsl:call-template name="id.warning"/>
186 <xsl:element name="{$div.element}">
187 <xsl:call-template name="common.html.attributes">
188 <xsl:with-param name="inherit" select="1"/>
190 <xsl:call-template name="id.attribute">
191 <xsl:with-param name="conditional" select="0"/>
194 <xsl:call-template name="component.separator"/>
195 <xsl:call-template name="preface.titlepage"/>
197 <xsl:variable name="toc.params">
198 <xsl:call-template name="find.path.params">
199 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
203 <xsl:if test="contains($toc.params, 'toc')">
204 <xsl:call-template name="component.toc">
205 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
207 <xsl:call-template name="component.toc.separator"/>
209 <xsl:apply-templates/>
210 <xsl:call-template name="process.footnotes"/>
214 <xsl:template match="preface/title" mode="titlepage.mode" priority="2">
215 <xsl:call-template name="component.title">
216 <xsl:with-param name="node" select="ancestor::preface[1]"/>
220 <xsl:template match="preface/subtitle
221 |preface/prefaceinfo/subtitle
222 |preface/info/subtitle
223 |preface/docinfo/subtitle"
224 mode="titlepage.mode" priority="2">
225 <xsl:call-template name="component.subtitle">
226 <xsl:with-param name="node" select="ancestor::preface[1]"/>
230 <xsl:template match="preface/docinfo|prefaceinfo"></xsl:template>
231 <xsl:template match="preface/info"></xsl:template>
232 <xsl:template match="preface/title"></xsl:template>
233 <xsl:template match="preface/titleabbrev"></xsl:template>
234 <xsl:template match="preface/subtitle"></xsl:template>
236 <!-- ==================================================================== -->
238 <xsl:template match="chapter">
239 <xsl:call-template name="id.warning"/>
241 <xsl:element name="{$div.element}">
242 <xsl:call-template name="common.html.attributes">
243 <xsl:with-param name="inherit" select="1"/>
245 <xsl:call-template name="id.attribute">
246 <xsl:with-param name="conditional" select="0"/>
249 <xsl:call-template name="component.separator"/>
250 <xsl:call-template name="chapter.titlepage"/>
252 <xsl:variable name="toc.params">
253 <xsl:call-template name="find.path.params">
254 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
257 <xsl:if test="contains($toc.params, 'toc')">
258 <xsl:call-template name="component.toc">
259 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
261 <xsl:call-template name="component.toc.separator"/>
263 <xsl:apply-templates/>
264 <xsl:call-template name="process.footnotes"/>
268 <xsl:template match="chapter/title|chapter/chapterinfo/title|chapter/info/title"
269 mode="titlepage.mode" priority="2">
270 <xsl:call-template name="component.title">
271 <xsl:with-param name="node" select="ancestor::chapter[1]"/>
275 <xsl:template match="chapter/subtitle
276 |chapter/chapterinfo/subtitle
277 |chapter/info/subtitle
278 |chapter/docinfo/subtitle"
279 mode="titlepage.mode" priority="2">
280 <xsl:call-template name="component.subtitle">
281 <xsl:with-param name="node" select="ancestor::chapter[1]"/>
285 <xsl:template match="chapter/docinfo|chapterinfo"></xsl:template>
286 <xsl:template match="chapter/info"></xsl:template>
287 <xsl:template match="chapter/title"></xsl:template>
288 <xsl:template match="chapter/titleabbrev"></xsl:template>
289 <xsl:template match="chapter/subtitle"></xsl:template>
291 <!-- ==================================================================== -->
293 <xsl:template match="appendix">
294 <xsl:variable name="ischunk">
295 <xsl:call-template name="chunk"/>
298 <xsl:call-template name="id.warning"/>
300 <xsl:element name="{$div.element}">
301 <xsl:call-template name="common.html.attributes">
302 <xsl:with-param name="inherit" select="1"/>
304 <xsl:call-template name="id.attribute">
305 <xsl:with-param name="conditional" select="0"/>
309 <xsl:when test="parent::article and $ischunk = 0">
310 <xsl:call-template name="section.heading">
311 <xsl:with-param name="level" select="1"/>
312 <xsl:with-param name="title">
313 <xsl:apply-templates select="." mode="object.title.markup"/>
318 <xsl:call-template name="component.separator"/>
319 <xsl:call-template name="appendix.titlepage"/>
323 <xsl:variable name="toc.params">
324 <xsl:call-template name="find.path.params">
325 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
329 <xsl:if test="contains($toc.params, 'toc')">
330 <xsl:call-template name="component.toc">
331 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
333 <xsl:call-template name="component.toc.separator"/>
336 <xsl:apply-templates/>
338 <xsl:if test="not(parent::article) or $ischunk != 0">
339 <xsl:call-template name="process.footnotes"/>
344 <xsl:template match="appendix/title|appendix/appendixinfo/title"
345 mode="titlepage.mode" priority="2">
346 <xsl:call-template name="component.title">
347 <xsl:with-param name="node" select="ancestor::appendix[1]"/>
351 <xsl:template match="appendix/subtitle
352 |appendix/appendixinfo/subtitle
353 |appendix/info/subtitle
354 |appendix/docinfo/subtitle"
355 mode="titlepage.mode" priority="2">
356 <xsl:call-template name="component.subtitle">
357 <xsl:with-param name="node" select="ancestor::appendix[1]"/>
361 <xsl:template match="appendix/docinfo|appendixinfo"></xsl:template>
362 <xsl:template match="appendix/info"></xsl:template>
363 <xsl:template match="appendix/title"></xsl:template>
364 <xsl:template match="appendix/titleabbrev"></xsl:template>
365 <xsl:template match="appendix/subtitle"></xsl:template>
367 <!-- ==================================================================== -->
369 <xsl:template match="article">
370 <xsl:call-template name="id.warning"/>
372 <xsl:element name="{$div.element}">
373 <xsl:call-template name="common.html.attributes">
374 <xsl:with-param name="inherit" select="1"/>
376 <xsl:call-template name="id.attribute">
377 <xsl:with-param name="conditional" select="0"/>
380 <xsl:call-template name="article.titlepage"/>
382 <xsl:variable name="toc.params">
383 <xsl:call-template name="find.path.params">
384 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
388 <xsl:call-template name="make.lots">
389 <xsl:with-param name="toc.params" select="$toc.params"/>
390 <xsl:with-param name="toc">
391 <xsl:call-template name="component.toc">
392 <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
397 <xsl:apply-templates/>
398 <xsl:call-template name="process.footnotes"/>
402 <xsl:template match="article/title|article/articleinfo/title" mode="titlepage.mode" priority="2">
403 <xsl:call-template name="component.title">
404 <xsl:with-param name="node" select="ancestor::article[1]"/>
408 <xsl:template match="article/subtitle
409 |article/articleinfo/subtitle
410 |article/info/subtitle
411 |article/artheader/subtitle"
412 mode="titlepage.mode" priority="2">
413 <xsl:call-template name="component.subtitle">
414 <xsl:with-param name="node" select="ancestor::article[1]"/>
418 <xsl:template match="article/artheader|article/articleinfo"></xsl:template>
419 <xsl:template match="article/info"></xsl:template>
420 <xsl:template match="article/title"></xsl:template>
421 <xsl:template match="article/titleabbrev"></xsl:template>
422 <xsl:template match="article/subtitle"></xsl:template>
424 <!-- ==================================================================== -->
426 <xsl:template match="topic">
427 <xsl:call-template name="id.warning"/>
429 <xsl:element name="{$div.element}">
430 <xsl:call-template name="common.html.attributes">
431 <xsl:with-param name="inherit" select="1"/>
433 <xsl:call-template name="id.attribute">
434 <xsl:with-param name="conditional" select="0"/>
437 <xsl:call-template name="topic.titlepage"/>
439 <xsl:variable name="toc.params">
440 <xsl:call-template name="find.path.params">
441 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
445 <xsl:apply-templates/>
447 <xsl:call-template name="process.footnotes"/>
451 <xsl:template match="topic/title|topic/info/title" mode="titlepage.mode" priority="2">
452 <xsl:call-template name="component.title">
453 <xsl:with-param name="node" select="ancestor::topic[1]"/>
457 <xsl:template match="topic/subtitle
458 |topic/info/subtitle"
459 mode="titlepage.mode" priority="2">
460 <xsl:call-template name="component.subtitle">
461 <xsl:with-param name="node" select="ancestor::topic[1]"/>
465 <xsl:template match="topic/info"></xsl:template>
466 <xsl:template match="topic/title"></xsl:template>
467 <xsl:template match="topic/titleabbrev"></xsl:template>
468 <xsl:template match="topic/subtitle"></xsl:template>