2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: component.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <!-- ==================================================================== -->
17 <xsl:template name=
"component.title">
18 <xsl:param name=
"node" select=
"."/>
20 <xsl:variable name=
"level">
22 <xsl:when test=
"ancestor::section">
23 <xsl:value-of select=
"count(ancestor::section)+1"/>
25 <xsl:when test=
"ancestor::sect5">6</xsl:when>
26 <xsl:when test=
"ancestor::sect4">5</xsl:when>
27 <xsl:when test=
"ancestor::sect3">4</xsl:when>
28 <xsl:when test=
"ancestor::sect2">3</xsl:when>
29 <xsl:when test=
"ancestor::sect1">2</xsl:when>
30 <xsl:otherwise>1</xsl:otherwise>
34 <!-- Let's handle the case where a component (bibliography, for example)
35 occurs inside a section; will we need parameters for this? -->
37 <xsl:element name=
"h{$level+1}">
38 <xsl:attribute name=
"class">title
</xsl:attribute>
39 <xsl:call-template name=
"anchor">
40 <xsl:with-param name=
"node" select=
"$node"/>
41 <xsl:with-param name=
"conditional" select=
"0"/>
43 <xsl:apply-templates select=
"$node" mode=
"object.title.markup">
44 <xsl:with-param name=
"allow-anchors" select=
"1"/>
45 </xsl:apply-templates>
49 <xsl:template name=
"component.subtitle">
50 <xsl:param name=
"node" select=
"."/>
51 <xsl:variable name=
"subtitle"
52 select=
"($node/docinfo/subtitle
54 |$node/prefaceinfo/subtitle
55 |$node/chapterinfo/subtitle
56 |$node/appendixinfo/subtitle
57 |$node/articleinfo/subtitle
58 |$node/artheader/subtitle
59 |$node/subtitle)[1]"/>
61 <xsl:if test=
"$subtitle">
64 <xsl:apply-templates select=
"$node" mode=
"object.subtitle.markup"/>
70 <xsl:template name=
"component.separator">
73 <!-- ==================================================================== -->
75 <xsl:template match=
"dedication" mode=
"dedication">
76 <xsl:call-template name=
"id.warning"/>
79 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
80 <xsl:call-template name=
"dir">
81 <xsl:with-param name=
"inherit" select=
"1"/>
83 <xsl:call-template name=
"language.attribute"/>
84 <xsl:call-template name=
"dedication.titlepage"/>
85 <xsl:apply-templates/>
86 <xsl:call-template name=
"process.footnotes"/>
90 <xsl:template match=
"dedication/title|dedication/info/title"
91 mode=
"titlepage.mode" priority=
"2">
92 <xsl:call-template name=
"component.title">
93 <xsl:with-param name=
"node" select=
"ancestor::dedication[1]"/>
97 <xsl:template match=
"dedication/subtitle|dedication/info/subtitle"
98 mode=
"titlepage.mode" priority=
"2">
99 <xsl:call-template name=
"component.subtitle">
100 <xsl:with-param name=
"node" select=
"ancestor::dedication[1]"/>
104 <xsl:template match=
"dedication"></xsl:template> <!-- see mode="dedication" -->
105 <xsl:template match=
"dedication/title"></xsl:template>
106 <xsl:template match=
"dedication/subtitle"></xsl:template>
107 <xsl:template match=
"dedication/titleabbrev"></xsl:template>
109 <!-- ==================================================================== -->
111 <xsl:template match=
"colophon">
112 <xsl:call-template name=
"id.warning"/>
115 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
116 <xsl:call-template name=
"dir">
117 <xsl:with-param name=
"inherit" select=
"1"/>
119 <xsl:call-template name=
"language.attribute"/>
120 <xsl:if test=
"$generate.id.attributes != 0">
121 <xsl:attribute name=
"id">
122 <xsl:call-template name=
"object.id"/>
126 <xsl:call-template name=
"component.separator"/>
127 <xsl:call-template name=
"component.title"/>
128 <xsl:call-template name=
"component.subtitle"/>
130 <xsl:apply-templates/>
131 <xsl:call-template name=
"process.footnotes"/>
135 <xsl:template match=
"colophon/title"></xsl:template>
136 <xsl:template match=
"colophon/subtitle"></xsl:template>
137 <xsl:template match=
"colophon/titleabbrev"></xsl:template>
139 <!-- ==================================================================== -->
141 <xsl:template match=
"preface">
142 <xsl:call-template name=
"id.warning"/>
145 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
146 <xsl:call-template name=
"dir">
147 <xsl:with-param name=
"inherit" select=
"1"/>
149 <xsl:call-template name=
"language.attribute"/>
150 <xsl:if test=
"$generate.id.attributes != 0">
151 <xsl:attribute name=
"id">
152 <xsl:call-template name=
"object.id"/>
156 <xsl:call-template name=
"component.separator"/>
157 <xsl:call-template name=
"preface.titlepage"/>
159 <xsl:variable name=
"toc.params">
160 <xsl:call-template name=
"find.path.params">
161 <xsl:with-param name=
"table" select=
"normalize-space($generate.toc)"/>
165 <xsl:if test=
"contains($toc.params, 'toc')">
166 <xsl:call-template name=
"component.toc">
167 <xsl:with-param name=
"toc.title.p" select=
"contains($toc.params, 'title')"/>
169 <xsl:call-template name=
"component.toc.separator"/>
171 <xsl:apply-templates/>
172 <xsl:call-template name=
"process.footnotes"/>
176 <xsl:template match=
"preface/title" mode=
"titlepage.mode" priority=
"2">
177 <xsl:call-template name=
"component.title">
178 <xsl:with-param name=
"node" select=
"ancestor::preface[1]"/>
182 <xsl:template match=
"preface/subtitle
183 |preface/prefaceinfo/subtitle
184 |preface/info/subtitle
185 |preface/docinfo/subtitle"
186 mode=
"titlepage.mode" priority=
"2">
187 <xsl:call-template name=
"component.subtitle">
188 <xsl:with-param name=
"node" select=
"ancestor::preface[1]"/>
192 <xsl:template match=
"preface/docinfo|prefaceinfo"></xsl:template>
193 <xsl:template match=
"preface/info"></xsl:template>
194 <xsl:template match=
"preface/title"></xsl:template>
195 <xsl:template match=
"preface/titleabbrev"></xsl:template>
196 <xsl:template match=
"preface/subtitle"></xsl:template>
198 <!-- ==================================================================== -->
200 <xsl:template match=
"chapter">
201 <xsl:call-template name=
"id.warning"/>
204 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
205 <xsl:call-template name=
"dir">
206 <xsl:with-param name=
"inherit" select=
"1"/>
208 <xsl:call-template name=
"language.attribute"/>
209 <xsl:if test=
"$generate.id.attributes != 0">
210 <xsl:attribute name=
"id">
211 <xsl:call-template name=
"object.id"/>
215 <xsl:call-template name=
"component.separator"/>
216 <xsl:call-template name=
"chapter.titlepage"/>
218 <xsl:variable name=
"toc.params">
219 <xsl:call-template name=
"find.path.params">
220 <xsl:with-param name=
"table" select=
"normalize-space($generate.toc)"/>
223 <xsl:if test=
"contains($toc.params, 'toc')">
224 <xsl:call-template name=
"component.toc">
225 <xsl:with-param name=
"toc.title.p" select=
"contains($toc.params, 'title')"/>
227 <xsl:call-template name=
"component.toc.separator"/>
229 <xsl:apply-templates/>
230 <xsl:call-template name=
"process.footnotes"/>
234 <xsl:template match=
"chapter/title" mode=
"titlepage.mode" priority=
"2">
235 <xsl:call-template name=
"component.title">
236 <xsl:with-param name=
"node" select=
"ancestor::chapter[1]"/>
240 <xsl:template match=
"chapter/subtitle
241 |chapter/chapterinfo/subtitle
242 |chapter/info/subtitle
243 |chapter/docinfo/subtitle"
244 mode=
"titlepage.mode" priority=
"2">
245 <xsl:call-template name=
"component.subtitle">
246 <xsl:with-param name=
"node" select=
"ancestor::chapter[1]"/>
250 <xsl:template match=
"chapter/docinfo|chapterinfo"></xsl:template>
251 <xsl:template match=
"chapter/info"></xsl:template>
252 <xsl:template match=
"chapter/title"></xsl:template>
253 <xsl:template match=
"chapter/titleabbrev"></xsl:template>
254 <xsl:template match=
"chapter/subtitle"></xsl:template>
256 <!-- ==================================================================== -->
258 <xsl:template match=
"appendix">
259 <xsl:variable name=
"ischunk">
260 <xsl:call-template name=
"chunk"/>
263 <xsl:call-template name=
"id.warning"/>
266 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
267 <xsl:call-template name=
"dir">
268 <xsl:with-param name=
"inherit" select=
"1"/>
270 <xsl:call-template name=
"language.attribute"/>
271 <xsl:if test=
"$generate.id.attributes != 0">
272 <xsl:attribute name=
"id">
273 <xsl:call-template name=
"object.id"/>
278 <xsl:when test=
"parent::article and $ischunk = 0">
279 <xsl:call-template name=
"section.heading">
280 <xsl:with-param name=
"level" select=
"1"/>
281 <xsl:with-param name=
"title">
282 <xsl:apply-templates select=
"." mode=
"object.title.markup"/>
287 <xsl:call-template name=
"component.separator"/>
288 <xsl:call-template name=
"appendix.titlepage"/>
292 <xsl:variable name=
"toc.params">
293 <xsl:call-template name=
"find.path.params">
294 <xsl:with-param name=
"table" select=
"normalize-space($generate.toc)"/>
298 <xsl:if test=
"contains($toc.params, 'toc')">
299 <xsl:call-template name=
"component.toc">
300 <xsl:with-param name=
"toc.title.p" select=
"contains($toc.params, 'title')"/>
302 <xsl:call-template name=
"component.toc.separator"/>
305 <xsl:apply-templates/>
307 <xsl:if test=
"not(parent::article) or $ischunk != 0">
308 <xsl:call-template name=
"process.footnotes"/>
313 <xsl:template match=
"appendix/title" mode=
"titlepage.mode" priority=
"2">
314 <xsl:call-template name=
"component.title">
315 <xsl:with-param name=
"node" select=
"ancestor::appendix[1]"/>
319 <xsl:template match=
"appendix/subtitle
320 |appendix/appendixinfo/subtitle
321 |appendix/info/subtitle
322 |appendix/docinfo/subtitle"
323 mode=
"titlepage.mode" priority=
"2">
324 <xsl:call-template name=
"component.subtitle">
325 <xsl:with-param name=
"node" select=
"ancestor::appendix[1]"/>
329 <xsl:template match=
"appendix/docinfo|appendixinfo"></xsl:template>
330 <xsl:template match=
"appendix/info"></xsl:template>
331 <xsl:template match=
"appendix/title"></xsl:template>
332 <xsl:template match=
"appendix/titleabbrev"></xsl:template>
333 <xsl:template match=
"appendix/subtitle"></xsl:template>
335 <!-- ==================================================================== -->
337 <xsl:template match=
"article">
338 <xsl:call-template name=
"id.warning"/>
341 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
342 <xsl:call-template name=
"dir">
343 <xsl:with-param name=
"inherit" select=
"1"/>
345 <xsl:call-template name=
"language.attribute"/>
346 <xsl:if test=
"$generate.id.attributes != 0">
347 <xsl:attribute name=
"id">
348 <xsl:call-template name=
"object.id"/>
352 <xsl:call-template name=
"article.titlepage"/>
354 <xsl:variable name=
"toc.params">
355 <xsl:call-template name=
"find.path.params">
356 <xsl:with-param name=
"table" select=
"normalize-space($generate.toc)"/>
360 <xsl:call-template name=
"make.lots">
361 <xsl:with-param name=
"toc.params" select=
"$toc.params"/>
362 <xsl:with-param name=
"toc">
363 <xsl:call-template name=
"component.toc">
364 <xsl:with-param name=
"toc.title.p" select=
"contains($toc.params, 'title')"/>
369 <xsl:apply-templates/>
370 <xsl:call-template name=
"process.footnotes"/>
374 <xsl:template match=
"article/title" mode=
"titlepage.mode" priority=
"2">
375 <xsl:call-template name=
"component.title">
376 <xsl:with-param name=
"node" select=
"ancestor::article[1]"/>
380 <xsl:template match=
"article/subtitle
381 |article/articleinfo/subtitle
382 |article/info/subtitle
383 |article/artheader/subtitle"
384 mode=
"titlepage.mode" priority=
"2">
385 <xsl:call-template name=
"component.subtitle">
386 <xsl:with-param name=
"node" select=
"ancestor::article[1]"/>
390 <xsl:template match=
"article/artheader|article/articleinfo"></xsl:template>
391 <xsl:template match=
"article/info"></xsl:template>
392 <xsl:template match=
"article/title"></xsl:template>
393 <xsl:template match=
"article/titleabbrev"></xsl:template>
394 <xsl:template match=
"article/subtitle"></xsl:template>
396 <!-- ==================================================================== -->