Debian Codegraph @

docs/xsl-generic/html/docbook.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:ng="http://docbook.org/docbook-ng"
4 xmlns:db="http://docbook.org/ns/docbook"
5 xmlns:exsl="http://exslt.org/common"
6 exclude-result-prefixes="db ng exsl"
7 version='1.0'>
8
9 <xsl:output method="html"
10 encoding="ISO-8859-1"
11 indent="no"/>
12
13 <!-- ********************************************************************
14 $Id: docbook.xsl 7156 2007-07-26 21:42:04Z mzjn $
15 ********************************************************************
16
17 This file is part of the XSL DocBook Stylesheet distribution.
18 See ../README or http://docbook.sf.net/release/xsl/current/ for
19 copyright and other information.
20
21 ******************************************************************** -->
22
23 <!-- ==================================================================== -->
24
25 <xsl:include href="../VERSION"/>
26 <xsl:include href="param.xsl"/>
27 <xsl:include href="../lib/lib.xsl"/>
28 <xsl:include href="../common/l10n.xsl"/>
29 <xsl:include href="../common/common.xsl"/>
30 <xsl:include href="../common/utility.xsl"/>
31 <xsl:include href="../common/labels.xsl"/>
32 <xsl:include href="../common/titles.xsl"/>
33 <xsl:include href="../common/subtitles.xsl"/>
34 <xsl:include href="../common/gentext.xsl"/>
35 <xsl:include href="../common/targets.xsl"/>
36 <xsl:include href="../common/olink.xsl"/>
37 <xsl:include href="../common/pi.xsl"/>
38 <xsl:include href="autotoc.xsl"/>
39 <xsl:include href="autoidx.xsl"/>
40 <xsl:include href="lists.xsl"/>
41 <xsl:include href="callout.xsl"/>
42 <xsl:include href="verbatim.xsl"/>
43 <xsl:include href="graphics.xsl"/>
44 <xsl:include href="xref.xsl"/>
45 <xsl:include href="formal.xsl"/>
46 <xsl:include href="table.xsl"/>
47 <xsl:include href="htmltbl.xsl"/>
48 <xsl:include href="sections.xsl"/>
49 <xsl:include href="inline.xsl"/>
50 <xsl:include href="footnote.xsl"/>
51 <xsl:include href="html.xsl"/>
52 <xsl:include href="info.xsl"/>
53 <xsl:include href="keywords.xsl"/>
54 <xsl:include href="division.xsl"/>
55 <xsl:include href="toc.xsl"/>
56 <xsl:include href="index.xsl"/>
57 <xsl:include href="refentry.xsl"/>
58 <xsl:include href="math.xsl"/>
59 <xsl:include href="admon.xsl"/>
60 <xsl:include href="component.xsl"/>
61 <xsl:include href="biblio.xsl"/>
62 <xsl:include href="biblio-iso690.xsl"/>
63 <xsl:include href="glossary.xsl"/>
64 <xsl:include href="block.xsl"/>
65 <xsl:include href="task.xsl"/>
66 <xsl:include href="qandaset.xsl"/>
67 <xsl:include href="synop.xsl"/>
68 <xsl:include href="titlepage.xsl"/>
69 <xsl:include href="titlepage.templates.xsl"/>
70 <xsl:include href="pi.xsl"/>
71 <xsl:include href="ebnf.xsl"/>
72 <xsl:include href="chunker.xsl"/>
73 <xsl:include href="html-rtf.xsl"/>
74 <xsl:include href="annotations.xsl"/>
75 <xsl:include href="../common/stripns.xsl"/>
76
77 <xsl:param name="stylesheet.result.type" select="'html'"/>
78 <xsl:param name="htmlhelp.output" select="0"/>
79
80 <!-- ==================================================================== -->
81
82 <xsl:key name="id" match="*" use="@id|@xml:id"/>
83 <xsl:key name="gid" match="*" use="generate-id()"/>
84
85 <!-- ==================================================================== -->
86
87 <xsl:template match="*">
88 <xsl:message>
89 <xsl:text>Element </xsl:text>
90 <xsl:value-of select="local-name(.)"/>
91 <xsl:text> in namespace '</xsl:text>
92 <xsl:value-of select="namespace-uri(.)"/>
93 <xsl:text>' encountered</xsl:text>
94 <xsl:if test="parent::*">
95 <xsl:text> in </xsl:text>
96 <xsl:value-of select="name(parent::*)"/>
97 </xsl:if>
98 <xsl:text>, but no template matches.</xsl:text>
99 </xsl:message>
100
101 <span style="color: red">
102 <xsl:text>&lt;</xsl:text>
103 <xsl:value-of select="name(.)"/>
104 <xsl:text>&gt;</xsl:text>
105 <xsl:apply-templates/>
106 <xsl:text>&lt;/</xsl:text>
107 <xsl:value-of select="name(.)"/>
108 <xsl:text>&gt;</xsl:text>
109 </span>
110 </xsl:template>
111
112 <xsl:template match="text()">
113 <xsl:value-of select="."/>
114 </xsl:template>
115
116 <xsl:template name="body.attributes">
117 <xsl:attribute name="bgcolor">white</xsl:attribute>
118 <xsl:attribute name="text">black</xsl:attribute>
119 <xsl:attribute name="link">#0000FF</xsl:attribute>
120 <xsl:attribute name="vlink">#840084</xsl:attribute>
121 <xsl:attribute name="alink">#0000FF</xsl:attribute>
122 </xsl:template>
123
124 <xsl:template name="head.content">
125 <xsl:param name="node" select="."/>
126 <xsl:param name="title">
127 <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/>
128 </xsl:param>
129
130 <title>
131 <xsl:copy-of select="$title"/>
132 </title>
133
134 <xsl:if test="$html.stylesheet != ''">
135 <xsl:call-template name="output.html.stylesheets">
136 <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/>
137 </xsl:call-template>
138 </xsl:if>
139
140 <xsl:if test="$link.mailto.url != ''">
141 <link rev="made"
142 href="{$link.mailto.url}"/>
143 </xsl:if>
144
145 <xsl:if test="$html.base != ''">
146 <base href="{$html.base}"/>
147 </xsl:if>
148
149 <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
150
151 <xsl:if test="$generate.meta.abstract != 0">
152 <xsl:variable name="info" select="(articleinfo
153 |bookinfo
154 |prefaceinfo
155 |chapterinfo
156 |appendixinfo
157 |sectioninfo
158 |sect1info
159 |sect2info
160 |sect3info
161 |sect4info
162 |sect5info
163 |referenceinfo
164 |refentryinfo
165 |partinfo
166 |info
167 |docinfo)[1]"/>
168 <xsl:if test="$info and $info/abstract">
169 <meta name="description">
170 <xsl:attribute name="content">
171 <xsl:for-each select="$info/abstract[1]/*">
172 <xsl:value-of select="normalize-space(.)"/>
173 <xsl:if test="position() &lt; last()">
174 <xsl:text> </xsl:text>
175 </xsl:if>
176 </xsl:for-each>
177 </xsl:attribute>
178 </meta>
179 </xsl:if>
180 </xsl:if>
181
182 <xsl:if test="($draft.mode = 'yes' or
183 ($draft.mode = 'maybe' and
184 ancestor-or-self::*[@status][1]/@status = 'draft'))
185 and $draft.watermark.image != ''">
186 <style type="text/css"><xsl:text>
187 body { background-image: url('</xsl:text>
188 <xsl:value-of select="$draft.watermark.image"/><xsl:text>');
189 background-repeat: no-repeat;
190 background-position: top left;
191 /* The following properties make the watermark "fixed" on the page. */
192 /* I think that's just a bit too distracting for the reader... */
193 /* background-attachment: fixed; */
194 /* background-position: center center; */
195 }</xsl:text>
196 </style>
197 </xsl:if>
198 <xsl:apply-templates select="." mode="head.keywords.content"/>
199 </xsl:template>
200
201 <xsl:template name="output.html.stylesheets">
202 <xsl:param name="stylesheets" select="''"/>
203
204 <xsl:choose>
205 <xsl:when test="contains($stylesheets, ' ')">
206 <link rel="stylesheet" href="{substring-before($stylesheets, ' ')}">
207 <xsl:if test="$html.stylesheet.type != ''">
208 <xsl:attribute name="type">
209 <xsl:value-of select="$html.stylesheet.type"/>
210 </xsl:attribute>
211 </xsl:if>
212 </link>
213 <xsl:call-template name="output.html.stylesheets">
214 <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
215 </xsl:call-template>
216 </xsl:when>
217 <xsl:when test="$stylesheets != ''">
218 <link rel="stylesheet" href="{$stylesheets}">
219 <xsl:if test="$html.stylesheet.type != ''">
220 <xsl:attribute name="type">
221 <xsl:value-of select="$html.stylesheet.type"/>
222 </xsl:attribute>
223 </xsl:if>
224 </link>
225 </xsl:when>
226 </xsl:choose>
227 </xsl:template>
228
229 <!-- ============================================================ -->
230
231 <xsl:template match="*" mode="head.keywords.content">
232 <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/>
233 <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/>
234 <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/>
235 <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/>
236 <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/>
237 <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/>
238 <xsl:apply-templates select="artheader/keywordset" mode="html.header"/>
239 <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/>
240 <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/>
241 <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/>
242 <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/>
243 <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/>
244 <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/>
245 <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/>
246 <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/>
247 <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/>
248 <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/>
249 <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/>
250 <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/>
251 <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/>
252 <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/>
253 <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/>
254 <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/>
255 <xsl:apply-templates select="info/keywordset" mode="html.header"/>
256
257 <xsl:if test="$inherit.keywords != 0
258 and parent::*">
259 <xsl:apply-templates select="parent::*" mode="head.keywords.content"/>
260 </xsl:if>
261 </xsl:template>
262
263 <!-- ============================================================ -->
264
265 <xsl:template name="system.head.content">
266 <xsl:param name="node" select="."/>
267
268 <!-- FIXME: When chunking, only the annotations actually used
269 in this chunk should be referenced. I don't think it
270 does any harm to reference them all, but it adds
271 unnecessary bloat to each chunk. -->
272 <xsl:if test="$annotation.support != 0 and //annotation">
273 <xsl:call-template name="add.annotation.links"/>
274 <script type="text/javascript">
275 <xsl:text>&#10;// Create PopupWindow objects</xsl:text>
276 <xsl:for-each select="//annotation">
277 <xsl:text>&#10;var popup_</xsl:text>
278 <xsl:value-of select="generate-id(.)"/>
279 <xsl:text> = new PopupWindow("popup-</xsl:text>
280 <xsl:value-of select="generate-id(.)"/>
281 <xsl:text>");&#10;</xsl:text>
282 <xsl:text>popup_</xsl:text>
283 <xsl:value-of select="generate-id(.)"/>
284 <xsl:text>.offsetY = 15;&#10;</xsl:text>
285 <xsl:text>popup_</xsl:text>
286 <xsl:value-of select="generate-id(.)"/>
287 <xsl:text>.autoHide();&#10;</xsl:text>
288 </xsl:for-each>
289 </script>
290
291 <style type="text/css">
292 <xsl:value-of select="$annotation.css"/>
293 </style>
294 </xsl:if>
295
296 <!-- system.head.content is like user.head.content, except that
297 it is called before head.content. This is important because it
298 means, for example, that <style> elements output by system.head.content
299 have a lower CSS precedence than the users stylesheet. -->
300 </xsl:template>
301
302 <!-- ============================================================ -->
303
304 <xsl:template name="user.preroot">
305 <!-- Pre-root output, can be used to output comments and PIs. -->
306 <!-- This must not output any element content! -->
307 </xsl:template>
308
309 <xsl:template name="user.head.content">
310 <xsl:param name="node" select="."/>
311 </xsl:template>
312
313 <xsl:template name="user.header.navigation">
314 <xsl:param name="node" select="."/>
315 </xsl:template>
316
317 <xsl:template name="user.header.content">
318 <xsl:param name="node" select="."/>
319 </xsl:template>
320
321 <xsl:template name="user.footer.content">
322 <xsl:param name="node" select="."/>
323 </xsl:template>
324
325 <xsl:template name="user.footer.navigation">
326 <xsl:param name="node" select="."/>
327 </xsl:template>
328
329 <xsl:template match="/">
330 <!-- * Get a title for current doc so that we let the user -->
331 <!-- * know what document we are processing at this point. -->
332 <xsl:variable name="doc.title">
333 <xsl:call-template name="get.doc.title"/>
334 </xsl:variable>
335 <xsl:choose>
336 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
337 toss the namespace and continue. Use the docbook5 namespaced
338 stylesheets for DocBook5 if you don't want to use this feature.-->
339 <!-- include extra test for Xalan quirk -->
340 <xsl:when test="(function-available('exsl:node-set') or
341 contains(system-property('xsl:vendor'),
342 'Apache Software Foundation'))
343 and (*/self::ng:* or */self::db:*)">
344 <xsl:call-template name="log.message">
345 <xsl:with-param name="level">Note</xsl:with-param>
346 <xsl:with-param name="source" select="$doc.title"/>
347 <xsl:with-param name="context-desc">
348 <xsl:text>namesp. cut</xsl:text>
349 </xsl:with-param>
350 <xsl:with-param name="message">
351 <xsl:text>stripped namespace before processing</xsl:text>
352 </xsl:with-param>
353 </xsl:call-template>
354 <xsl:variable name="nons">
355 <xsl:apply-templates mode="stripNS"/>
356 </xsl:variable>
357 <!--
358 <xsl:message>Saving stripped document.</xsl:message>
359 <xsl:call-template name="write.chunk">
360 <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/>
361 <xsl:with-param name="method" select="'xml'"/>
362 <xsl:with-param name="content">
363 <xsl:copy-of select="exsl:node-set($nons)"/>
364 </xsl:with-param>
365 </xsl:call-template>
366 -->
367 <xsl:call-template name="log.message">
368 <xsl:with-param name="level">Note</xsl:with-param>
369 <xsl:with-param name="source" select="$doc.title"/>
370 <xsl:with-param name="context-desc">
371 <xsl:text>namesp. cut</xsl:text>
372 </xsl:with-param>
373 <xsl:with-param name="message">
374 <xsl:text>processing stripped document</xsl:text>
375 </xsl:with-param>
376 </xsl:call-template>
377 <xsl:apply-templates select="exsl:node-set($nons)"/>
378 </xsl:when>
379 <!-- Can't process unless namespace removed -->
380 <xsl:when test="*/self::ng:* or */self::db:*">
381 <xsl:message terminate="yes">
382 <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
383 <xsl:text> cannot proceed.</xsl:text>
384 </xsl:message>
385 </xsl:when>
386 <xsl:otherwise>
387 <xsl:choose>
388 <xsl:when test="$rootid != ''">
389 <xsl:choose>
390 <xsl:when test="count(key('id',$rootid)) = 0">
391 <xsl:message terminate="yes">
392 <xsl:text>ID '</xsl:text>
393 <xsl:value-of select="$rootid"/>
394 <xsl:text>' not found in document.</xsl:text>
395 </xsl:message>
396 </xsl:when>
397 <xsl:otherwise>
398 <xsl:if test="$collect.xref.targets = 'yes' or
399 $collect.xref.targets = 'only'">
400 <xsl:apply-templates select="key('id', $rootid)"
401 mode="collect.targets"/>
402 </xsl:if>
403 <xsl:if test="$collect.xref.targets != 'only'">
404 <xsl:apply-templates select="key('id',$rootid)"
405 mode="process.root"/>
406 <xsl:if test="$tex.math.in.alt != ''">
407 <xsl:apply-templates select="key('id',$rootid)"
408 mode="collect.tex.math"/>
409 </xsl:if>
410 </xsl:if>
411 </xsl:otherwise>
412 </xsl:choose>
413 </xsl:when>
414 <xsl:otherwise>
415 <xsl:if test="$collect.xref.targets = 'yes' or
416 $collect.xref.targets = 'only'">
417 <xsl:apply-templates select="/" mode="collect.targets"/>
418 </xsl:if>
419 <xsl:if test="$collect.xref.targets != 'only'">
420 <xsl:apply-templates select="/" mode="process.root"/>
421 <xsl:if test="$tex.math.in.alt != ''">
422 <xsl:apply-templates select="/" mode="collect.tex.math"/>
423 </xsl:if>
424 </xsl:if>
425 </xsl:otherwise>
426 </xsl:choose>
427 </xsl:otherwise>
428 </xsl:choose>
429 </xsl:template>
430
431 <xsl:template match="*" mode="process.root">
432 <xsl:variable name="doc" select="self::*"/>
433
434 <xsl:call-template name="user.preroot"/>
435 <xsl:call-template name="root.messages"/>
436
437 <html>
438 <head>
439 <xsl:call-template name="system.head.content">
440 <xsl:with-param name="node" select="$doc"/>
441 </xsl:call-template>
442 <xsl:call-template name="head.content">
443 <xsl:with-param name="node" select="$doc"/>
444 </xsl:call-template>
445 <xsl:call-template name="user.head.content">
446 <xsl:with-param name="node" select="$doc"/>
447 </xsl:call-template>
448 </head>
449 <body>
450 <xsl:call-template name="body.attributes"/>
451 <xsl:call-template name="user.header.content">
452 <xsl:with-param name="node" select="$doc"/>
453 </xsl:call-template>
454 <xsl:apply-templates select="."/>
455 <xsl:call-template name="user.footer.content">
456 <xsl:with-param name="node" select="$doc"/>
457 </xsl:call-template>
458 </body>
459 </html>
460 <xsl:value-of select="$html.append"/>
461 </xsl:template>
462
463 <xsl:template name="root.messages">
464 <!-- redefine this any way you'd like to output messages -->
465 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
466 </xsl:template>
467
468 <!-- ==================================================================== -->
469
470 <xsl:template name="chunk">
471 <xsl:param name="node" select="."/>
472
473 <!-- The default is that we are not chunking... -->
474 <xsl:text>0</xsl:text>
475 </xsl:template>
476
477 <!-- ==================================================================== -->
478
479 </xsl:stylesheet>