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"
9 <xsl:output method=
"html"
13 <!-- ********************************************************************
14 $Id: docbook.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
15 ********************************************************************
17 This file is part of the XSL DocBook Stylesheet distribution.
18 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
19 and other information.
21 ******************************************************************** -->
23 <!-- ==================================================================== -->
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/labels.xsl"/>
31 <xsl:include href=
"../common/titles.xsl"/>
32 <xsl:include href=
"../common/subtitles.xsl"/>
33 <xsl:include href=
"../common/gentext.xsl"/>
34 <xsl:include href=
"../common/targets.xsl"/>
35 <xsl:include href=
"../common/olink.xsl"/>
36 <xsl:include href=
"../common/pi.xsl"/>
37 <xsl:include href=
"autotoc.xsl"/>
38 <xsl:include href=
"autoidx.xsl"/>
39 <xsl:include href=
"lists.xsl"/>
40 <xsl:include href=
"callout.xsl"/>
41 <xsl:include href=
"verbatim.xsl"/>
42 <xsl:include href=
"graphics.xsl"/>
43 <xsl:include href=
"xref.xsl"/>
44 <xsl:include href=
"formal.xsl"/>
45 <xsl:include href=
"table.xsl"/>
46 <xsl:include href=
"htmltbl.xsl"/>
47 <xsl:include href=
"sections.xsl"/>
48 <xsl:include href=
"inline.xsl"/>
49 <xsl:include href=
"footnote.xsl"/>
50 <xsl:include href=
"html.xsl"/>
51 <xsl:include href=
"info.xsl"/>
52 <xsl:include href=
"keywords.xsl"/>
53 <xsl:include href=
"division.xsl"/>
54 <xsl:include href=
"toc.xsl"/>
55 <xsl:include href=
"index.xsl"/>
56 <xsl:include href=
"refentry.xsl"/>
57 <xsl:include href=
"math.xsl"/>
58 <xsl:include href=
"admon.xsl"/>
59 <xsl:include href=
"component.xsl"/>
60 <xsl:include href=
"biblio.xsl"/>
61 <xsl:include href=
"biblio-iso690.xsl"/>
62 <xsl:include href=
"glossary.xsl"/>
63 <xsl:include href=
"block.xsl"/>
64 <xsl:include href=
"task.xsl"/>
65 <xsl:include href=
"qandaset.xsl"/>
66 <xsl:include href=
"synop.xsl"/>
67 <xsl:include href=
"titlepage.xsl"/>
68 <xsl:include href=
"titlepage.templates.xsl"/>
69 <xsl:include href=
"pi.xsl"/>
70 <xsl:include href=
"ebnf.xsl"/>
71 <xsl:include href=
"chunker.xsl"/>
72 <xsl:include href=
"html-rtf.xsl"/>
73 <xsl:include href=
"annotations.xsl"/>
74 <xsl:include href=
"../common/stripns.xsl"/>
76 <xsl:param name=
"stylesheet.result.type" select=
"'html'"/>
77 <xsl:param name=
"htmlhelp.output" select=
"0"/>
79 <!-- ==================================================================== -->
81 <xsl:key name=
"id" match=
"*" use=
"@id|@xml:id"/>
82 <xsl:key name=
"gid" match=
"*" use=
"generate-id()"/>
84 <!-- ==================================================================== -->
86 <xsl:template match=
"*">
88 <xsl:text>Element
</xsl:text>
89 <xsl:value-of select=
"local-name(.)"/>
90 <xsl:text> in namespace '
</xsl:text>
91 <xsl:value-of select=
"namespace-uri(.)"/>
92 <xsl:text>' encountered
</xsl:text>
93 <xsl:if test=
"parent::*">
94 <xsl:text> in
</xsl:text>
95 <xsl:value-of select=
"name(parent::*)"/>
97 <xsl:text>, but no template matches.
</xsl:text>
101 <xsl:text><</xsl:text>
102 <xsl:value-of select=
"name(.)"/>
103 <xsl:text>></xsl:text>
104 <xsl:apply-templates/>
105 <xsl:text></
</xsl:text>
106 <xsl:value-of select=
"name(.)"/>
107 <xsl:text>></xsl:text>
111 <xsl:template match=
"text()">
112 <xsl:value-of select=
"."/>
115 <xsl:template name=
"body.attributes">
116 <xsl:attribute name=
"bgcolor">white
</xsl:attribute>
117 <xsl:attribute name=
"text">black
</xsl:attribute>
118 <xsl:attribute name=
"link">#
0000FF
</xsl:attribute>
119 <xsl:attribute name=
"vlink">#
840084</xsl:attribute>
120 <xsl:attribute name=
"alink">#
0000FF
</xsl:attribute>
123 <xsl:template name=
"head.content">
124 <xsl:param name=
"node" select=
"."/>
125 <xsl:param name=
"title">
126 <xsl:apply-templates select=
"$node" mode=
"object.title.markup.textonly"/>
130 <xsl:copy-of select=
"$title"/>
133 <xsl:if test=
"$html.stylesheet != ''">
134 <xsl:call-template name=
"output.html.stylesheets">
135 <xsl:with-param name=
"stylesheets" select=
"normalize-space($html.stylesheet)"/>
139 <xsl:if test=
"$link.mailto.url != ''">
141 href=
"{$link.mailto.url}"/>
144 <xsl:if test=
"$html.base != ''">
145 <base href=
"{$html.base}"/>
148 <meta name=
"generator" content=
"DocBook {$DistroTitle} V{$VERSION}"/>
150 <xsl:if test=
"$generate.meta.abstract != 0">
151 <xsl:variable name=
"info" select=
"(articleinfo
167 <xsl:if test=
"$info and $info/abstract">
168 <meta name=
"description">
169 <xsl:attribute name=
"content">
170 <xsl:for-each select=
"$info/abstract[1]/*">
171 <xsl:value-of select=
"normalize-space(.)"/>
172 <xsl:if test=
"position() < last()">
173 <xsl:text> </xsl:text>
181 <xsl:if test=
"($draft.mode = 'yes' or
182 ($draft.mode = 'maybe' and
183 ancestor-or-self::*[@status][1]/@status = 'draft'))
184 and $draft.watermark.image != ''">
185 <style type=
"text/css"><xsl:text>
186 body { background-image: url('
</xsl:text>
187 <xsl:value-of select=
"$draft.watermark.image"/><xsl:text>');
188 background-repeat: no-repeat;
189 background-position: top left;
190 /* The following properties make the watermark
"fixed" on the page. */
191 /* I think that's just a bit too distracting for the reader... */
192 /* background-attachment: fixed; */
193 /* background-position: center center; */
197 <xsl:apply-templates select=
"." mode=
"head.keywords.content"/>
200 <xsl:template name=
"output.html.stylesheets">
201 <xsl:param name=
"stylesheets" select=
"''"/>
204 <xsl:when test=
"contains($stylesheets, ' ')">
205 <link rel=
"stylesheet" href=
"{substring-before($stylesheets, ' ')}">
206 <xsl:if test=
"$html.stylesheet.type != ''">
207 <xsl:attribute name=
"type">
208 <xsl:value-of select=
"$html.stylesheet.type"/>
212 <xsl:call-template name=
"output.html.stylesheets">
213 <xsl:with-param name=
"stylesheets" select=
"substring-after($stylesheets, ' ')"/>
216 <xsl:when test=
"$stylesheets != ''">
217 <link rel=
"stylesheet" href=
"{$stylesheets}">
218 <xsl:if test=
"$html.stylesheet.type != ''">
219 <xsl:attribute name=
"type">
220 <xsl:value-of select=
"$html.stylesheet.type"/>
228 <!-- ============================================================ -->
230 <xsl:template match=
"*" mode=
"head.keywords.content">
231 <xsl:apply-templates select=
"chapterinfo/keywordset" mode=
"html.header"/>
232 <xsl:apply-templates select=
"appendixinfo/keywordset" mode=
"html.header"/>
233 <xsl:apply-templates select=
"prefaceinfo/keywordset" mode=
"html.header"/>
234 <xsl:apply-templates select=
"bookinfo/keywordset" mode=
"html.header"/>
235 <xsl:apply-templates select=
"setinfo/keywordset" mode=
"html.header"/>
236 <xsl:apply-templates select=
"articleinfo/keywordset" mode=
"html.header"/>
237 <xsl:apply-templates select=
"artheader/keywordset" mode=
"html.header"/>
238 <xsl:apply-templates select=
"sect1info/keywordset" mode=
"html.header"/>
239 <xsl:apply-templates select=
"sect2info/keywordset" mode=
"html.header"/>
240 <xsl:apply-templates select=
"sect3info/keywordset" mode=
"html.header"/>
241 <xsl:apply-templates select=
"sect4info/keywordset" mode=
"html.header"/>
242 <xsl:apply-templates select=
"sect5info/keywordset" mode=
"html.header"/>
243 <xsl:apply-templates select=
"sectioninfo/keywordset" mode=
"html.header"/>
244 <xsl:apply-templates select=
"refsect1info/keywordset" mode=
"html.header"/>
245 <xsl:apply-templates select=
"refsect2info/keywordset" mode=
"html.header"/>
246 <xsl:apply-templates select=
"refsect3info/keywordset" mode=
"html.header"/>
247 <xsl:apply-templates select=
"bibliographyinfo/keywordset" mode=
"html.header"/>
248 <xsl:apply-templates select=
"glossaryinfo/keywordset" mode=
"html.header"/>
249 <xsl:apply-templates select=
"indexinfo/keywordset" mode=
"html.header"/>
250 <xsl:apply-templates select=
"refentryinfo/keywordset" mode=
"html.header"/>
251 <xsl:apply-templates select=
"partinfo/keywordset" mode=
"html.header"/>
252 <xsl:apply-templates select=
"referenceinfo/keywordset" mode=
"html.header"/>
253 <xsl:apply-templates select=
"docinfo/keywordset" mode=
"html.header"/>
254 <xsl:apply-templates select=
"info/keywordset" mode=
"html.header"/>
256 <xsl:if test=
"$inherit.keywords != 0
258 <xsl:apply-templates select=
"parent::*" mode=
"head.keywords.content"/>
262 <!-- ============================================================ -->
264 <xsl:template name=
"system.head.content">
265 <xsl:param name=
"node" select=
"."/>
267 <!-- FIXME: When chunking, only the annotations actually used
268 in this chunk should be referenced. I don't think it
269 does any harm to reference them all, but it adds
270 unnecessary bloat to each chunk. -->
271 <xsl:if test=
"$annotation.support != 0 and //annotation">
272 <xsl:call-template name=
"add.annotation.links"/>
273 <script type=
"text/javascript">
274 <xsl:text> // Create PopupWindow objects
</xsl:text>
275 <xsl:for-each select=
"//annotation">
276 <xsl:text> var popup_
</xsl:text>
277 <xsl:value-of select=
"generate-id(.)"/>
278 <xsl:text> = new PopupWindow(
"popup-</xsl:text>
279 <xsl:value-of select="generate-id(.)
"/>
280 <xsl:text>");
</xsl:text>
281 <xsl:text>popup_
</xsl:text>
282 <xsl:value-of select=
"generate-id(.)"/>
283 <xsl:text>.offsetY =
15;
</xsl:text>
284 <xsl:text>popup_
</xsl:text>
285 <xsl:value-of select=
"generate-id(.)"/>
286 <xsl:text>.autoHide();
</xsl:text>
290 <style type=
"text/css">
291 <xsl:value-of select=
"$annotation.css"/>
295 <!-- system.head.content is like user.head.content, except that
296 it is called before head.content. This is important because it
297 means, for example, that <style> elements output by system.head.content
298 have a lower CSS precedence than the users stylesheet. -->
301 <!-- ============================================================ -->
303 <xsl:template name=
"user.preroot">
304 <!-- Pre-root output, can be used to output comments and PIs. -->
305 <!-- This must not output any element content! -->
308 <xsl:template name=
"user.head.content">
309 <xsl:param name=
"node" select=
"."/>
312 <xsl:template name=
"user.header.navigation">
313 <xsl:param name=
"node" select=
"."/>
316 <xsl:template name=
"user.header.content">
317 <xsl:param name=
"node" select=
"."/>
320 <xsl:template name=
"user.footer.content">
321 <xsl:param name=
"node" select=
"."/>
324 <xsl:template name=
"user.footer.navigation">
325 <xsl:param name=
"node" select=
"."/>
328 <xsl:template match=
"/">
330 <!-- include extra test for Xalan quirk -->
331 <xsl:when test=
"(function-available('exsl:node-set') or
332 contains(system-property('xsl:vendor'),
333 'Apache Software Foundation'))
334 and (*/self::ng:* or */self::db:*)">
335 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
336 toss the namespace and continue. Someday we'll reverse this logic
337 and add the namespace to documents that don't have one.
338 But not before the whole stylesheet has been converted to use
339 namespaces. i.e., don't hold your breath -->
340 <xsl:message>Stripping namespace from DocBook
5 document.
</xsl:message>
341 <xsl:variable name=
"nons">
342 <xsl:apply-templates mode=
"stripNS"/>
345 <xsl:message>Saving stripped document.</xsl:message>
346 <xsl:call-template name="write.chunk">
347 <xsl:with-param name="filename" select="'/tmp/stripped.xml'"/>
348 <xsl:with-param name="method" select="'xml'"/>
349 <xsl:with-param name="content">
350 <xsl:copy-of select="exsl:node-set($nons)"/>
354 <xsl:message>Processing stripped document.
</xsl:message>
355 <xsl:apply-templates select=
"exsl:node-set($nons)"/>
357 <!-- Can't process unless namespace removed -->
358 <xsl:when test=
"*/self::ng:* or */self::db:*">
359 <xsl:message terminate=
"yes">
360 <xsl:text>Unable to strip the namespace from DB5 document,
</xsl:text>
361 <xsl:text> cannot proceed.
</xsl:text>
366 <xsl:when test=
"$rootid != ''">
368 <xsl:when test=
"count(key('id',$rootid)) = 0">
369 <xsl:message terminate=
"yes">
370 <xsl:text>ID '
</xsl:text>
371 <xsl:value-of select=
"$rootid"/>
372 <xsl:text>' not found in document.
</xsl:text>
376 <xsl:if test=
"$collect.xref.targets = 'yes' or
377 $collect.xref.targets = 'only'">
378 <xsl:apply-templates select=
"key('id', $rootid)"
379 mode=
"collect.targets"/>
381 <xsl:if test=
"$collect.xref.targets != 'only'">
382 <xsl:apply-templates select=
"key('id',$rootid)"
383 mode=
"process.root"/>
384 <xsl:if test=
"$tex.math.in.alt != ''">
385 <xsl:apply-templates select=
"key('id',$rootid)"
386 mode=
"collect.tex.math"/>
393 <xsl:if test=
"$collect.xref.targets = 'yes' or
394 $collect.xref.targets = 'only'">
395 <xsl:apply-templates select=
"/" mode=
"collect.targets"/>
397 <xsl:if test=
"$collect.xref.targets != 'only'">
398 <xsl:apply-templates select=
"/" mode=
"process.root"/>
399 <xsl:if test=
"$tex.math.in.alt != ''">
400 <xsl:apply-templates select=
"/" mode=
"collect.tex.math"/>
409 <xsl:template match=
"*" mode=
"process.root">
410 <xsl:variable name=
"doc" select=
"self::*"/>
412 <xsl:call-template name=
"user.preroot"/>
413 <xsl:call-template name=
"root.messages"/>
417 <xsl:call-template name=
"system.head.content">
418 <xsl:with-param name=
"node" select=
"$doc"/>
420 <xsl:call-template name=
"head.content">
421 <xsl:with-param name=
"node" select=
"$doc"/>
423 <xsl:call-template name=
"user.head.content">
424 <xsl:with-param name=
"node" select=
"$doc"/>
428 <xsl:call-template name=
"body.attributes"/>
429 <xsl:call-template name=
"user.header.content">
430 <xsl:with-param name=
"node" select=
"$doc"/>
432 <xsl:apply-templates select=
"."/>
433 <xsl:call-template name=
"user.footer.content">
434 <xsl:with-param name=
"node" select=
"$doc"/>
438 <xsl:value-of select=
"$html.append"/>
441 <xsl:template name=
"root.messages">
442 <!-- redefine this any way you'd like to output messages -->
443 <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
446 <!-- ==================================================================== -->
448 <xsl:template name=
"chunk">
449 <xsl:param name=
"node" select=
"."/>
451 <!-- The default is that we are not chunking... -->
452 <xsl:text>0</xsl:text>
455 <!-- ==================================================================== -->