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