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