Imported Upstream version 1.77.1
[platform/upstream/docbook-xsl.git] / html / component.xsl
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 version='1.0'>
4
5 <!-- ********************************************************************
6      $Id: component.xsl 9356 2012-05-12 23:33:15Z bobstayton $
7      ********************************************************************
8
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.
12
13      ******************************************************************** -->
14
15 <!-- ==================================================================== -->
16
17 <!-- Set to 2 for backwards compatibility -->
18 <xsl:param name="component.heading.level" select="2"/>
19
20 <xsl:template name="component.title">
21   <xsl:param name="node" select="."/>
22
23   <!-- This handles the case where a component (bibliography, for example)
24        occurs inside a section; will we need parameters for this? -->
25
26   <!-- This "level" is a section level.  To compute <h> level, add 1. -->
27   <xsl:variable name="level">
28     <xsl:choose>
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"/>
33       </xsl:when>
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>
40     </xsl:choose>
41   </xsl:variable>
42
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"/>
49     </xsl:call-template>
50     <xsl:apply-templates select="$node" mode="object.title.markup">
51       <xsl:with-param name="allow-anchors" select="1"/>
52     </xsl:apply-templates>
53   </xsl:element>
54 </xsl:template>
55
56 <xsl:template name="component.subtitle">
57   <xsl:param name="node" select="."/>
58   <xsl:variable name="subtitle"
59                 select="($node/docinfo/subtitle
60                         |$node/info/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]"/>
67
68   <xsl:if test="$subtitle">
69     <h3 class="subtitle">
70       <xsl:call-template name="id.attribute"/>
71       <i>
72         <xsl:apply-templates select="$node" mode="object.subtitle.markup"/>
73       </i>
74     </h3>
75   </xsl:if>
76 </xsl:template>
77
78 <xsl:template name="component.separator">
79 </xsl:template>
80
81 <!-- ==================================================================== -->
82
83 <xsl:template match="dedication" mode="dedication">
84   <xsl:call-template name="id.warning"/>
85
86   <div>
87     <xsl:call-template name="common.html.attributes">
88       <xsl:with-param name="inherit" select="1"/>
89     </xsl:call-template>
90     <xsl:call-template name="id.attribute">
91       <xsl:with-param name="conditional" select="0"/>
92     </xsl:call-template>
93     <xsl:call-template name="dedication.titlepage"/>
94     <xsl:apply-templates/>
95     <xsl:call-template name="process.footnotes"/>
96   </div>
97 </xsl:template>
98
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]"/>
103   </xsl:call-template>
104 </xsl:template>
105
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]"/>
110   </xsl:call-template>
111 </xsl:template>
112
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>
117
118 <!-- ==================================================================== -->
119
120 <xsl:template match="acknowledgements" mode="acknowledgements">
121   <xsl:call-template name="id.warning"/>
122
123   <div>
124     <xsl:call-template name="common.html.attributes">
125       <xsl:with-param name="inherit" select="1"/>
126     </xsl:call-template>
127     <xsl:call-template name="id.attribute">
128       <xsl:with-param name="conditional" select="0"/>
129     </xsl:call-template>
130     <xsl:call-template name="acknowledgements.titlepage"/>
131     <xsl:apply-templates/>
132     <xsl:call-template name="process.footnotes"/>
133   </div>
134 </xsl:template>
135
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]"/>
140   </xsl:call-template>
141 </xsl:template>
142
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]"/>
147   </xsl:call-template>
148 </xsl:template>
149
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>
154
155 <!-- ==================================================================== -->
156
157 <xsl:template match="colophon">
158   <xsl:call-template name="id.warning"/>
159
160   <div>
161     <xsl:call-template name="common.html.attributes">
162       <xsl:with-param name="inherit" select="1"/>
163     </xsl:call-template>
164     <xsl:call-template name="id.attribute">
165       <xsl:with-param name="conditional" select="0"/>
166     </xsl:call-template>
167
168     <xsl:call-template name="component.separator"/>
169     <xsl:call-template name="component.title"/>
170     <xsl:call-template name="component.subtitle"/>
171
172     <xsl:apply-templates/>
173     <xsl:call-template name="process.footnotes"/>
174   </div>
175 </xsl:template>
176
177 <xsl:template match="colophon/title"></xsl:template>
178 <xsl:template match="colophon/subtitle"></xsl:template>
179 <xsl:template match="colophon/titleabbrev"></xsl:template>
180
181 <!-- ==================================================================== -->
182
183 <xsl:template match="preface">
184   <xsl:call-template name="id.warning"/>
185
186   <xsl:element name="{$div.element}">
187     <xsl:call-template name="common.html.attributes">
188       <xsl:with-param name="inherit" select="1"/>
189     </xsl:call-template>
190     <xsl:call-template name="id.attribute">
191       <xsl:with-param name="conditional" select="0"/>
192     </xsl:call-template>
193
194     <xsl:call-template name="component.separator"/>
195     <xsl:call-template name="preface.titlepage"/>
196
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)"/>
200       </xsl:call-template>
201     </xsl:variable>
202
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')"/>
206       </xsl:call-template>
207       <xsl:call-template name="component.toc.separator"/>
208     </xsl:if>
209     <xsl:apply-templates/>
210     <xsl:call-template name="process.footnotes"/>
211   </xsl:element>
212 </xsl:template>
213
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]"/>
217   </xsl:call-template>
218 </xsl:template>
219
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]"/>
227   </xsl:call-template>
228 </xsl:template>
229
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>
235
236 <!-- ==================================================================== -->
237
238 <xsl:template match="chapter">
239   <xsl:call-template name="id.warning"/>
240
241   <xsl:element name="{$div.element}">
242     <xsl:call-template name="common.html.attributes">
243       <xsl:with-param name="inherit" select="1"/>
244     </xsl:call-template>
245     <xsl:call-template name="id.attribute">
246       <xsl:with-param name="conditional" select="0"/>
247     </xsl:call-template>
248
249     <xsl:call-template name="component.separator"/>
250     <xsl:call-template name="chapter.titlepage"/>
251
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)"/>
255       </xsl:call-template>
256     </xsl:variable>
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')"/>
260       </xsl:call-template>
261       <xsl:call-template name="component.toc.separator"/>
262     </xsl:if>
263     <xsl:apply-templates/>
264     <xsl:call-template name="process.footnotes"/>
265   </xsl:element>
266 </xsl:template>
267
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]"/>
272   </xsl:call-template>
273 </xsl:template>
274
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]"/>
282   </xsl:call-template>
283 </xsl:template>
284
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>
290
291 <!-- ==================================================================== -->
292
293 <xsl:template match="appendix">
294   <xsl:variable name="ischunk">
295     <xsl:call-template name="chunk"/>
296   </xsl:variable>
297
298   <xsl:call-template name="id.warning"/>
299
300   <xsl:element name="{$div.element}">
301     <xsl:call-template name="common.html.attributes">
302       <xsl:with-param name="inherit" select="1"/>
303     </xsl:call-template>
304     <xsl:call-template name="id.attribute">
305       <xsl:with-param name="conditional" select="0"/>
306     </xsl:call-template>
307
308     <xsl:choose>
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"/>
314           </xsl:with-param>
315         </xsl:call-template>
316       </xsl:when>
317       <xsl:otherwise>
318         <xsl:call-template name="component.separator"/>
319         <xsl:call-template name="appendix.titlepage"/>
320       </xsl:otherwise>
321     </xsl:choose>
322
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)"/>
326       </xsl:call-template>
327     </xsl:variable>
328
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')"/>
332       </xsl:call-template>
333       <xsl:call-template name="component.toc.separator"/>
334     </xsl:if>
335
336     <xsl:apply-templates/>
337
338     <xsl:if test="not(parent::article) or $ischunk != 0">
339       <xsl:call-template name="process.footnotes"/>
340     </xsl:if>
341   </xsl:element>
342 </xsl:template>
343
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]"/>
348   </xsl:call-template>
349 </xsl:template>
350
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]"/>
358   </xsl:call-template>
359 </xsl:template>
360
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>
366
367 <!-- ==================================================================== -->
368
369 <xsl:template match="article">
370   <xsl:call-template name="id.warning"/>
371
372   <xsl:element name="{$div.element}">
373     <xsl:call-template name="common.html.attributes">
374       <xsl:with-param name="inherit" select="1"/>
375     </xsl:call-template>
376     <xsl:call-template name="id.attribute">
377       <xsl:with-param name="conditional" select="0"/>
378     </xsl:call-template>
379
380     <xsl:call-template name="article.titlepage"/>
381
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)"/>
385       </xsl:call-template>
386     </xsl:variable>
387
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')"/>
393         </xsl:call-template>
394       </xsl:with-param>
395     </xsl:call-template>
396
397     <xsl:apply-templates/>
398     <xsl:call-template name="process.footnotes"/>
399   </xsl:element>
400 </xsl:template>
401
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]"/>
405   </xsl:call-template>
406 </xsl:template>
407
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]"/>
415   </xsl:call-template>
416 </xsl:template>
417
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>
423
424 <!-- ==================================================================== -->
425
426 <xsl:template match="topic">
427   <xsl:call-template name="id.warning"/>
428
429   <xsl:element name="{$div.element}">
430     <xsl:call-template name="common.html.attributes">
431       <xsl:with-param name="inherit" select="1"/>
432     </xsl:call-template>
433     <xsl:call-template name="id.attribute">
434       <xsl:with-param name="conditional" select="0"/>
435     </xsl:call-template>
436
437     <xsl:call-template name="topic.titlepage"/>
438
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)"/>
442       </xsl:call-template>
443     </xsl:variable>
444
445     <xsl:apply-templates/>
446
447     <xsl:call-template name="process.footnotes"/>
448   </xsl:element>
449 </xsl:template>
450
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]"/>
454   </xsl:call-template>
455 </xsl:template>
456
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]"/>
462   </xsl:call-template>
463 </xsl:template>
464
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>
469
470 </xsl:stylesheet>
471