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