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