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