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 8399 2009-04-08 07:37:42Z bobstayton $
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.stylesheet != ''">
139 <xsl:call-template name="output.html.stylesheets">
140 <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/>
144 <xsl:if test="$link.mailto.url != ''">
146 href="{$link.mailto.url}"/>
149 <xsl:if test="$html.base != ''">
150 <base href="{$html.base}"/>
153 <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
155 <xsl:if test="$generate.meta.abstract != 0">
156 <xsl:variable name="info" select="(articleinfo
172 <xsl:if test="$info and $info/abstract">
173 <meta name="description">
174 <xsl:attribute name="content">
175 <xsl:for-each select="$info/abstract[1]/*">
176 <xsl:value-of select="normalize-space(.)"/>
177 <xsl:if test="position() < last()">
178 <xsl:text> </xsl:text>
186 <xsl:if test="($draft.mode = 'yes' or
187 ($draft.mode = 'maybe' and
188 ancestor-or-self::*[@status][1]/@status = 'draft'))
189 and $draft.watermark.image != ''">
190 <style type="text/css"><xsl:text>
191 body { background-image: url('</xsl:text>
192 <xsl:value-of select="$draft.watermark.image"/><xsl:text>');
193 background-repeat: no-repeat;
194 background-position: top left;
195 /* The following properties make the watermark "fixed" on the page. */
196 /* I think that's just a bit too distracting for the reader... */
197 /* background-attachment: fixed; */
198 /* background-position: center center; */
202 <xsl:apply-templates select="." mode="head.keywords.content"/>
205 <xsl:template name="output.html.stylesheets">
206 <xsl:param name="stylesheets" select="''"/>
209 <xsl:when test="contains($stylesheets, ' ')">
210 <link rel="stylesheet" href="{substring-before($stylesheets, ' ')}">
211 <xsl:if test="$html.stylesheet.type != ''">
212 <xsl:attribute name="type">
213 <xsl:value-of select="$html.stylesheet.type"/>
217 <xsl:call-template name="output.html.stylesheets">
218 <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
221 <xsl:when test="$stylesheets != ''">
222 <link rel="stylesheet" href="{$stylesheets}">
223 <xsl:if test="$html.stylesheet.type != ''">
224 <xsl:attribute name="type">
225 <xsl:value-of select="$html.stylesheet.type"/>
233 <!-- ============================================================ -->
235 <xsl:template match="*" mode="head.keywords.content">
236 <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/>
237 <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/>
238 <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/>
239 <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/>
240 <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/>
241 <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/>
242 <xsl:apply-templates select="artheader/keywordset" mode="html.header"/>
243 <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/>
244 <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/>
245 <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/>
246 <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/>
247 <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/>
248 <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/>
249 <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/>
250 <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/>
251 <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/>
252 <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/>
253 <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/>
254 <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/>
255 <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/>
256 <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/>
257 <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/>
258 <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/>
259 <xsl:apply-templates select="info/keywordset" mode="html.header"/>
261 <xsl:if test="$inherit.keywords != 0
263 <xsl:apply-templates select="parent::*" mode="head.keywords.content"/>
267 <!-- ============================================================ -->
269 <xsl:template name="system.head.content">
270 <xsl:param name="node" select="."/>
272 <!-- FIXME: When chunking, only the annotations actually used
273 in this chunk should be referenced. I don't think it
274 does any harm to reference them all, but it adds
275 unnecessary bloat to each chunk. -->
276 <xsl:if test="$annotation.support != 0 and //annotation">
277 <xsl:call-template name="add.annotation.links"/>
278 <script type="text/javascript">
279 <xsl:text> // Create PopupWindow objects</xsl:text>
280 <xsl:for-each select="//annotation">
281 <xsl:text> var popup_</xsl:text>
282 <xsl:value-of select="generate-id(.)"/>
283 <xsl:text> = new PopupWindow("popup-</xsl:text>
284 <xsl:value-of select="generate-id(.)"/>
285 <xsl:text>"); </xsl:text>
286 <xsl:text>popup_</xsl:text>
287 <xsl:value-of select="generate-id(.)"/>
288 <xsl:text>.offsetY = 15; </xsl:text>
289 <xsl:text>popup_</xsl:text>
290 <xsl:value-of select="generate-id(.)"/>
291 <xsl:text>.autoHide(); </xsl:text>
295 <style type="text/css">
296 <xsl:value-of select="$annotation.css"/>
300 <!-- system.head.content is like user.head.content, except that
301 it is called before head.content. This is important because it
302 means, for example, that <style> elements output by system.head.content
303 have a lower CSS precedence than the users stylesheet. -->
306 <!-- ============================================================ -->
308 <xsl:template name="user.preroot">
309 <!-- Pre-root output, can be used to output comments and PIs. -->
310 <!-- This must not output any element content! -->
313 <xsl:template name="user.head.content">
314 <xsl:param name="node" select="."/>
317 <xsl:template name="user.header.navigation">
318 <xsl:param name="node" select="."/>
321 <xsl:template name="user.header.content">
322 <xsl:param name="node" select="."/>
325 <xsl:template name="user.footer.content">
326 <xsl:param name="node" select="."/>
329 <xsl:template name="user.footer.navigation">
330 <xsl:param name="node" select="."/>
333 <xsl:template match="/">
334 <!-- * Get a title for current doc so that we let the user -->
335 <!-- * know what document we are processing at this point. -->
336 <xsl:variable name="doc.title">
337 <xsl:call-template name="get.doc.title"/>
340 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
341 toss the namespace and continue. Use the docbook5 namespaced
342 stylesheets for DocBook5 if you don't want to use this feature.-->
343 <!-- include extra test for Xalan quirk -->
344 <xsl:when test="$exsl.node.set.available != 0
345 and (*/self::ng:* or */self::db:*)">
346 <xsl:call-template name="log.message">
347 <xsl:with-param name="level">Note</xsl:with-param>
348 <xsl:with-param name="source" select="$doc.title"/>
349 <xsl:with-param name="context-desc">
350 <xsl:text>namesp. cut</xsl:text>
352 <xsl:with-param name="message">
353 <xsl:text>stripped namespace before processing</xsl:text>
356 <xsl:variable name="nons">
357 <xsl:apply-templates mode="stripNS"/>
360 <xsl:message>Saving stripped document.</xsl:message>
361 <xsl:call-template name="write.chunk">
362 <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/>
363 <xsl:with-param name="method" select="'xml'"/>
364 <xsl:with-param name="content">
365 <xsl:copy-of select="exsl:node-set($nons)"/>
369 <xsl:call-template name="log.message">
370 <xsl:with-param name="level">Note</xsl:with-param>
371 <xsl:with-param name="source" select="$doc.title"/>
372 <xsl:with-param name="context-desc">
373 <xsl:text>namesp. cut</xsl:text>
375 <xsl:with-param name="message">
376 <xsl:text>processing stripped document</xsl:text>
379 <xsl:apply-templates select="exsl:node-set($nons)"/>
381 <!-- Can't process unless namespace removed -->
382 <xsl:when test="*/self::ng:* or */self::db:*">
383 <xsl:message terminate="yes">
384 <xsl:text>Unable to strip the namespace from DB5 document,</xsl:text>
385 <xsl:text> cannot proceed.</xsl:text>
390 <xsl:when test="$rootid != ''">
392 <xsl:when test="count(key('id',$rootid)) = 0">
393 <xsl:message terminate="yes">
394 <xsl:text>ID '</xsl:text>
395 <xsl:value-of select="$rootid"/>
396 <xsl:text>' not found in document.</xsl:text>
400 <xsl:if test="$collect.xref.targets = 'yes' or
401 $collect.xref.targets = 'only'">
402 <xsl:apply-templates select="key('id', $rootid)"
403 mode="collect.targets"/>
405 <xsl:if test="$collect.xref.targets != 'only'">
406 <xsl:apply-templates select="key('id',$rootid)"
407 mode="process.root"/>
408 <xsl:if test="$tex.math.in.alt != ''">
409 <xsl:apply-templates select="key('id',$rootid)"
410 mode="collect.tex.math"/>
417 <xsl:if test="$collect.xref.targets = 'yes' or
418 $collect.xref.targets = 'only'">
419 <xsl:apply-templates select="/" mode="collect.targets"/>
421 <xsl:if test="$collect.xref.targets != 'only'">
422 <xsl:apply-templates select="/" mode="process.root"/>
423 <xsl:if test="$tex.math.in.alt != ''">
424 <xsl:apply-templates select="/" mode="collect.tex.math"/>
433 <xsl:template match="*" mode="process.root">
434 <xsl:variable name="doc" select="self::*"/>
436 <xsl:call-template name="user.preroot"/>
437 <xsl:call-template name="root.messages"/>
441 <xsl:call-template name="system.head.content">
442 <xsl:with-param name="node" select="$doc"/>
444 <xsl:call-template name="head.content">
445 <xsl:with-param name="node" select="$doc"/>
447 <xsl:call-template name="user.head.content">
448 <xsl:with-param name="node" select="$doc"/>
452 <xsl:call-template name="body.attributes"/>
453 <xsl:call-template name="user.header.content">
454 <xsl:with-param name="node" select="$doc"/>
456 <xsl:apply-templates select="."/>
457 <xsl:call-template name="user.footer.content">
458 <xsl:with-param name="node" select="$doc"/>
462 <xsl:value-of select="$html.append"/>
465 <xsl:template name="root.messages">
466 <!-- redefine this any way you'd like to output messages -->
467 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
470 <!-- ==================================================================== -->
472 <xsl:template name="chunk">
473 <xsl:param name="node" select="."/>
475 <!-- The default is that we are not chunking... -->
476 <xsl:text>0</xsl:text>
479 <!-- ==================================================================== -->