]> git.lyx.org Git - lyx.git/blob - lib/docbook/xhtml/profile-docbook.xsl
Release notes
[lyx.git] / lib / docbook / xhtml / profile-docbook.xsl
1 <?xml version="1.0" encoding="US-ASCII"?><!--This file was created automatically by xsl2profile--><!--from the DocBook XSL stylesheets.--><!--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" xmlns:exslt="http://exslt.org/common" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="exsl d exslt" 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 <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="with.namespace"><xslo:apply-templates select="/*" mode="addNS"/></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. add</xslo:text></xslo:with-param><xslo:with-param name="message"><xslo:text>added namespace before processing</xslo:text></xslo:with-param></xslo:call-template><xslo:apply-templates select="exslt:node-set($with.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="/">
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="false()"/>
400     <!-- Can't process unless namespace fixed with exsl node-set()-->
401     <xsl:when test="false()"/>
402     <xsl:otherwise>
403       <xsl:choose>
404         <xsl:when test="$rootid != ''">
405           <xsl:choose>
406             <xsl:when test="count($profiled-nodes//*[@id=$rootid or @xml:id=$rootid]) = 0">
407               <xsl:message terminate="yes">
408                 <xsl:text>ID '</xsl:text>
409                 <xsl:value-of select="$rootid"/>
410                 <xsl:text>' not found in document.</xsl:text>
411               </xsl:message>
412             </xsl:when>
413             <xsl:otherwise>
414               <xsl:if test="$collect.xref.targets = 'yes' or                             $collect.xref.targets = 'only'">
415                 <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
416               </xsl:if>
417               <xsl:if test="$collect.xref.targets != 'only'">
418                 <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="process.root"/>
419                 <xsl:if test="$tex.math.in.alt != ''">
420                   <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid or @xml:id=$rootid]" mode="collect.tex.math"/>
421                 </xsl:if>
422               </xsl:if>
423             </xsl:otherwise>
424           </xsl:choose>
425         </xsl:when>
426         <xsl:otherwise>
427           <xsl:if test="$collect.xref.targets = 'yes' or                         $collect.xref.targets = 'only'">
428             <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
429           </xsl:if>
430           <xsl:if test="$collect.xref.targets != 'only'">
431             <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
432             <xsl:if test="$tex.math.in.alt != ''">
433               <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
434             </xsl:if>
435           </xsl:if>
436         </xsl:otherwise>
437       </xsl:choose>
438     </xsl:otherwise>
439   </xsl:choose>
440 </xsl:template>
441
442 <xsl:template match="*" mode="process.root">
443   <xsl:variable name="doc" select="self::*"/>
444
445   <xsl:call-template name="user.preroot"/>
446   <xsl:call-template name="root.messages"/>
447
448   <html>
449     <xsl:call-template name="root.attributes"/>
450     <head>
451       <xsl:call-template name="system.head.content">
452         <xsl:with-param name="node" select="$doc"/>
453       </xsl:call-template>
454       <xsl:call-template name="head.content">
455         <xsl:with-param name="node" select="$doc"/>
456       </xsl:call-template>
457       <xsl:call-template name="user.head.content">
458         <xsl:with-param name="node" select="$doc"/>
459       </xsl:call-template>
460     </head>
461     <body>
462       <xsl:call-template name="body.attributes"/>
463       <xsl:call-template name="user.header.content">
464         <xsl:with-param name="node" select="$doc"/>
465       </xsl:call-template>
466       <xsl:apply-templates select="."/>
467       <xsl:call-template name="user.footer.content">
468         <xsl:with-param name="node" select="$doc"/>
469       </xsl:call-template>
470     </body>
471   </html>
472   <xsl:value-of select="$html.append"/>
473   
474   <!-- Generate any css files only once, not once per chunk -->
475   <xsl:call-template name="generate.css.files"/>
476 </xsl:template>
477
478 <xsl:template name="root.attributes">
479   <!-- customize to add attributes to <html> element  -->
480 </xsl:template>
481
482 <xsl:template name="root.messages">
483   <!-- redefine this any way you'd like to output messages -->
484   <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
485 </xsl:template>
486
487 <!-- ==================================================================== -->
488
489 <xsl:template name="chunk">
490   <xsl:param name="node" select="."/>
491
492   <!-- The default is that we are not chunking... -->
493   <xsl:text>0</xsl:text>
494 </xsl:template>
495
496 </xsl:stylesheet>