source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/epub/docbook.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 72.5 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet
3 xmlns:db="http://docbook.org/ns/docbook"
4 xmlns:dc="http://purl.org/dc/elements/1.1/"
5 xmlns:exsl="http://exslt.org/common"
6 xmlns:h="http://www.w3.org/1999/xhtml"
7 xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"
8 xmlns:ng="http://docbook.org/docbook-ng"
9 xmlns:opf="http://www.idpf.org/2007/opf"
10 xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
11 xmlns:str="http://exslt.org/strings"
12 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
13 xmlns:xtext="xalan://com.nwalsh.xalan.Text"
14
15 extension-element-prefixes="stext xtext"
16 exclude-result-prefixes="exsl db dc h ncx ng opf stext str xtext"
17
18 version="1.0">
19
20 <xsl:import href="../xhtml-1_1/docbook.xsl" />
21 <xsl:import href="../xhtml-1_1/chunk-common.xsl" />
22 <xsl:include href="../xhtml-1_1/chunk-code.xsl" />
23
24
25 <!-- We want a separate TOC file, please -->
26 <xsl:param name="chunk.tocs.and.lots">1</xsl:param>
27 <xsl:param name="toc.section.depth">2</xsl:param>
28 <xsl:param name="generate.toc">
29 book toc,title
30 </xsl:param>
31
32 <xsl:param name="ade.extensions" select="0"/>
33 <xsl:param name="epub.autolabel" select="'1'"/>
34 <xsl:param name="epub.ncx.depth">4</xsl:param> <!-- Not functional until http://code.google.com/p/epubcheck/issues/detail?id=70 is resolved -->
35
36
37 <xsl:param name="manifest.in.base.dir" select="'1'"/>
38 <xsl:param name="base.dir" select="$epub.oebps.dir"/>
39
40 <xsl:param name="epub.oebps.dir" select="'OEBPS/'"/>
41 <xsl:param name="epub.ncx.filename" select="'toc.ncx'"/>
42 <xsl:param name="epub.container.filename" select="'container.xml'"/>
43 <xsl:param name="epub.opf.filename" select="concat($epub.oebps.dir, 'content.opf')"/>
44 <xsl:param name="epub.cover.filename" select="concat($epub.oebps.dir, 'cover', $html.ext)"/>
45 <xsl:param name="epub.cover.id" select="'cover'"/>
46 <xsl:param name="epub.cover.html" select="'cover.html'" />
47 <xsl:param name="epub.cover.image.id" select="'cover-image'"/>
48 <xsl:param name="epub.cover.linear" select="0" />
49 <xsl:param name="epub.ncx.toc.id">ncxtoc</xsl:param>
50 <xsl:param name="epub.html.toc.id">htmltoc</xsl:param>
51 <xsl:param name="epub.metainf.dir" select="'META-INF/'"/>
52
53 <xsl:param name="epub.embedded.fonts"></xsl:param>
54
55 <!-- Turning this on crashes ADE, which is unbelievably awesome -->
56 <xsl:param name="formal.object.break.after">0</xsl:param>
57
58
59 <!-- Per Bob Stayton:
60 """Process your documents with the css.decoration parameter set to zero.
61 That will avoid the use of style attributes in XHTML elements where they are not permitted."""
62 http://www.sagehill.net/docbookxsl/OtherOutputForms.html#StrictXhtmlValid -->
63 <xsl:param name="css.decoration" select="0"/>
64 <xsl:param name="custom.css.source"></xsl:param> <!-- FIXME: Align with current CSS parameter design -->
65
66 <xsl:param name="callout.graphics" select="1"/>
67 <xsl:param name="callout.graphics.extension">.png</xsl:param>
68 <xsl:param name="callout.graphics.number.limit" select="15"/>
69 <xsl:param name="callout.graphics.path" select="'images/callouts/'"/>
70
71 <!-- no navigation in .epub -->
72 <xsl:param name="suppress.navigation" select="'1'"/>
73
74 <xsl:variable name="toc.params">
75 <xsl:call-template name="find.path.params">
76 <xsl:with-param name="node" select="/*"/>
77 <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
78 </xsl:call-template>
79 </xsl:variable>
80 <xsl:variable name="root.is.a.chunk">
81 <xsl:choose>
82 <xsl:when test="/*[not(self::book)][not(sect1) or not(section)]">
83 <xsl:text>1</xsl:text>
84 </xsl:when>
85 <xsl:when test="/book[*[last()][self::bookinfo]]|book[bookinfo]">
86 <xsl:text>1</xsl:text>
87 </xsl:when>
88 <xsl:when test="/book[*[last()][self::info]]|book[info]">
89 <xsl:text>1</xsl:text>
90 </xsl:when>
91 <xsl:when test="/bibliography">
92 <xsl:text>1</xsl:text>
93 </xsl:when>
94 <xsl:otherwise>
95 <xsl:text>0</xsl:text>
96 </xsl:otherwise>
97 </xsl:choose>
98 </xsl:variable>
99
100 <xsl:key name="image-filerefs" match="graphic|inlinegraphic|imagedata" use="@fileref"/>
101
102 <xsl:template match="/" priority="1">
103 <!-- * Get a title for current doc so that we let the user -->
104 <!-- * know what document we are processing at this point. -->
105 <xsl:variable name="doc.title">
106 <xsl:call-template name="get.doc.title" />
107 </xsl:variable>
108 <xsl:choose>
109 <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
110 toss the namespace and continue. Use the docbook5 namespaced
111 stylesheets for DocBook5 if you don't want to use this feature.-->
112 <!-- include extra test for Xalan quirk -->
113 <xsl:when test="$exsl.node.set.available != 0
114 and (*/self::ng:* or */self::db:*)">
115 <xsl:call-template name="log.message">
116 <xsl:with-param name="level">Note</xsl:with-param>
117 <xsl:with-param name="source" select="$doc.title" />
118 <xsl:with-param name="context-desc">
119 <xsl:text>namesp. cut</xsl:text>
120 </xsl:with-param>
121 <xsl:with-param name="message">
122 <xsl:text>stripped namespace before processing</xsl:text>
123 </xsl:with-param>
124 </xsl:call-template>
125 <xsl:variable name="nons">
126 <xsl:apply-templates mode="stripNS" />
127 </xsl:variable>
128 <xsl:call-template name="log.message">
129 <xsl:with-param name="level">Note</xsl:with-param>
130 <xsl:with-param name="source" select="$doc.title" />
131 <xsl:with-param name="context-desc">
132 <xsl:text>namesp. cut</xsl:text>
133 </xsl:with-param>
134 <xsl:with-param name="message">
135 <xsl:text>processing stripped document</xsl:text>
136 </xsl:with-param>
137 </xsl:call-template>
138 <xsl:apply-templates select="exsl:node-set($nons)" />
139 </xsl:when>
140 <xsl:otherwise>
141 <xsl:choose>
142 <xsl:when test="$rootid != ''">
143 <xsl:choose>
144 <xsl:when
145 test="count(key('id',$rootid)) = 0">
146 <xsl:message terminate="yes">
147 <xsl:text>ID '</xsl:text>
148 <xsl:value-of select="$rootid" />
149 <xsl:text>' not found in document.</xsl:text>
150 </xsl:message>
151 </xsl:when>
152 <xsl:otherwise>
153 <xsl:if
154 test="$collect.xref.targets = 'yes' or
155 $collect.xref.targets = 'only'">
156 <xsl:apply-templates
157 select="key('id', $rootid)" mode="collect.targets" />
158 </xsl:if>
159 <xsl:if
160 test="$collect.xref.targets != 'only'">
161 <xsl:message>
162 Formatting from
163 <xsl:value-of select="$rootid" />
164 </xsl:message>
165 <xsl:apply-templates
166 select="key('id',$rootid)" mode="process.root" />
167 <xsl:call-template name="ncx" />
168 </xsl:if>
169 </xsl:otherwise>
170 </xsl:choose>
171 </xsl:when>
172 <xsl:otherwise>
173 <xsl:if
174 test="$collect.xref.targets = 'yes' or
175 $collect.xref.targets = 'only'">
176 <xsl:apply-templates select="/"
177 mode="collect.targets" />
178 </xsl:if>
179 <xsl:if
180 test="$collect.xref.targets != 'only'">
181 <xsl:apply-templates select="/"
182 mode="process.root" />
183 <xsl:call-template name="ncx" />
184 <xsl:call-template name="opf" />
185 <xsl:call-template name="cover" />
186 <xsl:call-template name="container" />
187 </xsl:if>
188 </xsl:otherwise>
189 </xsl:choose>
190 </xsl:otherwise>
191 </xsl:choose>
192 </xsl:template>
193
194 <xsl:template name="package-identifier">
195 <xsl:choose>
196 <xsl:when test="/*/*[contains(name(.), 'info')]/biblioid">
197 <xsl:if test="/*/*[contains(name(.), 'info')][1]/biblioid[1][@class = 'doi' or
198 @class = 'isbn' or
199 @class = 'isrn' or
200 @class = 'issn']">
201 <xsl:text>urn:</xsl:text>
202 <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/biblioid[1]/@class"/>
203 <xsl:text>:</xsl:text>
204 </xsl:if>
205 <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/biblioid[1]"/>
206 </xsl:when>
207 <xsl:when test="/*/*[contains(name(.), 'info')]/isbn">
208 <xsl:text>urn:isbn:</xsl:text>
209 <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/isbn[1]"/>
210 </xsl:when>
211 <xsl:when test="/*/*[contains(name(.), 'info')]/issn">
212 <xsl:text>urn:issn:</xsl:text>
213 <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/issn[1]"/>
214 </xsl:when>
215 <xsl:otherwise>
216 <xsl:choose>
217 <xsl:when test="/*/*[contains(name(.), 'info')]/invpartnumber"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/invpartnumber[1]"/> </xsl:when>
218 <xsl:when test="/*/*[contains(name(.), 'info')]/issuenum"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/issuenum[1]"/> </xsl:when>
219 <xsl:when test="/*/*[contains(name(.), 'info')]/productnumber"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/productnumber[1]"/> </xsl:when>
220 <xsl:when test="/*/*[contains(name(.), 'info')]/seriesvolnums"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/seriesvolnums[1]"/> </xsl:when>
221 <xsl:when test="/*/*[contains(name(.), 'info')]/volumenum"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/volumenum[1]"/> </xsl:when>
222 <!-- Deprecated -->
223 <xsl:when test="/*/*[contains(name(.), 'info')]/pubsnumber"> <xsl:value-of select="/*/*[contains(name(.), 'info')][1]/pubsnumber[1]"/> </xsl:when>
224 </xsl:choose>
225 <xsl:text>_</xsl:text>
226 <xsl:choose>
227 <xsl:when test="/*/@id">
228 <xsl:value-of select="/*/@id"/>
229 </xsl:when>
230 <xsl:when test="/*/@xml:id">
231 <xsl:value-of select="/*/@xml:id"/>
232 </xsl:when>
233 <xsl:otherwise>
234 <!-- TODO: Do UUIDs here -->
235 <xsl:value-of select="generate-id(/*)"/>
236 </xsl:otherwise>
237 </xsl:choose>
238 </xsl:otherwise>
239 </xsl:choose>
240 </xsl:template>
241
242 <xsl:template name="opf">
243 <xsl:variable name="package-identifier-id"><xsl:value-of select="concat(name(/*), 'id')"/></xsl:variable>
244 <xsl:variable name="doc.title">
245 <xsl:call-template name="get.doc.title" />
246 </xsl:variable>
247 <xsl:call-template name="write.chunk">
248 <xsl:with-param name="filename">
249 <xsl:value-of select="$epub.opf.filename" />
250 </xsl:with-param>
251 <xsl:with-param name="method" select="'xml'" />
252 <xsl:with-param name="encoding" select="'utf-8'" />
253 <xsl:with-param name="indent" select="'no'" />
254 <xsl:with-param name="quiet" select="$chunk.quietly" />
255 <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
256 <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
257 <xsl:with-param name="content">
258 <xsl:element namespace="http://www.idpf.org/2007/opf" name="package">
259 <xsl:attribute name="version">2.0</xsl:attribute>
260 <xsl:attribute name="unique-identifier"> <xsl:value-of select="$package-identifier-id"/> </xsl:attribute>
261
262 <xsl:element namespace="http://www.idpf.org/2007/opf" name="metadata">
263 <xsl:element name="dc:identifier">
264 <xsl:attribute name="id"><xsl:value-of select="$package-identifier-id"/></xsl:attribute>
265 <xsl:call-template name="package-identifier"/>
266 </xsl:element>
267
268 <xsl:element name="dc:title">
269 <xsl:value-of select="normalize-space($doc.title)"/>
270 </xsl:element>
271
272 <xsl:apply-templates select="/*/*[contains(name(.), 'info')]/*"
273 mode="opf.metadata"/>
274 <xsl:element name="dc:language">
275 <xsl:call-template name="l10n.language">
276 <xsl:with-param name="target" select="/*"/>
277 </xsl:call-template>
278 </xsl:element>
279
280 <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
281 <xsl:element namespace="http://www.idpf.org/2007/opf" name="meta">
282 <xsl:attribute name="name">cover</xsl:attribute>
283 <xsl:attribute name="content">
284 <xsl:value-of select="$epub.cover.image.id"/>
285 </xsl:attribute>
286 </xsl:element>
287 </xsl:if>
288
289 </xsl:element>
290 <xsl:call-template name="opf.manifest"/>
291 <xsl:call-template name="opf.spine"/>
292 <xsl:call-template name="opf.guide"/>
293
294 </xsl:element>
295 </xsl:with-param>
296 </xsl:call-template>
297 </xsl:template>
298
299 <xsl:template name="container">
300 <xsl:call-template name="write.chunk">
301 <xsl:with-param name="filename">
302 <xsl:value-of select="$epub.metainf.dir" />
303 <xsl:value-of select="$epub.container.filename" />
304 </xsl:with-param>
305 <xsl:with-param name="method" select="'xml'" />
306 <xsl:with-param name="encoding" select="'utf-8'" />
307 <xsl:with-param name="indent" select="'no'" />
308 <xsl:with-param name="quiet" select="$chunk.quietly" />
309 <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
310 <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
311
312 <xsl:with-param name="content">
313 <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="container">
314 <xsl:attribute name="version">1.0</xsl:attribute>
315 <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfiles">
316 <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfile">
317 <xsl:attribute name="full-path">
318 <xsl:value-of select="$epub.opf.filename" />
319 </xsl:attribute>
320 <xsl:attribute name="media-type">
321 <xsl:text>application/oebps-package+xml</xsl:text>
322 </xsl:attribute>
323 </xsl:element>
324 </xsl:element>
325 </xsl:element>
326 </xsl:with-param>
327 </xsl:call-template>
328 </xsl:template>
329
330 <xsl:template name="ncx">
331 <xsl:call-template name="write.chunk">
332 <xsl:with-param name="filename">
333 <xsl:if test="$manifest.in.base.dir != 0">
334 <xsl:value-of select="$chunk.base.dir" />
335 </xsl:if>
336 <xsl:value-of select="$epub.ncx.filename" />
337 </xsl:with-param>
338 <xsl:with-param name="method" select="'xml'" />
339 <xsl:with-param name="encoding" select="'utf-8'" />
340 <xsl:with-param name="indent" select="'no'" />
341 <xsl:with-param name="quiet" select="$chunk.quietly" />
342 <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
343 <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
344 <xsl:with-param name="content">
345 <xsl:element name="ncx" namespace="http://www.daisy.org/z3986/2005/ncx/">
346 <xsl:attribute name="version">2005-1</xsl:attribute>
347
348 <!-- Via Martin Goerner: On covers: the IDPF2.0 standard unfortunately does not have a provision for
349 covers. We had to add one and we did so in conjunction with the IDPF and
350 various publishers. The tag chosen to define the covers is:
351 <meta name="cover" content="-reference to a manifest item-">
352 Then, we also added a bit of logic to get rid cleanly of the HTML cover
353 people usually add because the logical cover is not specced by the IDPF. So,
354 if the HTML cover item is marked linear="no" AND there is a guide item of
355 type="cover" pointing to it AND there is a logical cover specified in a
356 <meta name="cover"> tag, THEN, the HTML cover is discarded. -->
357 <xsl:element name="head" namespace="http://www.daisy.org/z3986/2005/ncx/">
358 <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
359 <xsl:element name="meta" namespace="http://www.daisy.org/z3986/2005/ncx/">
360 <xsl:attribute name="name">cover</xsl:attribute>
361 <xsl:attribute name="content">
362 <xsl:value-of select="$epub.cover.id"/>
363 </xsl:attribute>
364 </xsl:element>
365 </xsl:if>
366 <xsl:element name="meta" namespace="http://www.daisy.org/z3986/2005/ncx/">
367 <xsl:attribute name="name">dtb:uid</xsl:attribute>
368 <xsl:attribute name="content"><xsl:call-template name="package-identifier"/></xsl:attribute>
369 </xsl:element>
370 </xsl:element>
371
372 <xsl:choose>
373 <xsl:when test="$rootid != ''">
374 <xsl:variable name="title">
375 <xsl:if test="$epub.autolabel != 0">
376 <xsl:variable name="label.markup">
377 <xsl:apply-templates select="key('id',$rootid)" mode="label.markup" />
378 </xsl:variable>
379 <xsl:if test="normalize-space($label.markup)">
380 <xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
381 </xsl:if>
382 </xsl:if>
383 <xsl:apply-templates select="key('id',$rootid)" mode="title.markup" />
384 </xsl:variable>
385 <xsl:variable name="href">
386 <xsl:call-template name="href.target.with.base.dir">
387 <xsl:with-param name="object" select="key('id',$rootid)" />
388 </xsl:call-template>
389 </xsl:variable>
390 <xsl:element name="docTitle" namespace="http://www.daisy.org/z3986/2005/ncx/">
391 <xsl:element name="text" namespace="http://www.daisy.org/z3986/2005/ncx/"><xsl:value-of select="normalize-space($title)" /> </xsl:element>
392 </xsl:element>
393 <xsl:element name="navMap" namespace="http://www.daisy.org/z3986/2005/ncx/">
394 <xsl:apply-templates select="key('id',$rootid)/*" mode="ncx" />
395 </xsl:element>
396 </xsl:when>
397 <xsl:otherwise>
398 <xsl:variable name="title">
399 <xsl:if test="$epub.autolabel != 0">
400 <xsl:variable name="label.markup">
401 <xsl:apply-templates select="/*" mode="label.markup" />
402 </xsl:variable>
403 <xsl:if test="normalize-space($label.markup)">
404 <xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
405 </xsl:if>
406 </xsl:if>
407 <xsl:apply-templates select="/*" mode="title.markup" />
408 </xsl:variable>
409 <xsl:variable name="href">
410 <xsl:call-template name="href.target.with.base.dir">
411 <xsl:with-param name="object" select="/" />
412 </xsl:call-template>
413 </xsl:variable>
414 <xsl:element name="docTitle" namespace="http://www.daisy.org/z3986/2005/ncx/">
415 <xsl:element name="text" namespace="http://www.daisy.org/z3986/2005/ncx/">
416 <xsl:value-of select="normalize-space($title)" />
417 </xsl:element>
418 </xsl:element>
419 <xsl:element name="navMap" namespace="http://www.daisy.org/z3986/2005/ncx/">
420 <xsl:choose>
421 <xsl:when test="$root.is.a.chunk != '0'">
422 <xsl:apply-templates select="/*" mode="ncx" />
423 </xsl:when>
424 <xsl:otherwise>
425 <xsl:apply-templates select="/*/*" mode="ncx" />
426 </xsl:otherwise>
427 </xsl:choose>
428 </xsl:element>
429 </xsl:otherwise>
430
431 </xsl:choose>
432 </xsl:element>
433 </xsl:with-param>
434 </xsl:call-template>
435 </xsl:template>
436
437 <xsl:template match="book|
438 article|
439 part|
440 reference|
441 preface|
442 chapter|
443 bibliography|
444 appendix|
445 glossary|
446 section|
447 sect1|
448 sect2|
449 sect3|
450 sect4|
451 sect5|
452 refentry|
453 colophon|
454 bibliodiv[title]|
455 setindex|
456 index"
457 mode="ncx">
458 <xsl:variable name="depth" select="count(ancestor::*)"/>
459 <xsl:variable name="title">
460 <xsl:if test="$epub.autolabel != 0">
461 <xsl:variable name="label.markup">
462 <xsl:apply-templates select="." mode="label.markup" />
463 </xsl:variable>
464 <xsl:if test="normalize-space($label.markup)">
465 <xsl:value-of
466 select="concat($label.markup,$autotoc.label.separator)" />
467 </xsl:if>
468 </xsl:if>
469 <xsl:apply-templates select="." mode="title.markup" />
470 </xsl:variable>
471
472 <xsl:variable name="href">
473 <xsl:call-template name="href.target.with.base.dir">
474 <xsl:with-param name="context" select="/" />
475 <!-- Generate links relative to the location of root file/toc.xml file -->
476 </xsl:call-template>
477 </xsl:variable>
478
479 <xsl:variable name="id">
480 <xsl:value-of select="generate-id(.)"/>
481 </xsl:variable>
482 <xsl:variable name="order">
483 <xsl:value-of select="$depth +
484 count(preceding::part|
485 preceding::reference|
486 preceding::book[parent::set]|
487 preceding::preface|
488 preceding::chapter|
489 preceding::bibliography|
490 preceding::appendix|
491 preceding::article|
492 preceding::glossary|
493 preceding::section[not(parent::partintro)]|
494 preceding::sect1[not(parent::partintro)]|
495 preceding::sect2[not(ancestor::partintro)]|
496 preceding::sect3[not(ancestor::partintro)]|
497 preceding::sect4[not(ancestor::partintro)]|
498 preceding::sect5[not(ancestor::partintro)]|
499 preceding::refentry|
500 preceding::colophon|
501 preceding::bibliodiv[title]|
502 preceding::index)"/>
503 </xsl:variable>
504
505 <xsl:element name="navPoint" namespace="http://www.daisy.org/z3986/2005/ncx/">
506 <xsl:attribute name="id">
507 <xsl:value-of select="$id"/>
508 </xsl:attribute>
509
510 <xsl:attribute name="playOrder">
511 <xsl:choose>
512 <xsl:when test="/*[self::set]">
513 <xsl:value-of select="$order"/>
514 </xsl:when>
515 <xsl:when test="$root.is.a.chunk != '0'">
516 <xsl:value-of select="$order + 1"/>
517 </xsl:when>
518 <xsl:otherwise>
519 <xsl:value-of select="$order - 0"/>
520 </xsl:otherwise>
521 </xsl:choose>
522 </xsl:attribute>
523 <xsl:element name="navLabel" namespace="http://www.daisy.org/z3986/2005/ncx/">
524 <xsl:element name="text" namespace="http://www.daisy.org/z3986/2005/ncx/"><xsl:value-of select="normalize-space($title)"/> </xsl:element>
525 </xsl:element>
526 <xsl:element name="content" namespace="http://www.daisy.org/z3986/2005/ncx/">
527 <xsl:attribute name="src">
528 <xsl:value-of select="$href"/>
529 </xsl:attribute>
530 </xsl:element>
531 <xsl:apply-templates select="book[parent::set]|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv[title]|setindex|index" mode="ncx"/>
532 </xsl:element>
533
534 </xsl:template>
535
536 <xsl:template match="*" mode="opf.metadata">
537 <!-- override if you care -->
538 </xsl:template>
539
540 <xsl:template match="authorgroup" mode="opf.metadata">
541 <xsl:apply-templates select="author|corpauthor" mode="opf.metadata"/>
542 </xsl:template>
543
544 <xsl:template match="author|corpauthor" mode="opf.metadata">
545 <xsl:variable name="n">
546 <xsl:call-template name="person.name">
547 <xsl:with-param name="node" select="."/>
548 </xsl:call-template>
549 </xsl:variable>
550 <xsl:element name="dc:creator">
551 <xsl:attribute name="opf:file-as">
552 <xsl:call-template name="person.name.last-first">
553 <xsl:with-param name="node" select="."/>
554 </xsl:call-template>
555 </xsl:attribute>
556 <xsl:value-of select="normalize-space(string($n))"/>
557 </xsl:element>
558 </xsl:template>
559
560 <xsl:template match="date" mode="opf.metadata">
561 <xsl:element name="dc:date">
562 <xsl:value-of select="normalize-space(string(.))"/>
563 </xsl:element>
564 </xsl:template>
565
566
567 <!-- Space separate the compontents of the abstract (dropping the inline markup, sadly) -->
568 <xsl:template match="abstract" mode="opf.metadata">
569 <xsl:element name="dc:description">
570 <xsl:for-each select="formalpara|para|simpara|title">
571 <xsl:choose>
572 <xsl:when test="self::formalpara">
573 <xsl:value-of select="normalize-space(string(title))"/>
574 <xsl:text>: </xsl:text>
575 <xsl:value-of select="normalize-space(string(para))"/>
576 </xsl:when>
577 <xsl:otherwise>
578 <xsl:value-of select="normalize-space(string(.))"/>
579 </xsl:otherwise>
580 </xsl:choose>
581 <xsl:if test="self::title">
582 <xsl:text>:</xsl:text>
583 </xsl:if>
584 <xsl:if test="not(position() = last())">
585 <xsl:text> </xsl:text>
586 </xsl:if>
587 </xsl:for-each>
588 </xsl:element>
589 </xsl:template>
590
591 <xsl:template match="subjectset" mode="opf.metadata">
592 <xsl:apply-templates select="subject/subjectterm" mode="opf.metadata"/>
593 </xsl:template>
594
595 <xsl:template match="subjectterm" mode="opf.metadata">
596 <xsl:element name="dc:subject">
597 <xsl:value-of select="normalize-space(string(.))"/>
598 </xsl:element>
599 </xsl:template>
600
601 <xsl:template match="publisher" mode="opf.metadata">
602 <xsl:apply-templates select="publishername" mode="opf.metadata"/>
603 </xsl:template>
604
605 <xsl:template match="publishername" mode="opf.metadata">
606 <xsl:element name="dc:publisher">
607 <xsl:value-of select="normalize-space(string(.))"/>
608 </xsl:element>
609 </xsl:template>
610
611 <xsl:template match="copyright" mode="opf.metadata">
612 <xsl:variable name="copyright.date">
613 <xsl:call-template name="copyright.years">
614 <xsl:with-param name="years" select="year"/>
615 <xsl:with-param name="print.ranges" select="$make.year.ranges"/>
616 <xsl:with-param name="single.year.ranges" select="$make.single.year.ranges"/>
617 </xsl:call-template>
618 </xsl:variable>
619 <xsl:if test="not(../date)">
620 <xsl:element name="dc:date">
621 <xsl:call-template name="copyright.years">
622 <xsl:with-param name="years" select="year[last()]"/>
623 <xsl:with-param name="print.ranges" select="0"/>
624 <xsl:with-param name="single.year.ranges" select="0"/>
625 </xsl:call-template>
626 </xsl:element>
627 </xsl:if>
628 <xsl:element name="dc:rights">
629 <xsl:call-template name="gentext">
630 <xsl:with-param name="key" select="'Copyright'"/>
631 </xsl:call-template>
632 <xsl:call-template name="gentext.space"/>
633 <xsl:text>&#x00A9;</xsl:text>
634 <xsl:call-template name="gentext.space"/>
635 <xsl:value-of select="$copyright.date"/>
636 <xsl:call-template name="gentext.space"/>
637 <xsl:apply-templates select="holder" mode="titlepage.mode"/>
638 </xsl:element>
639 </xsl:template>
640
641 <xsl:template name="opf.guide">
642 <xsl:if test="contains($toc.params, 'toc') or
643 /*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
644 <xsl:element namespace="http://www.idpf.org/2007/opf" name="guide">
645 <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
646 <xsl:element namespace="http://www.idpf.org/2007/opf" name="reference">
647 <xsl:attribute name="href">
648 <xsl:value-of select="$epub.cover.html" />
649 </xsl:attribute>
650 <xsl:attribute name="type">cover</xsl:attribute>
651 <xsl:attribute name="title">Cover</xsl:attribute>
652 </xsl:element>
653 </xsl:if>
654
655 <xsl:if test="contains($toc.params, 'toc')">
656 <xsl:element namespace="http://www.idpf.org/2007/opf" name="reference">
657 <xsl:attribute name="href">
658 <xsl:call-template name="toc-href">
659 <xsl:with-param name="node" select="/*"/>
660 </xsl:call-template>
661 </xsl:attribute>
662 <xsl:attribute name="type">toc</xsl:attribute>
663 <xsl:attribute name="title">Table of Contents</xsl:attribute>
664 </xsl:element>
665 </xsl:if>
666 </xsl:element>
667 </xsl:if>
668 </xsl:template>
669
670 <xsl:template name="opf.spine">
671
672 <xsl:element namespace="http://www.idpf.org/2007/opf" name="spine">
673 <xsl:attribute name="toc">
674 <xsl:value-of select="$epub.ncx.toc.id"/>
675 </xsl:attribute>
676
677 <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
678 <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
679 <xsl:attribute name="idref">
680 <xsl:value-of select="$epub.cover.id"/>
681 </xsl:attribute>
682 <xsl:attribute name="linear">
683 <xsl:choose>
684 <xsl:when test="$epub.cover.linear">
685 <xsl:text>yes</xsl:text>
686 </xsl:when>
687 <xsl:otherwise>no</xsl:otherwise>
688 </xsl:choose>
689 </xsl:attribute>
690 </xsl:element>
691 </xsl:if>
692
693
694 <xsl:if test="contains($toc.params, 'toc')">
695 <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
696 <xsl:attribute name="idref"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
697 <xsl:attribute name="linear">yes</xsl:attribute>
698 </xsl:element>
699 </xsl:if>
700
701 <!-- TODO: be nice to have a idref="titlepage" here -->
702 <xsl:choose>
703 <xsl:when test="$root.is.a.chunk != '0'">
704 <xsl:apply-templates select="/*" mode="opf.spine"/>
705 </xsl:when>
706 <xsl:otherwise>
707 <xsl:apply-templates select="/*/*" mode="opf.spine"/>
708 </xsl:otherwise>
709 </xsl:choose>
710
711 </xsl:element>
712 </xsl:template>
713
714 <xsl:template match="*" mode="opf.spine">
715 <xsl:variable name="is.chunk">
716 <xsl:call-template name="chunk">
717 <xsl:with-param name="node" select="."/>
718 </xsl:call-template>
719 </xsl:variable>
720
721 <xsl:if test="$is.chunk != 0">
722 <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
723 <xsl:attribute name="idref">
724 <xsl:value-of select="generate-id(.)"/>
725 </xsl:attribute>
726 </xsl:element>
727 <xsl:apply-templates select="*|.//refentry" mode="opf.spine"/>
728 </xsl:if>
729 </xsl:template>
730
731 <xsl:template name="opf.manifest">
732 <xsl:element namespace="http://www.idpf.org/2007/opf" name="manifest">
733 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
734 <xsl:attribute name="id"> <xsl:value-of select="$epub.ncx.toc.id"/> </xsl:attribute>
735 <xsl:attribute name="media-type">application/x-dtbncx+xml</xsl:attribute>
736 <xsl:attribute name="href"><xsl:value-of select="$epub.ncx.filename"/> </xsl:attribute>
737 </xsl:element>
738
739 <xsl:if test="contains($toc.params, 'toc')">
740 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
741 <xsl:attribute name="id"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
742 <xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
743 <xsl:attribute name="href">
744 <xsl:call-template name="toc-href">
745 <xsl:with-param name="node" select="/*"/>
746 </xsl:call-template>
747 </xsl:attribute>
748 </xsl:element>
749 </xsl:if>
750
751 <xsl:if test="$html.stylesheet != ''">
752 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
753 <xsl:attribute name="media-type">text/css</xsl:attribute>
754 <xsl:attribute name="id">css</xsl:attribute>
755 <xsl:attribute name="href"><xsl:value-of select="$html.stylesheet"/></xsl:attribute>
756 </xsl:element>
757 </xsl:if>
758
759 <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
760 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
761 <xsl:attribute name="id"> <xsl:value-of select="$epub.cover.id"/> </xsl:attribute>
762 <xsl:attribute name="href">
763 <xsl:value-of select="$epub.cover.html"/>
764 </xsl:attribute>
765 <xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
766 </xsl:element>
767 </xsl:if>
768
769 <xsl:choose>
770 <xsl:when test="$epub.embedded.fonts != '' and not(contains($epub.embedded.fonts, ','))">
771 <xsl:call-template name="embedded-font-item">
772 <xsl:with-param name="font.file" select="$epub.embedded.fonts"/> <!-- There is just one -->
773 </xsl:call-template>
774 </xsl:when>
775 <xsl:when test="$epub.embedded.fonts != ''">
776 <xsl:variable name="font.file.tokens" select="str:tokenize($epub.embedded.fonts, ',')"/>
777 <xsl:for-each select="exsl:node-set($font.file.tokens)">
778 <xsl:call-template name="embedded-font-item">
779 <xsl:with-param name="font.file" select="."/>
780 <xsl:with-param name="font.order" select="position()"/>
781 </xsl:call-template>
782 </xsl:for-each>
783 </xsl:when>
784 </xsl:choose>
785
786 <!-- TODO: be nice to have a id="titlepage" here -->
787 <xsl:apply-templates select="//part|
788 //book[*[last()][self::bookinfo]]|
789 //book[bookinfo]|
790 //book[*[last()][self::info]]|
791 //book[info]|
792 /set|
793 /set/book|
794 //reference|
795 //preface|
796 //chapter|
797 //bibliography|
798 //appendix|
799 //article|
800 //glossary|
801 //section|
802 //sect1|
803 //sect2|
804 //sect3|
805 //sect4|
806 //sect5|
807 //refentry|
808 //colophon|
809 //bibliodiv[title]|
810 //index|
811 //setindex|
812 //graphic|
813 //inlinegraphic|
814 //mediaobject|
815 //mediaobjectco|
816 //inlinemediaobject"
817 mode="opf.manifest"/>
818 <xsl:call-template name="opf.calloutlist"/>
819 </xsl:element>
820 </xsl:template>
821
822 <xsl:template name="opf.calloutlist">
823 <xsl:variable name="format">
824 <xsl:call-template name="guess-media-type">
825 <xsl:with-param name="ext" select="$callout.graphics.extension"/>
826 </xsl:call-template>
827 </xsl:variable>
828 <xsl:if test="(//calloutlist|//co)">
829 <xsl:call-template name="opf.reference.callout">
830 <xsl:with-param name="conum" select="1"/>
831 <xsl:with-param name="format" select="$format"/>
832 </xsl:call-template>
833 </xsl:if>
834 </xsl:template>
835
836 <xsl:template name="opf.reference.callout">
837 <xsl:param name="conum"/>
838 <xsl:param name="format"/>
839
840 <xsl:variable name="filename" select="concat($callout.graphics.path, $conum, $callout.graphics.extension)"/>
841
842 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
843 <xsl:attribute name="id"> <xsl:value-of select="concat(generate-id(.), 'callout', $conum)"/> </xsl:attribute>
844 <xsl:attribute name="href"> <xsl:value-of select="$filename"/> </xsl:attribute>
845 <xsl:attribute name="media-type">
846 <xsl:value-of select="$format"/>
847 </xsl:attribute>
848 </xsl:element>
849 <xsl:if test="($conum &lt; $callout.graphics.number.limit)">
850 <xsl:call-template name="opf.reference.callout">
851 <xsl:with-param name="conum" select="$conum + 1"/>
852 <xsl:with-param name="format" select="$format"/>
853 </xsl:call-template>
854 </xsl:if>
855 </xsl:template>
856
857 <xsl:template name="guess-media-type">
858 <xsl:param name="ext"></xsl:param>
859 <xsl:choose>
860 <xsl:when test="contains($ext, '.gif')">
861 <xsl:text>image/gif</xsl:text>
862 </xsl:when>
863 <xsl:when test="contains($ext, 'GIF')">
864 <xsl:text>image/gif</xsl:text>
865 </xsl:when>
866 <xsl:when test="contains($ext, '.png')">
867 <xsl:text>image/png</xsl:text>
868 </xsl:when>
869 <xsl:when test="contains($ext, 'PNG')">
870 <xsl:text>image/png</xsl:text>
871 </xsl:when>
872 <xsl:when test="contains($ext, '.jpeg')">
873 <xsl:text>image/jpeg</xsl:text>
874 </xsl:when>
875 <xsl:when test="contains($ext, 'JPEG')">
876 <xsl:text>image/jpeg</xsl:text>
877 </xsl:when>
878 <xsl:when test="contains($ext, '.jpg')">
879 <xsl:text>image/jpeg</xsl:text>
880 </xsl:when>
881 <xsl:when test="contains($ext, 'JPG')">
882 <xsl:text>image/jpeg</xsl:text>
883 </xsl:when>
884 <xsl:when test="contains($ext, '.svg')">
885 <xsl:text>image/svg+xml</xsl:text>
886 </xsl:when>
887 <xsl:when test="contains($ext, 'SVG')">
888 <xsl:text>image/svg+xml</xsl:text>
889 </xsl:when>
890 <xsl:otherwise>
891 <!-- we failed -->
892 <xsl:text></xsl:text>
893 </xsl:otherwise>
894 </xsl:choose>
895 </xsl:template>
896
897 <xsl:template match="mediaobject|
898 mediaobjectco|
899 inlinemediaobject"
900 mode="opf.manifest">
901
902 <xsl:variable name="olist" select="imageobject|imageobjectco |videoobject|audioobject |textobject"/>
903
904 <xsl:variable name="object.index">
905 <xsl:call-template name="select.mediaobject.index">
906 <xsl:with-param name="olist" select="$olist"/>
907 <xsl:with-param name="count" select="1"/>
908 </xsl:call-template>
909 </xsl:variable>
910
911 <xsl:variable name="object" select="$olist[position() = $object.index]"/>
912
913 <xsl:choose>
914 <xsl:when test="$object/descendant::imagedata[@format = 'GIF' or
915 @format = 'GIF87a' or
916 @format = 'GIF89a' or
917 @format = 'JPEG' or
918 @format = 'JPG' or
919 @format = 'PNG' or
920 @format = 'SVG']">
921 <xsl:apply-templates select="$object[descendant::imagedata[@format = 'GIF' or
922 @format = 'GIF87a' or
923 @format = 'GIF89a' or
924 @format = 'JPEG' or
925 @format = 'JPG' or
926 @format = 'PNG' or
927 @format = 'SVG']][1]/imagedata"
928 mode="opf.manifest"/>
929 </xsl:when>
930 <xsl:otherwise>
931 <xsl:apply-templates select="$object/imagedata[1]"
932 mode="opf.manifest"/>
933 </xsl:otherwise>
934 </xsl:choose>
935 </xsl:template>
936
937 <xsl:template match="cover/mediaobject|
938 mediaobject[@role='cover']"
939 mode="opf.manifest">
940 <xsl:choose>
941 <xsl:when test="imageobject[@role='front-large']">
942 <xsl:apply-templates select="imageobject[@role='front-large']/imagedata"
943 mode="opf.manifest"/>
944 </xsl:when>
945 <xsl:otherwise>
946 <xsl:apply-templates select="imageobject/imagedata[1]"
947 mode="opf.manifest"/>
948 </xsl:otherwise>
949 </xsl:choose>
950 </xsl:template>
951
952 <xsl:template match="mediaobjectco"
953 mode="opf.manifest">
954 <xsl:message>WARNING: mediaobjectco almost certainly will not render as expected in .epub!</xsl:message>
955 <xsl:apply-templates select="imageobjectco/imageobject/imagedata"
956 mode="opf.manifest"/>
957 </xsl:template>
958
959 <!-- TODO: Barf (xsl:message terminate=yes) if you find a graphic with no reasonable format or a mediaobject w/o same? [option to not die?] -->
960
961 <!-- wish I had XSLT2 ...-->
962 <!-- TODO: priority a hack -->
963 <xsl:template match="graphic[not(@format)]|
964 inlinegraphic[not(@format)]|
965 imagedata[not(@format)]"
966 mode="opf.manifest">
967 <xsl:variable name="filename">
968 <xsl:choose>
969 <xsl:when test="contains(name(.), 'graphic')">
970 <xsl:choose>
971 <xsl:when test="@entityref">
972 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
973 </xsl:when>
974 <xsl:otherwise>
975 <xsl:apply-templates select="@fileref"/>
976 </xsl:otherwise>
977 </xsl:choose>
978 </xsl:when>
979 <xsl:otherwise>
980 <xsl:call-template name="mediaobject.filename">
981 <xsl:with-param name="object" select=".."/>
982 </xsl:call-template>
983 </xsl:otherwise>
984 </xsl:choose>
985 </xsl:variable>
986 <xsl:variable name="format">
987 <xsl:call-template name="guess-media-type">
988 <xsl:with-param name="ext" select="@fileref"/>
989 </xsl:call-template>
990 </xsl:variable>
991 <xsl:variable name="fr" select="@fileref"/>
992 <xsl:if test="$format != ''">
993 <!-- only do this if we're the first file to match -->
994 <!-- TODO: Why can't this be simple equality?? (I couldn't get it to work) -->
995 <xsl:if test="generate-id(.) = generate-id(key('image-filerefs', $fr)[1])">
996 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
997 <xsl:attribute name="id">
998 <xsl:choose>
999 <xsl:when test="ancestor::mediaobject[@role='cover'] and parent::*[@role='front-large']">
1000 <xsl:value-of select="$epub.cover.image.id"/>
1001 </xsl:when>
1002 <xsl:when test="ancestor::mediaobject[@role='cover'] and (count(ancestor::mediaobject//imageobject) = 1)">
1003 <xsl:value-of select="$epub.cover.image.id"/>
1004 </xsl:when>
1005 <xsl:when test="ancestor::cover">
1006 <xsl:value-of select="$epub.cover.image.id"/>
1007 </xsl:when>
1008 <xsl:otherwise>
1009 <xsl:value-of select="generate-id(.)"/>
1010 </xsl:otherwise>
1011 </xsl:choose>
1012 </xsl:attribute>
1013 <xsl:attribute name="href"> <xsl:value-of select="$filename"/> </xsl:attribute>
1014 <xsl:attribute name="media-type">
1015 <xsl:value-of select="$format"/>
1016 </xsl:attribute>
1017 </xsl:element>
1018 </xsl:if>
1019 </xsl:if>
1020 </xsl:template>
1021
1022 <!-- Note: Selection of the first interesting imagedata is done in the select -->
1023 <xsl:template match="graphic[@format = 'GIF' or @format = 'GIF87a' or @format = 'GIF89a' or @format = 'JPEG' or @format = 'JPG' or @format = 'PNG' or @format = 'SVG']|
1024 inlinegraphic[@format = 'GIF' or @format = 'GIF87a' or @format = 'GIF89a' or @format = 'JPEG' or @format = 'JPG' or @format = 'PNG' or @format = 'SVG']|
1025 imagedata[@format]"
1026 mode="opf.manifest">
1027 <xsl:variable name="filename">
1028 <xsl:choose>
1029 <xsl:when test="contains(name(.), 'graphic')">
1030 <xsl:choose>
1031 <xsl:when test="@entityref">
1032 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
1033 </xsl:when>
1034 <xsl:otherwise>
1035 <xsl:apply-templates select="@fileref"/>
1036 </xsl:otherwise>
1037 </xsl:choose>
1038 </xsl:when>
1039 <xsl:otherwise>
1040 <xsl:call-template name="mediaobject.filename">
1041 <xsl:with-param name="object" select=".."/>
1042 </xsl:call-template>
1043 </xsl:otherwise>
1044 </xsl:choose>
1045 </xsl:variable>
1046 <xsl:variable name="fr" select="@fileref"/>
1047 <!-- only do this if we're the first file to match -->
1048 <!-- TODO: Why can't this be simple equality?? (I couldn't get it to work) -->
1049 <xsl:if test="generate-id(.) = generate-id(key('image-filerefs', $fr)[1])">
1050 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
1051 <xsl:attribute name="id">
1052 <xsl:choose>
1053 <xsl:when test="ancestor::mediaobject[@role='cover'] and parent::*[@role='front-large']">
1054 <xsl:value-of select="$epub.cover.image.id"/>
1055 </xsl:when>
1056 <xsl:when test="ancestor::mediaobject[@role='cover'] and (count(ancestor::mediaobject//imageobject) = 1)">
1057 <xsl:value-of select="$epub.cover.image.id"/>
1058 </xsl:when>
1059 <xsl:when test="ancestor::cover">
1060 <xsl:value-of select="$epub.cover.image.id"/>
1061 </xsl:when>
1062 <xsl:otherwise>
1063 <xsl:value-of select="generate-id(.)"/>
1064 </xsl:otherwise>
1065 </xsl:choose>
1066 </xsl:attribute>
1067 <xsl:attribute name="href"> <xsl:value-of select="$filename"/> </xsl:attribute>
1068 <xsl:attribute name="media-type">
1069 <xsl:call-template name="guess-media-type">
1070 <xsl:with-param name="ext" select="@format"/>
1071 </xsl:call-template>
1072 </xsl:attribute>
1073 </xsl:element>
1074 </xsl:if>
1075 </xsl:template>
1076
1077 <!-- Warning: While the test indicate this match list is accurate, it may
1078 need further tweaking to ensure _never_ dropping generated content (XHTML)
1079 from the manifest (OPF file) -->
1080 <xsl:template
1081 match="set|
1082 book[parent::set]|
1083 book[*[last()][self::bookinfo]]|
1084 book[bookinfo]|
1085 book[*[last()][self::info]]|
1086 book[info]|
1087 article|
1088 part|
1089 reference|
1090 preface|
1091 chapter|
1092 bibliography|
1093 appendix|
1094 glossary|
1095 section|
1096 sect1|
1097 sect2|
1098 sect3|
1099 sect4|
1100 sect5|
1101 refentry|
1102 colophon|
1103 bibliodiv[title]|
1104 setindex|
1105 index"
1106 mode="opf.manifest">
1107 <xsl:variable name="href">
1108 <xsl:call-template name="href.target.with.base.dir">
1109 <xsl:with-param name="context" select="/" />
1110 <!-- Generate links relative to the location of root file/toc.xml file -->
1111 </xsl:call-template>
1112 </xsl:variable>
1113
1114 <xsl:variable name="id">
1115 <xsl:value-of select="generate-id(.)"/>
1116 </xsl:variable>
1117
1118 <xsl:variable name="is.chunk">
1119 <xsl:call-template name="chunk">
1120 <xsl:with-param name="node" select="."/>
1121 </xsl:call-template>
1122 </xsl:variable>
1123
1124 <xsl:if test="$is.chunk != 0">
1125 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
1126 <xsl:attribute name="id"> <xsl:value-of select="$id"/> </xsl:attribute>
1127 <xsl:attribute name="href"> <xsl:value-of select="$href"/> </xsl:attribute>
1128 <xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
1129 </xsl:element>
1130 </xsl:if>
1131 </xsl:template>
1132
1133 <xsl:template match="text()" mode="ncx" />
1134
1135 <xsl:template name="html.head">
1136 <xsl:param name="prev" select="/foo"/>
1137 <xsl:param name="next" select="/foo"/>
1138 <xsl:variable name="this" select="."/>
1139 <xsl:variable name="home" select="/*[1]"/>
1140 <xsl:variable name="up" select="parent::*"/>
1141
1142 <head xmlns="http://www.w3.org/1999/xhtml">
1143 <xsl:call-template name="system.head.content"/>
1144 <xsl:call-template name="head.content"/>
1145
1146 <xsl:call-template name="user.head.content"/>
1147 </head>
1148 </xsl:template>
1149
1150 <!-- OVERRIDES xhtml-1_1/graphics.xsl -->
1151 <!-- we can't deal with no img/@alt, because it's required. Try grabbing a title before it instead (hopefully meaningful) -->
1152 <xsl:template name="process.image.attributes">
1153 <xsl:param name="alt"/>
1154 <xsl:param name="html.width"/>
1155 <xsl:param name="html.depth"/>
1156 <xsl:param name="longdesc"/>
1157 <xsl:param name="scale"/>
1158 <xsl:param name="scalefit"/>
1159 <xsl:param name="scaled.contentdepth"/>
1160 <xsl:param name="scaled.contentwidth"/>
1161 <xsl:param name="viewport"/>
1162
1163 <xsl:choose>
1164 <xsl:when test="@contentwidth or @contentdepth">
1165 <!-- ignore @width/@depth, @scale, and @scalefit if specified -->
1166 <xsl:if test="@contentwidth and $scaled.contentwidth != ''">
1167 <xsl:attribute name="width">
1168 <xsl:value-of select="$scaled.contentwidth"/>
1169 </xsl:attribute>
1170 </xsl:if>
1171 <xsl:if test="@contentdepth and $scaled.contentdepth != ''">
1172 <xsl:attribute name="height">
1173 <xsl:value-of select="$scaled.contentdepth"/>
1174 </xsl:attribute>
1175 </xsl:if>
1176 </xsl:when>
1177
1178 <xsl:when test="number($scale) != 1.0">
1179 <!-- scaling is always uniform, so we only have to specify one dimension -->
1180 <!-- ignore @scalefit if specified -->
1181 <xsl:attribute name="width">
1182 <xsl:value-of select="$scaled.contentwidth"/>
1183 </xsl:attribute>
1184 </xsl:when>
1185
1186 <xsl:when test="$scalefit != 0">
1187 <xsl:choose>
1188 <xsl:when test="contains($html.width, '%')">
1189 <xsl:choose>
1190 <xsl:when test="$viewport != 0">
1191 <!-- The *viewport* will be scaled, so use 100% here! -->
1192 <xsl:attribute name="width">
1193 <xsl:value-of select="'100%'"/>
1194 </xsl:attribute>
1195 </xsl:when>
1196 <xsl:otherwise>
1197 <xsl:attribute name="width">
1198 <xsl:value-of select="$html.width"/>
1199 </xsl:attribute>
1200 </xsl:otherwise>
1201 </xsl:choose>
1202 </xsl:when>
1203
1204 <xsl:when test="contains($html.depth, '%')">
1205 <!-- HTML doesn't deal with this case very well...do nothing -->
1206 </xsl:when>
1207
1208 <xsl:when test="$scaled.contentwidth != '' and $html.width != '' and $scaled.contentdepth != '' and $html.depth != ''">
1209 <!-- scalefit should not be anamorphic; figure out which direction -->
1210 <!-- has the limiting scale factor and scale in that direction -->
1211 <xsl:choose>
1212 <xsl:when test="$html.width div $scaled.contentwidth &gt; $html.depth div $scaled.contentdepth">
1213 <xsl:attribute name="height">
1214 <xsl:value-of select="$html.depth"/>
1215 </xsl:attribute>
1216 </xsl:when>
1217 <xsl:otherwise>
1218 <xsl:attribute name="width">
1219 <xsl:value-of select="$html.width"/>
1220 </xsl:attribute>
1221 </xsl:otherwise>
1222 </xsl:choose>
1223 </xsl:when>
1224
1225 <xsl:when test="$scaled.contentwidth != '' and $html.width != ''">
1226 <xsl:attribute name="width">
1227 <xsl:value-of select="$html.width"/>
1228 </xsl:attribute>
1229 </xsl:when>
1230
1231 <xsl:when test="$scaled.contentdepth != '' and $html.depth != ''">
1232 <xsl:attribute name="height">
1233 <xsl:value-of select="$html.depth"/>
1234 </xsl:attribute>
1235 </xsl:when>
1236 </xsl:choose>
1237 </xsl:when>
1238 </xsl:choose>
1239
1240 <!-- AN OVERRIDE -->
1241 <xsl:if test="not(@format ='SVG')">
1242 <xsl:attribute name="alt">
1243 <xsl:choose>
1244 <xsl:when test="$alt != ''">
1245 <xsl:value-of select="normalize-space($alt)"/>
1246 </xsl:when>
1247 <xsl:when test="preceding::title[1]">
1248 <xsl:value-of select="normalize-space(preceding::title[1])"/>
1249 </xsl:when>
1250 <xsl:otherwise>
1251 <xsl:text>(missing alt)</xsl:text>
1252 </xsl:otherwise>
1253 </xsl:choose>
1254 </xsl:attribute>
1255 </xsl:if>
1256 <!-- END OF OVERRIDE -->
1257
1258 <xsl:if test="$longdesc != ''">
1259 <xsl:attribute name="longdesc">
1260 <xsl:value-of select="$longdesc"/>
1261 </xsl:attribute>
1262 </xsl:if>
1263
1264 <xsl:if test="@align and $viewport = 0">
1265 <xsl:attribute name="style"><xsl:text>text-align: </xsl:text>
1266 <xsl:choose>
1267 <xsl:when test="@align = 'center'">middle</xsl:when>
1268 <xsl:otherwise>
1269 <xsl:value-of select="@align"/>
1270 </xsl:otherwise>
1271 </xsl:choose>
1272 </xsl:attribute>
1273 </xsl:if>
1274 </xsl:template>
1275
1276 <!-- OVERRIDES xhtml-1_1/chunk-common.xsl -->
1277 <!-- make a bibliography always a chunk -->
1278 <xsl:template name="chunk">
1279 <xsl:param name="node" select="."/>
1280 <!-- returns 1 if $node is a chunk -->
1281
1282 <!-- ==================================================================== -->
1283 <!-- What's a chunk?
1284
1285 The root element
1286 appendix
1287 article
1288 bibliography ### NO LONGER TRUE in article or part or book
1289 book
1290 chapter
1291 colophon
1292 glossary in article or part or book
1293 index in article or part or book
1294 part
1295 preface
1296 refentry
1297 reference
1298 sect{1,2,3,4,5} if position()>1 && depth < chunk.section.depth
1299 section if position()>1 && depth < chunk.section.depth
1300 set
1301 setindex
1302 -->
1303 <!-- ==================================================================== -->
1304
1305 <!--
1306 <xsl:message>
1307 <xsl:text>chunk: </xsl:text>
1308 <xsl:value-of select="name($node)"/>
1309 <xsl:text>(</xsl:text>
1310 <xsl:value-of select="$node/@id"/>
1311 <xsl:text>)</xsl:text>
1312 <xsl:text> csd: </xsl:text>
1313 <xsl:value-of select="$chunk.section.depth"/>
1314 <xsl:text> cfs: </xsl:text>
1315 <xsl:value-of select="$chunk.first.sections"/>
1316 <xsl:text> ps: </xsl:text>
1317 <xsl:value-of select="count($node/parent::section)"/>
1318 <xsl:text> prs: </xsl:text>
1319 <xsl:value-of select="count($node/preceding-sibling::section)"/>
1320 </xsl:message>
1321 -->
1322
1323 <xsl:choose>
1324 <xsl:when test="not($node/parent::*)">1</xsl:when>
1325
1326 <xsl:when test="local-name($node) = 'sect1' and $chunk.section.depth &gt;= 1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect1) &gt; 0)">
1327 <xsl:text>1</xsl:text>
1328 </xsl:when>
1329 <xsl:when test="local-name($node) = 'sect2' and $chunk.section.depth &gt;= 2 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect2) &gt; 0)">
1330 <xsl:call-template name="chunk">
1331 <xsl:with-param name="node" select="$node/parent::*"/>
1332 </xsl:call-template>
1333 </xsl:when>
1334 <xsl:when test="local-name($node) = 'sect3' and $chunk.section.depth &gt;= 3 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect3) &gt; 0)">
1335 <xsl:call-template name="chunk">
1336 <xsl:with-param name="node" select="$node/parent::*"/>
1337 </xsl:call-template>
1338 </xsl:when>
1339 <xsl:when test="local-name($node) = 'sect4' and $chunk.section.depth &gt;= 4 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect4) &gt; 0)">
1340 <xsl:call-template name="chunk">
1341 <xsl:with-param name="node" select="$node/parent::*"/>
1342 </xsl:call-template>
1343 </xsl:when>
1344 <xsl:when test="local-name($node) = 'sect5' and $chunk.section.depth &gt;= 5 and ($chunk.first.sections != 0 or count($node/preceding-sibling::sect5) &gt; 0)">
1345 <xsl:call-template name="chunk">
1346 <xsl:with-param name="node" select="$node/parent::*"/>
1347 </xsl:call-template>
1348 </xsl:when>
1349 <xsl:when test="local-name($node) = 'section' and $chunk.section.depth &gt;= count($node/ancestor::section)+1 and ($chunk.first.sections != 0 or count($node/preceding-sibling::section) &gt; 0)">
1350 <xsl:call-template name="chunk">
1351 <xsl:with-param name="node" select="$node/parent::*"/>
1352 </xsl:call-template>
1353 </xsl:when>
1354
1355 <xsl:when test="local-name($node)='preface'">1</xsl:when>
1356 <xsl:when test="local-name($node)='chapter'">1</xsl:when>
1357 <xsl:when test="local-name($node)='appendix'">1</xsl:when>
1358 <xsl:when test="local-name($node)='article'">1</xsl:when>
1359 <xsl:when test="local-name($node)='part'">1</xsl:when>
1360 <xsl:when test="local-name($node)='reference'">1</xsl:when>
1361 <xsl:when test="local-name($node)='refentry'">1</xsl:when>
1362 <xsl:when test="local-name($node)='index' and ($generate.index != 0 or count($node/*) &gt; 0) and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
1363 <!-- AN OVERRIDE -->
1364 <xsl:when test="local-name($node)='bibliography'">1</xsl:when>
1365 <!-- END OF OVERRIDE -->
1366 <xsl:when test="local-name($node)='glossary' and (local-name($node/parent::*) = 'article' or local-name($node/parent::*) = 'book' or local-name($node/parent::*) = 'part' )">1</xsl:when>
1367 <xsl:when test="local-name($node)='colophon'">1</xsl:when>
1368 <xsl:when test="local-name($node)='book'">1</xsl:when>
1369 <xsl:when test="local-name($node)='set'">1</xsl:when>
1370 <xsl:when test="local-name($node)='setindex'">1</xsl:when>
1371 <xsl:when test="local-name($node)='legalnotice' and $generate.legalnotice.link != 0">1</xsl:when>
1372 <xsl:otherwise>0</xsl:otherwise>
1373 </xsl:choose>
1374 </xsl:template>
1375
1376 <!-- OVERRIDES xhtml-1_1/chunk-code.xsl -->
1377 <!-- Add chunking for bibliography as root element -->
1378 <!-- AN OVERRIDE -->
1379 <xsl:template match="set|
1380 book|
1381 part|
1382 preface|
1383 chapter|
1384 appendix|
1385 article|
1386 reference|
1387 refentry|
1388 book/glossary|
1389 article/glossary|
1390 part/glossary|
1391 bibliography|
1392 colophon"
1393 priority="1">
1394 <!-- END OF OVERRIDE -->
1395 <xsl:choose>
1396 <xsl:when test="$onechunk != 0 and parent::*">
1397 <xsl:apply-imports/>
1398 </xsl:when>
1399 <xsl:otherwise>
1400 <xsl:call-template name="process-chunk-element"/>
1401 </xsl:otherwise>
1402 </xsl:choose>
1403 </xsl:template>
1404
1405 <!-- OVERRIDES xhtml-1_1/graphics.xsl -->
1406 <!-- Do _NOT_ output any xlink garbage, so if you don't have
1407 processor with extensions, you're screwed and we're terminating -->
1408 <xsl:template match="inlinegraphic">
1409 <xsl:variable name="filename">
1410 <xsl:choose>
1411 <xsl:when test="@entityref">
1412 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
1413 </xsl:when>
1414 <xsl:otherwise>
1415 <xsl:apply-templates select="@fileref"/>
1416 </xsl:otherwise>
1417 </xsl:choose>
1418 </xsl:variable>
1419
1420 <xsl:call-template name="anchor"/>
1421
1422 <xsl:choose>
1423 <xsl:when test="@format='linespecific'">
1424 <xsl:choose>
1425 <xsl:when test="$use.extensions != '0' and $textinsert.extension != '0'">
1426 <xsl:choose>
1427 <xsl:when test="element-available('stext:insertfile')">
1428 <stext:insertfile href="{$filename}" encoding="{$textdata.default.encoding}"/>
1429 </xsl:when>
1430 <xsl:when test="element-available('xtext:insertfile')">
1431 <xtext:insertfile href="{$filename}"/>
1432 </xsl:when>
1433 <xsl:otherwise>
1434 <xsl:message terminate="yes">
1435 <xsl:text>No insertfile extension available.</xsl:text>
1436 </xsl:message>
1437 </xsl:otherwise>
1438 </xsl:choose>
1439 </xsl:when>
1440 <xsl:otherwise>
1441 <!-- AN OVERRIDE -->
1442 <xsl:message terminate="yes">
1443 <xsl:text>No insertfile extension available. Use a different processor (with extensions) or turn on $use.extensions and $textinsert.extension (see docs for more). </xsl:text>
1444 </xsl:message>
1445 <!-- END OF OVERRIDE -->
1446 </xsl:otherwise>
1447 </xsl:choose>
1448 </xsl:when>
1449 <xsl:otherwise>
1450 <xsl:call-template name="process.image"/>
1451 </xsl:otherwise>
1452 </xsl:choose>
1453 </xsl:template>
1454
1455 <xsl:template name="cover">
1456 <xsl:apply-templates select="/*/*[contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]"/>
1457 </xsl:template>
1458
1459 <xsl:template match="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]">
1460 <xsl:call-template name="write.chunk">
1461 <xsl:with-param name="filename">
1462 <xsl:value-of select="$epub.cover.filename" />
1463 </xsl:with-param>
1464 <xsl:with-param name="method" select="'xml'" />
1465 <xsl:with-param name="encoding" select="'utf-8'" />
1466 <xsl:with-param name="indent" select="'no'" />
1467 <xsl:with-param name="quiet" select="$chunk.quietly" />
1468 <xsl:with-param name="content">
1469 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="html">
1470 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="head">
1471 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="title">Cover</xsl:element>
1472 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="style">
1473 <xsl:attribute name="type">text/css</xsl:attribute>
1474 <!-- Help the cover image scale nicely in the CSS then apply a max-width to look better in Adobe Digital Editions -->
1475 <xsl:text> img { max-width: 100%; }</xsl:text>
1476 </xsl:element>
1477 </xsl:element>
1478 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="body">
1479 <xsl:element namespace="http://www.w3.org/1999/xhtml" name="div">
1480 <xsl:attribute name="id">
1481 <xsl:value-of select="$epub.cover.image.id"/>
1482 </xsl:attribute>
1483 <xsl:choose>
1484 <xsl:when test="imageobject[@role='front-large']">
1485 <xsl:apply-templates select="imageobject[@role='front-large']"/>
1486 </xsl:when>
1487 <xsl:otherwise>
1488 <xsl:apply-templates select="imageobject[1]"/>
1489 </xsl:otherwise>
1490 </xsl:choose>
1491 </xsl:element>
1492 <!-- If this is defined as an explicit cover page, then process
1493 any remaining text -->
1494 <xsl:if test="ancestor::cover">
1495 <xsl:apply-templates select="ancestor::cover/para"/>
1496 </xsl:if>
1497 </xsl:element>
1498 </xsl:element>
1499 </xsl:with-param>
1500 </xsl:call-template>
1501 </xsl:template>
1502
1503 <xsl:template name="cover-svg">
1504 <xsl:param name="node"/>
1505 </xsl:template>
1506
1507 <xsl:template name="toc-href">
1508 <xsl:param name="node" select="."/>
1509 <xsl:apply-templates select="$node" mode="recursive-chunk-filename">
1510 <xsl:with-param name="recursive" select="true()"/>
1511 </xsl:apply-templates>
1512 <xsl:text>-toc</xsl:text>
1513 <xsl:value-of select="$html.ext"/>
1514 </xsl:template>
1515
1516 <xsl:template match="bibliodiv[title]" mode="label.markup">
1517 </xsl:template>
1518
1519 <xsl:template match="token" mode="opf.manifest.font">
1520 <xsl:call-template name="embedded-font-item">
1521 <xsl:with-param name="font.file" select="."/>
1522 </xsl:call-template>
1523 </xsl:template>
1524
1525 <xsl:template name="embedded-font-item">
1526 <xsl:param name="font.file"/>
1527 <xsl:param name="font.order" select="1"/>
1528
1529 <xsl:element namespace="http://www.idpf.org/2007/opf" name="item">
1530 <xsl:attribute name="id">
1531 <xsl:value-of select="concat('epub.embedded.font.', $font.order)"/>
1532 </xsl:attribute>
1533 <xsl:attribute name="href"><xsl:value-of select="$font.file"/></xsl:attribute>
1534 <xsl:choose>
1535 <xsl:when test="contains($font.file, 'otf')">
1536 <xsl:attribute name="media-type">font/opentype</xsl:attribute>
1537 </xsl:when>
1538 <xsl:otherwise>
1539 <xsl:message>
1540 <xsl:text>WARNING: OpenType fonts should be supplied! (</xsl:text>
1541 <xsl:value-of select="$font.file"/>
1542 <xsl:text>)</xsl:text>
1543 </xsl:message>
1544 </xsl:otherwise>
1545 </xsl:choose>
1546 </xsl:element>
1547 </xsl:template>
1548
1549<!-- Change section.heading to improve SEO on generated HTML by doing heading levels
1550 "correctly". SEO rules are sometimes silly silly, but this does actually create
1551 a semantic improvement.
1552 Note: This template needs to be manually maintained outside of the html/sections.xsl
1553 code, so make sure important changes get reintegrated. -->
1554<xsl:template name="section.heading">
1555 <xsl:param name="section" select="."/>
1556 <xsl:param name="level" select="1"/>
1557 <xsl:param name="allow-anchors" select="1"/>
1558 <xsl:param name="title"/>
1559 <xsl:param name="class" select="'title'"/>
1560
1561 <xsl:variable name="id">
1562 <xsl:choose>
1563 <!-- Make sure the subtitle doesn't get the same id as the title -->
1564 <xsl:when test="self::subtitle">
1565 <xsl:call-template name="object.id">
1566 <xsl:with-param name="object" select="."/>
1567 </xsl:call-template>
1568 </xsl:when>
1569 <!-- if title is in an *info wrapper, get the grandparent -->
1570 <xsl:when test="contains(local-name(..), 'info')">
1571 <xsl:call-template name="object.id">
1572 <xsl:with-param name="object" select="../.."/>
1573 </xsl:call-template>
1574 </xsl:when>
1575 <xsl:otherwise>
1576 <xsl:call-template name="object.id">
1577 <xsl:with-param name="object" select=".."/>
1578 </xsl:call-template>
1579 </xsl:otherwise>
1580 </xsl:choose>
1581 </xsl:variable>
1582
1583 <!-- For SEO, we try to actually ensure we *always* output one and only one h1,
1584 so unlike the regular stylesheets, we don't add one to the section level and
1585 we get the right behavior because of chunking. -->
1586 <xsl:variable name="hlevel">
1587 <xsl:choose>
1588 <!-- highest valid HTML H level is H6; so anything nested deeper
1589 than 7 levels down just becomes H6 -->
1590 <xsl:when test="$level &gt; 6">6</xsl:when>
1591 <xsl:otherwise>
1592 <xsl:value-of select="$level"/>
1593 </xsl:otherwise>
1594 </xsl:choose>
1595 </xsl:variable>
1596 <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
1597 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
1598 <xsl:if test="$css.decoration != '0'">
1599 <xsl:if test="$hlevel&lt;3">
1600 <xsl:attribute name="style">clear: both</xsl:attribute>
1601 </xsl:if>
1602 </xsl:if>
1603 <xsl:if test="$allow-anchors != 0 and $generate.id.attributes = 0">
1604 <xsl:call-template name="anchor">
1605 <xsl:with-param name="node" select="$section"/>
1606 <xsl:with-param name="conditional" select="0"/>
1607 </xsl:call-template>
1608 </xsl:if>
1609 <xsl:if test="$generate.id.attributes != 0 and not(local-name(.) = 'appendix')">
1610 <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
1611 </xsl:if>
1612 <xsl:copy-of select="$title"/>
1613 </xsl:element>
1614</xsl:template>
1615
1616<!-- ==================================================================== -->
1617
1618<xsl:template match="bridgehead">
1619 <xsl:variable name="container" select="(ancestor::appendix |ancestor::article |ancestor::bibliography |ancestor::chapter |ancestor::glossary |ancestor::glossdiv |ancestor::index |ancestor::partintro |ancestor::preface |ancestor::refsect1 |ancestor::refsect2 |ancestor::refsect3 |ancestor::sect1 |ancestor::sect2 |ancestor::sect3 |ancestor::sect4 |ancestor::sect5 |ancestor::section |ancestor::setindex |ancestor::simplesect)[last()]"/>
1620
1621 <xsl:variable name="clevel">
1622 <xsl:choose>
1623 <xsl:when test="local-name($container) = 'appendix' or local-name($container) = 'chapter' or local-name($container) = 'article' or local-name($container) = 'bibliography' or local-name($container) = 'glossary' or local-name($container) = 'index' or local-name($container) = 'partintro' or local-name($container) = 'preface' or local-name($container) = 'setindex'">1</xsl:when>
1624 <xsl:when test="local-name($container) = 'glossdiv'">
1625 <xsl:value-of select="count(ancestor::glossdiv)+1"/>
1626 </xsl:when>
1627 <xsl:when test="local-name($container) = 'sect1' or local-name($container) = 'sect2' or local-name($container) = 'sect3' or local-name($container) = 'sect4' or local-name($container) = 'sect5' or local-name($container) = 'refsect1' or local-name($container) = 'refsect2' or local-name($container) = 'refsect3' or local-name($container) = 'section' or local-name($container) = 'simplesect'">
1628 <xsl:variable name="slevel">
1629 <xsl:call-template name="section.level">
1630 <xsl:with-param name="node" select="$container"/>
1631 </xsl:call-template>
1632 </xsl:variable>
1633 <xsl:value-of select="$slevel + 1"/>
1634 </xsl:when>
1635 <xsl:otherwise>1</xsl:otherwise>
1636 </xsl:choose>
1637 </xsl:variable>
1638
1639 <!-- HTML H level is one higher than section level -->
1640 <xsl:variable name="hlevel">
1641 <xsl:choose>
1642 <xsl:when test="@renderas = 'sect1'">1</xsl:when>
1643 <xsl:when test="@renderas = 'sect2'">2</xsl:when>
1644 <xsl:when test="@renderas = 'sect3'">3</xsl:when>
1645 <xsl:when test="@renderas = 'sect4'">4</xsl:when>
1646 <xsl:when test="@renderas = 'sect5'">5</xsl:when>
1647 <xsl:otherwise>
1648 <xsl:value-of select="$clevel + 1"/>
1649 </xsl:otherwise>
1650 </xsl:choose>
1651 </xsl:variable>
1652
1653 <xsl:element name="h{$hlevel}" namespace="http://www.w3.org/1999/xhtml">
1654 <xsl:call-template name="anchor">
1655 <xsl:with-param name="conditional" select="0"/>
1656 </xsl:call-template>
1657 <xsl:apply-templates/>
1658 </xsl:element>
1659</xsl:template>
1660
1661<!-- SEO customization #2 -->
1662<xsl:template name="component.title">
1663 <xsl:param name="node" select="."/>
1664
1665 <xsl:variable name="level">
1666 <xsl:choose>
1667 <xsl:when test="ancestor::section">
1668 <xsl:value-of select="count(ancestor::section)+1"/>
1669 </xsl:when>
1670 <xsl:when test="ancestor::sect5">6</xsl:when>
1671 <xsl:when test="ancestor::sect4">5</xsl:when>
1672 <xsl:when test="ancestor::sect3">4</xsl:when>
1673 <xsl:when test="ancestor::sect2">3</xsl:when>
1674 <xsl:when test="ancestor::sect1">2</xsl:when>
1675 <xsl:otherwise>1</xsl:otherwise>
1676 </xsl:choose>
1677 </xsl:variable>
1678
1679 <xsl:element name="h{$level}" namespace="http://www.w3.org/1999/xhtml">
1680 <xsl:attribute name="class">title</xsl:attribute>
1681 <xsl:if test="$generate.id.attributes = 0">
1682 <xsl:call-template name="anchor">
1683 <xsl:with-param name="node" select="$node"/>
1684 <xsl:with-param name="conditional" select="0"/>
1685 </xsl:call-template>
1686 </xsl:if>
1687 <xsl:apply-templates select="$node" mode="object.title.markup">
1688 <xsl:with-param name="allow-anchors" select="1"/>
1689 </xsl:apply-templates>
1690 </xsl:element>
1691</xsl:template>
1692
1693</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.