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 xmlns:exslt="http://exslt.org/common"
7 exclude-result-prefixes="db ng exsl exslt"
10 <xsl:output method="html"
14 <!-- ********************************************************************
15 $Id: docbook.xsl 8783 2010-07-28 10:59:39Z mzjn $
16 ********************************************************************
18 This file is part of the XSL DocBook Stylesheet distribution.
19 See ../README or http://docbook.sf.net/release/xsl/current/ for
20 copyright and other information.
22 ******************************************************************** -->
24 <!-- ==================================================================== -->
26 <xsl:include href="../VERSION"/>
27 <xsl:include href="param.xsl"/>
28 <xsl:include href="../lib/lib.xsl"/>
29 <xsl:include href="../common/l10n.xsl"/>
30 <xsl:include href="../common/common.xsl"/>
31 <xsl:include href="../common/utility.xsl"/>
32 <xsl:include href="../common/labels.xsl"/>
33 <xsl:include href="../common/titles.xsl"/>
34 <xsl:include href="../common/subtitles.xsl"/>
35 <xsl:include href="../common/gentext.xsl"/>
36 <xsl:include href="../common/targets.xsl"/>
37 <xsl:include href="../common/olink.xsl"/>
38 <xsl:include href="../common/pi.xsl"/>
39 <xsl:include href="autotoc.xsl"/>
40 <xsl:include href="autoidx.xsl"/>
41 <xsl:include href="lists.xsl"/>
42 <xsl:include href="callout.xsl"/>
43 <xsl:include href="verbatim.xsl"/>
44 <xsl:include href="graphics.xsl"/>
45 <xsl:include href="xref.xsl"/>
46 <xsl:include href="formal.xsl"/>
47 <xsl:include href="table.xsl"/>
48 <xsl:include href="htmltbl.xsl"/>
49 <xsl:include href="sections.xsl"/>
50 <xsl:include href="inline.xsl"/>
51 <xsl:include href="footnote.xsl"/>
52 <xsl:include href="html.xsl"/>
53 <xsl:include href="info.xsl"/>
54 <xsl:include href="keywords.xsl"/>
55 <xsl:include href="division.xsl"/>
56 <xsl:include href="toc.xsl"/>
57 <xsl:include href="index.xsl"/>
58 <xsl:include href="refentry.xsl"/>
59 <xsl:include href="math.xsl"/>
60 <xsl:include href="admon.xsl"/>
61 <xsl:include href="component.xsl"/>
62 <xsl:include href="biblio.xsl"/>
63 <xsl:include href="biblio-iso690.xsl"/>
64 <xsl:include href="glossary.xsl"/>
65 <xsl:include href="block.xsl"/>
66 <xsl:include href="task.xsl"/>
67 <xsl:include href="qandaset.xsl"/>
68 <xsl:include href="synop.xsl"/>
69 <xsl:include href="titlepage.xsl"/>
70 <xsl:include href="titlepage.templates.xsl"/>
71 <xsl:include href="pi.xsl"/>
72 <xsl:include href="ebnf.xsl"/>
73 <xsl:include href="chunker.xsl"/>
74 <xsl:include href="html-rtf.xsl"/>
75 <xsl:include href="annotations.xsl"/>
76 <xsl:include href="../common/stripns.xsl"/>
78 <xsl:param name="stylesheet.result.type" select="'html'"/>
79 <xsl:param name="htmlhelp.output" select="0"/>
81 <!-- ==================================================================== -->
83 <xsl:key name="id" match="*" use="@id|@xml:id"/>
84 <xsl:key name="gid" match="*" use="generate-id()"/>
86 <!-- ==================================================================== -->
88 <xsl:template match="*">
90 <xsl:text>Element </xsl:text>
91 <xsl:value-of select="local-name(.)"/>
92 <xsl:text> in namespace '</xsl:text>
93 <xsl:value-of select="namespace-uri(.)"/>
94 <xsl:text>' encountered</xsl:text>
95 <xsl:if test="parent::*">
96 <xsl:text> in </xsl:text>
97 <xsl:value-of select="name(parent::*)"/>
99 <xsl:text>, but no template matches.</xsl:text>
102 <span style="color: red">
103 <xsl:text><</xsl:text>
104 <xsl:value-of select="name(.)"/>
105 <xsl:text>></xsl:text>
106 <xsl:apply-templates/>
107 <xsl:text></</xsl:text>
108 <xsl:value-of select="name(.)"/>
109 <xsl:text>></xsl:text>
113 <xsl:template match="text()">
114 <xsl:value-of select="."/>
117 <xsl:template name="body.attributes">
118 <xsl:attribute name="bgcolor">white</xsl:attribute>
119 <xsl:attribute name="text">black</xsl:attribute>
120 <xsl:attribute name="link">#0000FF</xsl:attribute>
121 <xsl:attribute name="vlink">#840084</xsl:attribute>
122 <xsl:attribute name="alink">#0000FF</xsl:attribute>
123 <xsl:if test="starts-with($writing.mode, 'rl')">
124 <xsl:attribute name="dir">rtl</xsl:attribute>
128 <xsl:template name="head.content">
129 <xsl:param name="node" select="."/>
130 <xsl:param name="title">
131 <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/>
135 <xsl:copy-of select="$title"/>
138 <xsl:if test="$html.base != ''">
139 <base href="{$html.base}"/>
142 <!-- Insert links to CSS files or insert literal style elements -->
143 <xsl:call-template name="generate.css"/>
145 <xsl:if test="$html.stylesheet != ''">
146 <xsl:call-template name="output.html.stylesheets">
147 <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/>
151 <xsl:if test="$link.mailto.url != ''">
153 href="{$link.mailto.url}"/>
156 <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
158 <xsl:if test="$generate.meta.abstract != 0">
159 <xsl:variable name="info" select="(articleinfo
175 <xsl:if test="$info and $info/abstract">
176 <meta name="description">
177 <xsl:attribute name="content">
178 <xsl:for-each select="$info/abstract[1]/*">
179 <xsl:value-of select="normalize-space(.)"/>
180 <xsl:if test="position() < last()">
181 <xsl:text> </xsl:text>
189 <xsl:if test="($draft.mode = 'yes' or
190 ($draft.mode = 'maybe' and
191 ancestor-or-self::*[@status][1]/@status = 'draft'))
192 and $draft.watermark.image != ''">
193 <style type="text/css"><xsl:text>
194 body { background-image: url('</xsl:text>
195 <xsl:value-of select="$draft.watermark.image"/><xsl:text>');
196 background-repeat: no-repeat;
197 background-position: top left;
198 /* The following properties make the watermark "fixed" on the page. */
199 /* I think that's just a bit too distracting for the reader... */
200 /* background-attachment: fixed; */
201 /* background-position: center center; */
205 <xsl:apply-templates select="." mode="head.keywords.content"/>
208 <xsl:template name="output.html.stylesheets">
209 <xsl:param name="stylesheets" select="''"/>
212 <xsl:when test="contains($stylesheets, ' ')">
213 <xsl:variable name="css.filename" select="substring-before($stylesheets, ' ')"/>
215 <xsl:call-template name="make.css.link">
216 <xsl:with-param name="css.filename" select="$css.filename"/>
219 <xsl:call-template name="output.html.stylesheets">
220 <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
223 <xsl:when test="$stylesheets != ''">
224 <xsl:call-template name="make.css.link">
225 <xsl:with-param name="css.filename" select="$stylesheets"/>
231 <!-- ============================================================ -->
233 <xsl:template match="*" mode="head.keywords.content">
234 <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/>
235 <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/>
236 <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/>
237 <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/>
238 <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/>
239 <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/>
240 <xsl:apply-templates select="artheader/keywordset" mode="html.header"/>
241 <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/>
242 <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/>
243 <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/>
244 <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/>
245 <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/>
246 <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/>
247 <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/>
248 <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/>
249 <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/>
250 <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/>
251 <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/>
252 <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/>
253 <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/>
254 <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/>
255 <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/>
256 <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/>
257 <xsl:apply-templates select="info/keywordset" mode="html.header"/>
259 <xsl:if test="$inherit.keywords != 0
261 <xsl:apply-templates select="parent::*" mode="head.keywords.content"/>
265 <!-- ============================================================ -->
267 <xsl:template name="system.head.content">
268 <xsl:param name="node" select="."/>
270 <!-- FIXME: When chunking, only the annotations actually used
271 in this chunk should be referenced. I don't think it
272 does any harm to reference them all, but it adds
273 unnecessary bloat to each chunk. -->
274 <xsl:if test="$annotation.support != 0 and //annotation">
275 <xsl:call-template name="add.annotation.links"/>
276 <script type="text/javascript">
277 <xsl:text> // Create PopupWindow objects</xsl:text>
278 <xsl:for-each select="//annotation">
279 <xsl:text> var popup_</xsl:text>
280 <xsl:value-of select="generate-id(.)"/>
281 <xsl:text> = new PopupWindow("popup-</xsl:text>
282 <xsl:value-of select="generate-id(.)"/>
283 <xsl:text>"); </xsl:text>
284 <xsl:text>popup_</xsl:text>
285 <xsl:value-of select="generate-id(.)"/>
286 <xsl:text>.offsetY = 15; </xsl:text>
287 <xsl:text>popup_</xsl:text>
288 <xsl:value-of select="generate-id(.)"/>
289 <xsl:text>.autoHide(); </xsl:text>
293 <style type="text/css">
294 <xsl:value-of select="$annotation.css"/>
298 <!-- system.head.content is like user.head.content, except that
299 it is called before head.content. This is important because it
300 means, for example, that <style> elements output by system.head.content
301 have a lower CSS precedence than the users stylesheet. -->
304 <!-- ============================================================ -->
306 <xsl:template name="user.preroot">
307 <!-- Pre-root output, can be used to output comments and PIs. -->
308 <!-- This must not output any element content! -->
311 <xsl:template name="user.head.content">
312 <xsl:param name="node" select="."/>
315 <xsl:template name="user.header.navigation">
316 <xsl:param name="node" select="."/>
319 <xsl:template name="user.header.content">
320 <xsl:param name="node" select="."/>
323 <xsl:template name="user.footer.content">
324 <xsl:param name="node" select="."/>
327 <xsl:template name="user.footer.navigation">
328 <xsl:param name="node" select="."/>
331 <xsl:template match="/">
332 <!-- * Get a title for current doc so that we let the user -->
333 <!-- * know what document we are processing at this point. -->
334 <xsl:variable name="doc.title">
335 <xsl:call-template name="get.doc.title"/>
338 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
339 toss the namespace and continue. Use the docbook5 namespaced
340 stylesheets for DocBook5 if you don't want to use this feature.-->
341 <!-- include extra test for Xalan quirk -->
342 <xsl:when test="$exsl.node.set.available != 0
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>
350 <xsl:with-param name="message">
351 <xsl:text>stripped namespace before processing</xsl:text>
354 <xsl:variable name="nons">
355 <xsl:apply-templates mode="stripNS"/>
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)"/>
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>
373 <xsl:with-param name="message">
374 <xsl:text>processing stripped document</xsl:text>
377 <xsl:apply-templates select="exsl:node-set($nons)"/>
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>
388 <xsl:when test="$rootid != ''">
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>
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"/>
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"/>
415 <xsl:if test="$collect.xref.targets = 'yes' or
416 $collect.xref.targets = 'only'">
417 <xsl:apply-templates select="/" mode="collect.targets"/>
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"/>
431 <xsl:template match="*" mode="process.root">
432 <xsl:variable name="doc" select="self::*"/>
434 <xsl:call-template name="user.preroot"/>
435 <xsl:call-template name="root.messages"/>
439 <xsl:call-template name="system.head.content">
440 <xsl:with-param name="node" select="$doc"/>
442 <xsl:call-template name="head.content">
443 <xsl:with-param name="node" select="$doc"/>
445 <xsl:call-template name="user.head.content">
446 <xsl:with-param name="node" select="$doc"/>
450 <xsl:call-template name="body.attributes"/>
451 <xsl:call-template name="user.header.content">
452 <xsl:with-param name="node" select="$doc"/>
454 <xsl:apply-templates select="."/>
455 <xsl:call-template name="user.footer.content">
456 <xsl:with-param name="node" select="$doc"/>
460 <xsl:value-of select="$html.append"/>
462 <!-- Generate any css files only once, not once per chunk -->
463 <xsl:call-template name="generate.css.files"/>
466 <xsl:template name="root.messages">
467 <!-- redefine this any way you'd like to output messages -->
468 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
471 <!-- ==================================================================== -->
473 <xsl:template name="chunk">
474 <xsl:param name="node" select="."/>
476 <!-- The default is that we are not chunking... -->
477 <xsl:text>0</xsl:text>