docbook_xsl_wrapper 0.1.2 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/CHANGELOG +41 -0
- data/README.md +9 -17
- data/bin/docbook_xsl_wrapper +9 -14
- data/docbook_xsl_wrapper.gemspec +8 -7
- data/lib/docbook_xsl_wrapper.rb +24 -1
- data/lib/docbook_xsl_wrapper/epub.rb +124 -122
- data/lib/docbook_xsl_wrapper/options.rb +1 -1
- data/lib/docbook_xsl_wrapper/validate.rb +22 -0
- data/lib/docbook_xsl_wrapper/version.rb +1 -1
- data/schema/docbookxi.rng +18654 -0
- data/spec/docbook_xsl_wrapper/validate_spec.rb +64 -0
- data/xsl/AUTHORS +4 -0
- data/xsl/COPYING +48 -0
- data/xsl/REVISION +1 -0
- data/xsl/VERSION.xsl +115 -0
- data/xsl/common/addns.xsl +124 -0
- data/xsl/common/af.xml +1272 -0
- data/xsl/common/am.xml +1272 -0
- data/xsl/common/ar.xml +1272 -0
- data/xsl/common/as.xml +703 -0
- data/xsl/common/ast.xml +703 -0
- data/xsl/common/autoidx-kimber.xsl +45 -0
- data/xsl/common/autoidx-kosek.xsl +155 -0
- data/xsl/common/az.xml +715 -0
- data/xsl/common/bg.xml +767 -0
- data/xsl/common/bn.xml +1272 -0
- data/xsl/common/bn_in.xml +703 -0
- data/xsl/common/bs.xml +705 -0
- data/xsl/common/ca.xml +703 -0
- data/xsl/common/charmap.xsl +222 -0
- data/xsl/common/common.xsl +2129 -0
- data/xsl/common/cs.xml +743 -0
- data/xsl/common/cy.xml +1288 -0
- data/xsl/common/da.xml +707 -0
- data/xsl/common/de.xml +709 -0
- data/xsl/common/el.xml +772 -0
- data/xsl/common/en.xml +1272 -0
- data/xsl/common/entities.ent +67 -0
- data/xsl/common/eo.xml +1272 -0
- data/xsl/common/es.xml +719 -0
- data/xsl/common/et.xml +1272 -0
- data/xsl/common/eu.xml +1272 -0
- data/xsl/common/fa.xml +703 -0
- data/xsl/common/fi.xml +713 -0
- data/xsl/common/fr.xml +733 -0
- data/xsl/common/ga.xml +1272 -0
- data/xsl/common/gentext.xsl +855 -0
- data/xsl/common/gl.xml +1272 -0
- data/xsl/common/gu.xml +703 -0
- data/xsl/common/he.xml +1272 -0
- data/xsl/common/hi.xml +703 -0
- data/xsl/common/hr.xml +705 -0
- data/xsl/common/hu.xml +721 -0
- data/xsl/common/id.xml +1272 -0
- data/xsl/common/insertfile.xsl +113 -0
- data/xsl/common/is.xml +715 -0
- data/xsl/common/it.xml +1272 -0
- data/xsl/common/ja.xml +703 -0
- data/xsl/common/ka.xml +743 -0
- data/xsl/common/kn.xml +1272 -0
- data/xsl/common/ko.xml +1272 -0
- data/xsl/common/ky.xml +775 -0
- data/xsl/common/l10n.dtd +64 -0
- data/xsl/common/l10n.xml +78 -0
- data/xsl/common/l10n.xsl +598 -0
- data/xsl/common/la.xml +1272 -0
- data/xsl/common/labels.xsl +933 -0
- data/xsl/common/lt.xml +721 -0
- data/xsl/common/lv.xml +1272 -0
- data/xsl/common/ml.xml +703 -0
- data/xsl/common/mn.xml +773 -0
- data/xsl/common/mr.xml +703 -0
- data/xsl/common/nb.xml +1272 -0
- data/xsl/common/nds.xml +709 -0
- data/xsl/common/nl.xml +703 -0
- data/xsl/common/nn.xml +1272 -0
- data/xsl/common/olink.xsl +1284 -0
- data/xsl/common/or.xml +1272 -0
- data/xsl/common/pa.xml +703 -0
- data/xsl/common/pi.xml +168 -0
- data/xsl/common/pi.xsl +347 -0
- data/xsl/common/pl.xml +721 -0
- data/xsl/common/pt.xml +1272 -0
- data/xsl/common/pt_br.xml +1272 -0
- data/xsl/common/refentry.xsl +1353 -0
- data/xsl/common/ro.xml +1272 -0
- data/xsl/common/ru.xml +769 -0
- data/xsl/common/sk.xml +1272 -0
- data/xsl/common/sl.xml +1272 -0
- data/xsl/common/sq.xml +1272 -0
- data/xsl/common/sr.xml +763 -0
- data/xsl/common/sr_Latn.xml +722 -0
- data/xsl/common/subtitles.xsl +181 -0
- data/xsl/common/sv.xml +707 -0
- data/xsl/common/ta.xml +703 -0
- data/xsl/common/table.xsl +515 -0
- data/xsl/common/targetdatabase.dtd +49 -0
- data/xsl/common/targets.xsl +338 -0
- data/xsl/common/te.xml +703 -0
- data/xsl/common/th.xml +1272 -0
- data/xsl/common/titles.xsl +850 -0
- data/xsl/common/tl.xml +1272 -0
- data/xsl/common/tr.xml +709 -0
- data/xsl/common/uk.xml +769 -0
- data/xsl/common/ur.xml +705 -0
- data/xsl/common/utility.xsl +291 -0
- data/xsl/common/vi.xml +1272 -0
- data/xsl/common/xh.xml +1272 -0
- data/xsl/common/zh.xml +703 -0
- data/xsl/common/zh_cn.xml +703 -0
- data/xsl/common/zh_tw.xml +703 -0
- data/xsl/epub/docbook.xsl +1769 -0
- data/xsl/epub3/chunk.xsl +30 -0
- data/xsl/epub3/docbook-epub.css.xml +142 -0
- data/xsl/epub3/docbook.xsl +20 -0
- data/xsl/epub3/epub3-chunk-mods.xsl +52 -0
- data/xsl/epub3/epub3-element-mods.xsl +2533 -0
- data/xsl/epub3/titlepage.templates.xml +712 -0
- data/xsl/epub3/titlepage.templates.xsl +3842 -0
- data/xsl/lib/lib.xsl +533 -0
- data/xsl/xhtml/admon.xsl +142 -0
- data/xsl/xhtml/annotations.xsl +160 -0
- data/xsl/xhtml/autoidx.xsl +831 -0
- data/xsl/xhtml/autotoc.xsl +706 -0
- data/xsl/xhtml/biblio-iso690.xsl +1302 -0
- data/xsl/xhtml/biblio.xsl +1371 -0
- data/xsl/xhtml/block.xsl +584 -0
- data/xsl/xhtml/callout.xsl +210 -0
- data/xsl/xhtml/chunk-code.xsl +675 -0
- data/xsl/xhtml/chunk-common.xsl +1627 -0
- data/xsl/xhtml/chunker.xsl +317 -0
- data/xsl/xhtml/component.xsl +440 -0
- data/xsl/xhtml/division.xsl +214 -0
- data/xsl/xhtml/ebnf.xsl +331 -0
- data/xsl/xhtml/footnote.xsl +346 -0
- data/xsl/xhtml/formal.xsl +496 -0
- data/xsl/xhtml/glossary.xsl +602 -0
- data/xsl/xhtml/graphics.xsl +1537 -0
- data/xsl/xhtml/html-rtf.xsl +321 -0
- data/xsl/xhtml/html.xsl +690 -0
- data/xsl/xhtml/htmltbl.xsl +102 -0
- data/xsl/xhtml/index.xsl +264 -0
- data/xsl/xhtml/info.xsl +48 -0
- data/xsl/xhtml/inline.xsl +1508 -0
- data/xsl/xhtml/its.xsl +109 -0
- data/xsl/xhtml/keywords.xsl +38 -0
- data/xsl/xhtml/lists.xsl +1227 -0
- data/xsl/xhtml/math.xsl +286 -0
- data/xsl/xhtml/param.xsl +449 -0
- data/xsl/xhtml/pi.xsl +1237 -0
- data/xsl/xhtml/qandaset.xsl +440 -0
- data/xsl/xhtml/refentry.xsl +307 -0
- data/xsl/xhtml/sections.xsl +564 -0
- data/xsl/xhtml/synop.xsl +1623 -0
- data/xsl/xhtml/table.xsl +1179 -0
- data/xsl/xhtml/task.xsl +76 -0
- data/xsl/xhtml/titlepage.templates.xsl +4005 -0
- data/xsl/xhtml/titlepage.xsl +1108 -0
- data/xsl/xhtml/toc.xsl +334 -0
- data/xsl/xhtml/verbatim.xsl +389 -0
- data/xsl/xhtml/xref.xsl +1268 -0
- data/xsl/xhtml5/docbook.xsl +22 -0
- data/xsl/xhtml5/html5-chunk-mods.xsl +112 -0
- data/xsl/xhtml5/html5-element-mods.xsl +791 -0
- data/xsl/xhtml5/xhtml-docbook.xsl +531 -0
- metadata +207 -27
- data/.rvmrc +0 -48
- data/xslt/obfuscate.xsl +0 -12
data/xsl/epub3/chunk.xsl
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<xsl:stylesheet
|
3
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
4
|
+
xmlns:d="http://docbook.org/ns/docbook"
|
5
|
+
xmlns:exsl="http://exslt.org/common"
|
6
|
+
xmlns:epub="http://www.idpf.org/2007/ops"
|
7
|
+
exclude-result-prefixes="exsl d"
|
8
|
+
version="1.0">
|
9
|
+
|
10
|
+
<!-- $Id: chunk.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
|
11
|
+
|
12
|
+
<!-- This is the main driver stylesheet file. It imports or
|
13
|
+
includes all the components that it needs. -->
|
14
|
+
|
15
|
+
<!-- Import the module that customizes docbook elements -->
|
16
|
+
<!-- Put any customizations of element content in this module. -->
|
17
|
+
<xsl:import href="docbook.xsl"/>
|
18
|
+
|
19
|
+
<xsl:import href="../xhtml/chunk-common.xsl"/>
|
20
|
+
|
21
|
+
<xsl:include href="../xhtml/chunk-code.xsl"/>
|
22
|
+
|
23
|
+
<!-- The following module has templates that override the stock
|
24
|
+
xhtml templates for HTML5 output.
|
25
|
+
It contains match templates with priority="1" attributes,
|
26
|
+
and named templates. These override any templates that
|
27
|
+
handle chunking behavior -->
|
28
|
+
<xsl:include href="epub3-chunk-mods.xsl"/>
|
29
|
+
|
30
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,142 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<style>
|
3
|
+
|
4
|
+
/********************************/
|
5
|
+
/* start of styles in block.xsl */
|
6
|
+
|
7
|
+
.formalpara-title {
|
8
|
+
font-weight: bold;
|
9
|
+
}
|
10
|
+
|
11
|
+
div.blockquote-title {
|
12
|
+
font-weight: bold;
|
13
|
+
margin-top: 1em;
|
14
|
+
margin-bottom: 1em;
|
15
|
+
}
|
16
|
+
|
17
|
+
span.msgmain-title {
|
18
|
+
font-weight: bold;
|
19
|
+
}
|
20
|
+
|
21
|
+
span.msgsub-title {
|
22
|
+
font-weight: bold;
|
23
|
+
}
|
24
|
+
|
25
|
+
span.msgrel-title {
|
26
|
+
font-weight: bold;
|
27
|
+
}
|
28
|
+
|
29
|
+
div.msglevel, div.msgorig, div.msgaud {
|
30
|
+
margin-top: 1em;
|
31
|
+
margin-bottom: 1em;
|
32
|
+
}
|
33
|
+
|
34
|
+
span.msglevel-title, span.msgorig-title, span.msgaud-title {
|
35
|
+
font-weight: bold;
|
36
|
+
}
|
37
|
+
|
38
|
+
div.msgexplan {
|
39
|
+
margin-top: 1em;
|
40
|
+
margin-bottom: 1em;
|
41
|
+
}
|
42
|
+
|
43
|
+
span.msgexplan-title {
|
44
|
+
font-weight: bold;
|
45
|
+
}
|
46
|
+
|
47
|
+
div.sidebar {
|
48
|
+
border: 0.5pt solid black;
|
49
|
+
margin-top: 1em;
|
50
|
+
margin-bottom: 1em;
|
51
|
+
padding: 8px;
|
52
|
+
}
|
53
|
+
|
54
|
+
/* end of styles in block.xsl */
|
55
|
+
/********************************/
|
56
|
+
|
57
|
+
/********************************/
|
58
|
+
/* start of styles in autotoc.xsl */
|
59
|
+
|
60
|
+
/* top level entries */
|
61
|
+
nav>ol>li>a {
|
62
|
+
margin-top: 1em;
|
63
|
+
margin-bottom: 1em;
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
/* end of styles in autotoc.xsl */
|
68
|
+
/********************************/
|
69
|
+
|
70
|
+
/********************************/
|
71
|
+
/* start of styles in formal.xsl */
|
72
|
+
|
73
|
+
div.figure-title {
|
74
|
+
font-weight: bold;
|
75
|
+
}
|
76
|
+
|
77
|
+
div.example-title {
|
78
|
+
font-weight: bold;
|
79
|
+
}
|
80
|
+
|
81
|
+
div.equation-title {
|
82
|
+
font-weight: bold;
|
83
|
+
}
|
84
|
+
|
85
|
+
div.table-title {
|
86
|
+
font-weight: bold;
|
87
|
+
}
|
88
|
+
|
89
|
+
div.sidebar-title {
|
90
|
+
font-weight: bold;
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
/* end of styles in formal.xsl */
|
95
|
+
/********************************/
|
96
|
+
|
97
|
+
/********************************/
|
98
|
+
/* start of styles in verbatim.xsl */
|
99
|
+
|
100
|
+
div.programlisting {
|
101
|
+
white-space: pre-wrap;
|
102
|
+
font-family: monospace;
|
103
|
+
}
|
104
|
+
|
105
|
+
div.screen {
|
106
|
+
white-space: pre-wrap;
|
107
|
+
font-family: monospace;
|
108
|
+
}
|
109
|
+
|
110
|
+
div.synopsis {
|
111
|
+
white-space: pre-wrap;
|
112
|
+
font-family: monospace;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* end of styles in verbatim.xsl */
|
116
|
+
/********************************/
|
117
|
+
|
118
|
+
/********************************/
|
119
|
+
/* NAVIGATION */
|
120
|
+
|
121
|
+
nav ol {
|
122
|
+
list-style-type: none;
|
123
|
+
margin: 0 0 0 2em;
|
124
|
+
padding: 0 0 0 0;
|
125
|
+
}
|
126
|
+
|
127
|
+
nav ol li {
|
128
|
+
margin: 0 0 0 0;
|
129
|
+
padding: 0 0 0 0;
|
130
|
+
}
|
131
|
+
|
132
|
+
nav ol li a {
|
133
|
+
text-decoration: none;
|
134
|
+
color: black;
|
135
|
+
font-family: sans-serif;
|
136
|
+
}
|
137
|
+
|
138
|
+
#guide {
|
139
|
+
display: none;
|
140
|
+
}
|
141
|
+
|
142
|
+
</style>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE xsl:stylesheet [
|
3
|
+
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
|
4
|
+
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
|
5
|
+
]>
|
6
|
+
|
7
|
+
<xsl:stylesheet
|
8
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
9
|
+
xmlns:d="http://docbook.org/ns/docbook"
|
10
|
+
xmlns="http://www.w3.org/1999/xhtml"
|
11
|
+
exclude-result-prefixes="#default d"
|
12
|
+
version="1.0">
|
13
|
+
|
14
|
+
<!-- $Id: docbook.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
|
15
|
+
|
16
|
+
<xsl:import href="../xhtml5/docbook.xsl"/>
|
17
|
+
|
18
|
+
<xsl:include href="epub3-element-mods.xsl"/>
|
19
|
+
|
20
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<xsl:stylesheet
|
3
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
4
|
+
xmlns:d="http://docbook.org/ns/docbook"
|
5
|
+
xmlns:exsl="http://exslt.org/common"
|
6
|
+
xmlns:epub="http://www.idpf.org/2007/ops"
|
7
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
8
|
+
xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"
|
9
|
+
xmlns:db="http://docbook.org/ns/docbook"
|
10
|
+
xmlns:opf="http://www.idpf.org/2007/opf"
|
11
|
+
xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
|
12
|
+
xmlns:str="http://exslt.org/strings"
|
13
|
+
xmlns:xtext="xalan://com.nwalsh.xalan.Text"
|
14
|
+
extension-element-prefixes="stext xtext"
|
15
|
+
exclude-result-prefixes="exsl dc ncx opf stext str xtext d"
|
16
|
+
version="1.0">
|
17
|
+
|
18
|
+
<!-- $Id: epub3-chunk-mods.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
|
19
|
+
|
20
|
+
<xsl:include href="../xhtml5/html5-chunk-mods.xsl"/>
|
21
|
+
|
22
|
+
<!--==============================================================-->
|
23
|
+
<!-- DocBook XSL Parameter settings -->
|
24
|
+
<!--==============================================================-->
|
25
|
+
|
26
|
+
<!--==============================================================-->
|
27
|
+
<!-- Template customizations -->
|
28
|
+
<!--==============================================================-->
|
29
|
+
|
30
|
+
<!-- EPUB3: customize to generate package files -->
|
31
|
+
<xsl:template match="*" mode="process.root" priority="2">
|
32
|
+
<xsl:call-template name="check.for.xalan"/>
|
33
|
+
<xsl:apply-templates select="."/>
|
34
|
+
<xsl:call-template name="generate.css.files"/>
|
35
|
+
|
36
|
+
<xsl:call-template name="generate.epub.files"/>
|
37
|
+
|
38
|
+
</xsl:template>
|
39
|
+
|
40
|
+
<xsl:template name="check.for.xalan">
|
41
|
+
<xsl:if test="contains(system-property('xsl:vendor'), 'Apache Software Foundation')">
|
42
|
+
<xsl:message terminate="yes">
|
43
|
+
<xsl:text> </xsl:text>
|
44
|
+
<xsl:text>FATAL ERROR: </xsl:text>
|
45
|
+
<xsl:text>Xalan processor not supported by DocBook Epub3 stylesheets. </xsl:text>
|
46
|
+
<xsl:text>Xalan does not properly support XSL output method="text", </xsl:text>
|
47
|
+
<xsl:text>which is required for the various epub support files.</xsl:text>
|
48
|
+
</xsl:message>
|
49
|
+
</xsl:if>
|
50
|
+
</xsl:template>
|
51
|
+
|
52
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,2533 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE xsl:stylesheet [
|
3
|
+
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
|
4
|
+
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
|
5
|
+
]>
|
6
|
+
|
7
|
+
<xsl:stylesheet
|
8
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
9
|
+
xmlns:d="http://docbook.org/ns/docbook"
|
10
|
+
xmlns:exsl="http://exslt.org/common"
|
11
|
+
xmlns:set="http://exslt.org/sets"
|
12
|
+
xmlns="http://www.w3.org/1999/xhtml"
|
13
|
+
xmlns:epub="http://www.idpf.org/2007/ops"
|
14
|
+
xmlns:m="http://www.w3.org/1998/Math/MathML"
|
15
|
+
xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
|
16
|
+
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
|
17
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
18
|
+
xmlns:opf="http://www.idpf.org/2007/opf"
|
19
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
20
|
+
xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
|
21
|
+
xmlns:date="http://exslt.org/dates-and-times"
|
22
|
+
xmlns:dcterms="http://purl.org/dc/terms/"
|
23
|
+
xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"
|
24
|
+
xmlns:db="http://docbook.org/ns/docbook"
|
25
|
+
xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
|
26
|
+
xmlns:str="http://exslt.org/strings"
|
27
|
+
xmlns:xtext="xalan://com.nwalsh.xalan.Text"
|
28
|
+
|
29
|
+
extension-element-prefixes="stext xtext"
|
30
|
+
exclude-result-prefixes="#default cf date db dc dcterms epub exsl m ncx opf pls set ssml stext str svg xtext d"
|
31
|
+
version="1.0">
|
32
|
+
|
33
|
+
<!-- $Id: epub3-element-mods.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
|
34
|
+
|
35
|
+
<xsl:import href="titlepage.templates.xsl"/>
|
36
|
+
|
37
|
+
<!--
|
38
|
+
<xsl:key name="image-filerefs" match="d:graphic|d:inlinegraphic|d:imagedata" use="@fileref"/>
|
39
|
+
-->
|
40
|
+
|
41
|
+
<!--==============================================================-->
|
42
|
+
<!-- DocBook XSL Parameter settings -->
|
43
|
+
<!--==============================================================-->
|
44
|
+
<!-- separate file for toc -->
|
45
|
+
<xsl:param name="chunk.tocs.and.lots" select="1"/>
|
46
|
+
<xsl:param name="toc.section.depth" select="2"/>
|
47
|
+
<xsl:param name="generate.toc">
|
48
|
+
book toc,title,figure,table,example,equation
|
49
|
+
article toc,title,figure,table,example,equation
|
50
|
+
</xsl:param>
|
51
|
+
<xsl:param name="generate.manifest" select="0"/>
|
52
|
+
<xsl:param name="manifest.in.base.dir" select="1"/>
|
53
|
+
|
54
|
+
<!-- HTML chunk output goes to $base.dir/OEPBS -->
|
55
|
+
<xsl:variable name="chunk.base.dir">
|
56
|
+
<xsl:if test="$base.dir != '' and contains($base.dir, $epub.oebps.dir)">
|
57
|
+
<xsl:message terminate="yes">
|
58
|
+
<xsl:text>ERROR: the $base.dir param must not include the </xsl:text>
|
59
|
+
<xsl:value-of select="$epub.oebps.dir"/>
|
60
|
+
<xsl:text> directory in its path. Exiting.</xsl:text>
|
61
|
+
</xsl:message>
|
62
|
+
</xsl:if>
|
63
|
+
<xsl:choose>
|
64
|
+
<xsl:when test="string-length($base.dir) = 0"></xsl:when>
|
65
|
+
<!-- make sure to add trailing slash if omitted by user -->
|
66
|
+
<xsl:when test="substring($base.dir, string-length($base.dir), 1) = '/'">
|
67
|
+
<xsl:value-of select="$base.dir"/>
|
68
|
+
</xsl:when>
|
69
|
+
<xsl:otherwise>
|
70
|
+
<xsl:value-of select="concat($base.dir, '/')"/>
|
71
|
+
</xsl:otherwise>
|
72
|
+
</xsl:choose>
|
73
|
+
<xsl:value-of select="$epub.oebps.dir"/>
|
74
|
+
<xsl:if test="substring($epub.oebps.dir, string-length($epub.oebps.dir), 1) != '/'">
|
75
|
+
<xsl:text>/</xsl:text>
|
76
|
+
</xsl:if>
|
77
|
+
</xsl:variable>
|
78
|
+
|
79
|
+
|
80
|
+
<xsl:param name="index.links.to.section" select="0"/>
|
81
|
+
|
82
|
+
<!-- Epub does not yet support external links -->
|
83
|
+
<xsl:param name="activate.external.olinks" select="0"/>
|
84
|
+
|
85
|
+
<!-- Turning this on crashes ADE, which is unbelievably awesome -->
|
86
|
+
<xsl:param name="formal.object.break.after">0</xsl:param>
|
87
|
+
|
88
|
+
<xsl:param name="callout.graphics" select="1"/>
|
89
|
+
<xsl:param name="callout.graphics.extension">.png</xsl:param>
|
90
|
+
<xsl:param name="callout.graphics.number.limit" select="15"/>
|
91
|
+
<xsl:param name="callout.graphics.path" select="'images/callouts/'"/>
|
92
|
+
<xsl:param name="show.comments" select="0"/>
|
93
|
+
|
94
|
+
<!-- no navigation in .epub -->
|
95
|
+
<xsl:param name="suppress.navigation" select="'1'"/>
|
96
|
+
|
97
|
+
<!-- EPUB3: use ol lists in table of contents -->
|
98
|
+
<xsl:param name="toc.list.type">ol</xsl:param>
|
99
|
+
<xsl:param name="autotoc.label.in.hyperlink" select="1"/>
|
100
|
+
|
101
|
+
<xsl:param name="css.decoration" select="1"/>
|
102
|
+
<!-- generate the css file from a source file -->
|
103
|
+
<xsl:param name="make.clean.html" select="1"/>
|
104
|
+
<!-- specify the default epub3 stylesheet -->
|
105
|
+
<xsl:param name="docbook.css.source">docbook-epub.css.xml</xsl:param>
|
106
|
+
<!-- for custom CSS, use the custom.css.source param -->
|
107
|
+
<xsl:param name="custom.css.source"></xsl:param>
|
108
|
+
|
109
|
+
<!--==============================================================-->
|
110
|
+
<!-- New EPUB3 Parameters -->
|
111
|
+
<!--==============================================================-->
|
112
|
+
<xsl:param name="epub.version">3.0</xsl:param>
|
113
|
+
<!-- optional ncx for backwards compatibility -->
|
114
|
+
<xsl:param name="epub.include.ncx" select="1"/>
|
115
|
+
<xsl:param name="epub.ncx.depth">4</xsl:param> <!-- Not functional until http://code.google.com/p/epubcheck/issues/detail?id=70 is resolved -->
|
116
|
+
<!-- currently optional duplicate dcterms properties, may be required in future -->
|
117
|
+
<xsl:param name="epub.include.metadata.dcterms" select="1"/>
|
118
|
+
<!-- optional guide element for backwards compatibility -->
|
119
|
+
<xsl:param name="epub.include.guide" select="1"/>
|
120
|
+
<!-- some dc: currently required, to be replaced in future version -->
|
121
|
+
<xsl:param name="epub.include.metadata.dc.elements" select="1"/>
|
122
|
+
<!-- Some dc: elements will remain optional according to the spec -->
|
123
|
+
<xsl:param name="epub.include.optional.metadata.dc.elements" select="1"/>
|
124
|
+
<xsl:param name="epub.autolabel" select="0"/>
|
125
|
+
<xsl:param
|
126
|
+
name="epub.vocabulary.profile.content">http://www.idpf.org/epub/30/profile/content/</xsl:param>
|
127
|
+
<xsl:param
|
128
|
+
name="epub.vocabulary.profile.package">http://www.idpf.org/epub/30/profile/package/</xsl:param>
|
129
|
+
<xsl:param name="epub.output.epub.types" select="1"/>
|
130
|
+
<xsl:param name="epub.oebps.dir" select="'OEBPS'"/>
|
131
|
+
<xsl:variable name="epub.metainf.dir" select="'META-INF/'"/>
|
132
|
+
<xsl:param name="epub.ncx.filename" select="'toc.ncx'"/>
|
133
|
+
<xsl:variable name="epub.mimetype.filename" select="'mimetype'"/>
|
134
|
+
<xsl:variable name="epub.mimetype.value" select="'application/epub+zip'"/>
|
135
|
+
<xsl:param name="epub.container.filename" select="'container.xml'"/>
|
136
|
+
<xsl:param name="epub.package.filename" select="'package.opf'"/>
|
137
|
+
<xsl:param name="epub.cover.filename" select="concat('cover', $html.ext)"/>
|
138
|
+
<xsl:param name="epub.cover.linear" select="0" />
|
139
|
+
|
140
|
+
<!-- names of id attributes used in package files -->
|
141
|
+
<xsl:param name="epub.meta.identifier.id">meta-identifier</xsl:param>
|
142
|
+
<xsl:param name="epub.dc.identifier.id">pub-identifier</xsl:param>
|
143
|
+
<xsl:param name="epub.meta.title.id">meta-title</xsl:param>
|
144
|
+
<xsl:param name="epub.dc.title.id">pub-title</xsl:param>
|
145
|
+
<xsl:param name="epub.meta.language.id">meta-language</xsl:param>
|
146
|
+
<xsl:param name="epub.dc.language.id">pub-language</xsl:param>
|
147
|
+
<xsl:param name="epub.meta.creator.id">meta-creator</xsl:param>
|
148
|
+
<xsl:param name="epub.dc.creator.id">pub-creator</xsl:param>
|
149
|
+
<xsl:param name="epub.ncx.toc.id">ncxtoc</xsl:param>
|
150
|
+
<xsl:param name="epub.ncx.manifest.id">ncx</xsl:param>
|
151
|
+
<xsl:param name="epub.ncx.mediatype">application/x-dtbncx+xml</xsl:param>
|
152
|
+
<xsl:param name="epub.xhtml.mediatype">application/xhtml+xml</xsl:param>
|
153
|
+
<xsl:param name="epub.html.toc.id">htmltoc</xsl:param>
|
154
|
+
<xsl:param name="epub.cover.filename.id" select="'cover'"/>
|
155
|
+
<xsl:param name="epub.cover.image.id" select="'cover-image'"/>
|
156
|
+
|
157
|
+
<xsl:param name="epub.embedded.fonts"></xsl:param>
|
158
|
+
<xsl:param name="epub.namespace">http://www.idpf.org/2007/ops</xsl:param>
|
159
|
+
<xsl:param name="opf.namespace">http://www.idpf.org/2007/opf</xsl:param>
|
160
|
+
<xsl:param name="ncx.namespace">http://www.daisy.org/z3986/2005/ncx/</xsl:param>
|
161
|
+
<xsl:param name="dc.namespace">http://purl.org/dc/elements/1.1/</xsl:param>
|
162
|
+
<!-- prefix generated ids in package elements so they differ from content ids -->
|
163
|
+
<xsl:param name="epub.package.id.prefix">id-</xsl:param>
|
164
|
+
<!-- editor is either a creator or contributor -->
|
165
|
+
<xsl:param name="editor.property">contributor</xsl:param>
|
166
|
+
|
167
|
+
<!-- Generate full output path -->
|
168
|
+
<xsl:param name="epub.package.dir" select="concat($chunk.base.dir, '../')"/>
|
169
|
+
|
170
|
+
<xsl:param name="epub.ncx.pathname"
|
171
|
+
select="concat($chunk.base.dir, $epub.ncx.filename)"/>
|
172
|
+
<xsl:param name="epub.container.pathname"
|
173
|
+
select="concat($epub.package.dir, $epub.metainf.dir,
|
174
|
+
$epub.container.filename)"/>
|
175
|
+
<xsl:param name="epub.package.pathname"
|
176
|
+
select="concat($chunk.base.dir, $epub.package.filename)"/>
|
177
|
+
<xsl:param name="epub.cover.pathname"
|
178
|
+
select="concat($chunk.base.dir, $epub.cover.filename)"/>
|
179
|
+
<xsl:param name="epub.mimetype.pathname"
|
180
|
+
select="concat($epub.package.dir, $epub.mimetype.filename)"/>
|
181
|
+
|
182
|
+
<xsl:param name="kindle.extensions" select="0"/>
|
183
|
+
|
184
|
+
<!--==============================================================-->
|
185
|
+
<!-- Internal variables used for computing certain metadata -->
|
186
|
+
<!--==============================================================-->
|
187
|
+
<xsl:variable name="epub3.chunk.hierarchy">
|
188
|
+
<xsl:apply-templates select="/*" mode="find.chunks"/>
|
189
|
+
</xsl:variable>
|
190
|
+
|
191
|
+
<xsl:variable name="chunkset" select="exsl:node-set($epub3.chunk.hierarchy)//cf:div"/>
|
192
|
+
|
193
|
+
<!--==============================================================-->
|
194
|
+
<!-- Template customizations -->
|
195
|
+
<!--==============================================================-->
|
196
|
+
|
197
|
+
<!-- This is used only by ncx piece -->
|
198
|
+
<xsl:variable name="root.is.a.chunk">
|
199
|
+
<xsl:choose>
|
200
|
+
<xsl:when test="/*[not(self::d:book)][not(d:sect1) or not(d:section)]">
|
201
|
+
<xsl:text>1</xsl:text>
|
202
|
+
</xsl:when>
|
203
|
+
<xsl:when test="/d:book[*[last()][self::d:bookinfo]]|d:book[d:bookinfo]">
|
204
|
+
<xsl:text>1</xsl:text>
|
205
|
+
</xsl:when>
|
206
|
+
<xsl:when test="/d:book[*[last()][self::d:info]]|d:book[d:info]">
|
207
|
+
<xsl:text>1</xsl:text>
|
208
|
+
</xsl:when>
|
209
|
+
<xsl:when test="/d:bibliography">
|
210
|
+
<xsl:text>1</xsl:text>
|
211
|
+
</xsl:when>
|
212
|
+
<xsl:otherwise>
|
213
|
+
<xsl:text>0</xsl:text>
|
214
|
+
</xsl:otherwise>
|
215
|
+
</xsl:choose>
|
216
|
+
</xsl:variable>
|
217
|
+
|
218
|
+
<!-- EPUB3: Add generation of epub publication files -->
|
219
|
+
<xsl:template match="*" mode="process.root">
|
220
|
+
<xsl:variable name="doc" select="self::*"/>
|
221
|
+
|
222
|
+
<xsl:call-template name="user.preroot"/>
|
223
|
+
<xsl:call-template name="root.messages"/>
|
224
|
+
|
225
|
+
<html>
|
226
|
+
<head>
|
227
|
+
<xsl:call-template name="system.head.content">
|
228
|
+
<xsl:with-param name="node" select="$doc"/>
|
229
|
+
</xsl:call-template>
|
230
|
+
<xsl:call-template name="head.content">
|
231
|
+
<xsl:with-param name="node" select="$doc"/>
|
232
|
+
</xsl:call-template>
|
233
|
+
<xsl:call-template name="user.head.content">
|
234
|
+
<xsl:with-param name="node" select="$doc"/>
|
235
|
+
</xsl:call-template>
|
236
|
+
</head>
|
237
|
+
<body>
|
238
|
+
<xsl:call-template name="body.attributes"/>
|
239
|
+
<xsl:call-template name="user.header.content">
|
240
|
+
<xsl:with-param name="node" select="$doc"/>
|
241
|
+
</xsl:call-template>
|
242
|
+
<xsl:apply-templates select="."/>
|
243
|
+
<xsl:call-template name="user.footer.content">
|
244
|
+
<xsl:with-param name="node" select="$doc"/>
|
245
|
+
</xsl:call-template>
|
246
|
+
</body>
|
247
|
+
</html>
|
248
|
+
<xsl:value-of select="$html.append"/>
|
249
|
+
|
250
|
+
<!-- Generate any css files only once, not once per chunk -->
|
251
|
+
<xsl:call-template name="generate.css.files"/>
|
252
|
+
|
253
|
+
<xsl:call-template name="generate.epub.files"/>
|
254
|
+
|
255
|
+
</xsl:template>
|
256
|
+
|
257
|
+
<xsl:template name="generate.epub.files">
|
258
|
+
<!-- Generate epub3 files -->
|
259
|
+
<xsl:message>
|
260
|
+
<xsl:text>Generating EPUB package files.</xsl:text>
|
261
|
+
</xsl:message>
|
262
|
+
|
263
|
+
<xsl:apply-templates select="." mode="opf"/>
|
264
|
+
<xsl:apply-templates select="." mode="container"/>
|
265
|
+
<xsl:call-template name="mimetype"/>
|
266
|
+
<xsl:if test="$epub.include.ncx != 0">
|
267
|
+
<xsl:call-template name="ncx"/>
|
268
|
+
</xsl:if>
|
269
|
+
</xsl:template>
|
270
|
+
|
271
|
+
<!-- Generate the package file -->
|
272
|
+
<xsl:template match="*" mode="opf">
|
273
|
+
|
274
|
+
<xsl:variable name="lang">
|
275
|
+
<xsl:call-template name="l10n.language"/>
|
276
|
+
</xsl:variable>
|
277
|
+
|
278
|
+
<xsl:variable name="content">
|
279
|
+
<!-- use xsl:element so output does not have a namespace prefix -->
|
280
|
+
<xsl:element name="package" namespace="{$opf.namespace}">
|
281
|
+
<!-- Add the package namespaces at the top -->
|
282
|
+
<xsl:call-template name="add.package.namespaces"/>
|
283
|
+
|
284
|
+
<xsl:attribute name="version">
|
285
|
+
<xsl:value-of select="$epub.version"/>
|
286
|
+
</xsl:attribute>
|
287
|
+
<xsl:attribute name="xml:lang">
|
288
|
+
<xsl:value-of select="$lang"/>
|
289
|
+
</xsl:attribute>
|
290
|
+
<!-- No profile att in 2011-09-06 spec
|
291
|
+
<xsl:attribute name="profile">
|
292
|
+
<xsl:value-of select="$epub.vocabulary.profile.package"/>
|
293
|
+
</xsl:attribute>
|
294
|
+
-->
|
295
|
+
<xsl:attribute name="unique-identifier">
|
296
|
+
<xsl:value-of select="$epub.dc.identifier.id"/>
|
297
|
+
</xsl:attribute>
|
298
|
+
|
299
|
+
|
300
|
+
<xsl:call-template name="package.metadata"/>
|
301
|
+
<xsl:call-template name="package.manifest"/>
|
302
|
+
<xsl:call-template name="package.spine"/>
|
303
|
+
|
304
|
+
<xsl:if test="$epub.include.guide != 0">
|
305
|
+
<xsl:call-template name="package.guide"/>
|
306
|
+
</xsl:if>
|
307
|
+
|
308
|
+
</xsl:element>
|
309
|
+
</xsl:variable>
|
310
|
+
|
311
|
+
<xsl:call-template name="write.chunk">
|
312
|
+
<xsl:with-param name="filename">
|
313
|
+
<xsl:value-of select="$epub.package.pathname" />
|
314
|
+
</xsl:with-param>
|
315
|
+
<xsl:with-param name="content" select="$content"/>
|
316
|
+
<xsl:with-param name="method" select="'xml'" />
|
317
|
+
<xsl:with-param name="encoding" select="'utf-8'" />
|
318
|
+
<xsl:with-param name="indent" select="'yes'" />
|
319
|
+
<xsl:with-param name="quiet" select="$chunk.quietly" />
|
320
|
+
<xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
|
321
|
+
<xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
|
322
|
+
</xsl:call-template>
|
323
|
+
</xsl:template>
|
324
|
+
|
325
|
+
<xsl:template name="package.metadata">
|
326
|
+
|
327
|
+
<xsl:element name="metadata" namespace="{$opf.namespace}">
|
328
|
+
|
329
|
+
<xsl:call-template name="metadata.identifier"/>
|
330
|
+
<xsl:call-template name="metadata.title"/>
|
331
|
+
<xsl:call-template name="metadata.language"/>
|
332
|
+
<xsl:call-template name="metadata.modified"/>
|
333
|
+
<xsl:call-template name="metadata.cover"/>
|
334
|
+
<xsl:call-template name="metadata.other.info"/>
|
335
|
+
|
336
|
+
</xsl:element>
|
337
|
+
</xsl:template>
|
338
|
+
|
339
|
+
<xsl:template name="doc.title">
|
340
|
+
<xsl:apply-templates select="." mode="title.markup"/>
|
341
|
+
</xsl:template>
|
342
|
+
|
343
|
+
<xsl:template name="metadata.identifier">
|
344
|
+
<xsl:variable name="package.id.value">
|
345
|
+
<xsl:call-template name="package-identifier"/>
|
346
|
+
</xsl:variable>
|
347
|
+
|
348
|
+
<xsl:if test="$epub.include.metadata.dc.elements != 0">
|
349
|
+
<!-- dc:identifier element -->
|
350
|
+
<dc:identifier>
|
351
|
+
<xsl:attribute name="id">
|
352
|
+
<xsl:value-of select="$epub.dc.identifier.id"/>
|
353
|
+
</xsl:attribute>
|
354
|
+
<!--
|
355
|
+
<xsl:attribute name="prefer">
|
356
|
+
<xsl:value-of select="$epub.meta.identifier.id"/>
|
357
|
+
</xsl:attribute>
|
358
|
+
-->
|
359
|
+
<xsl:copy-of select="$package.id.value"/>
|
360
|
+
</dc:identifier>
|
361
|
+
</xsl:if>
|
362
|
+
|
363
|
+
<xsl:if test="$epub.include.metadata.dcterms != 0">
|
364
|
+
<!-- equivalent meta identifier element -->
|
365
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
366
|
+
<xsl:attribute name="id">
|
367
|
+
<xsl:value-of select="$epub.meta.identifier.id"/>
|
368
|
+
</xsl:attribute>
|
369
|
+
<xsl:attribute name="property">dcterms:identifier</xsl:attribute>
|
370
|
+
<xsl:copy-of select="$package.id.value"/>
|
371
|
+
</xsl:element>
|
372
|
+
</xsl:if>
|
373
|
+
</xsl:template>
|
374
|
+
|
375
|
+
<xsl:template name="metadata.title">
|
376
|
+
<xsl:variable name="doc.title">
|
377
|
+
<xsl:call-template name="doc.title"/>
|
378
|
+
</xsl:variable>
|
379
|
+
|
380
|
+
<xsl:if test="$epub.include.metadata.dc.elements != 0">
|
381
|
+
<dc:title>
|
382
|
+
<xsl:attribute name="id">
|
383
|
+
<xsl:value-of select="$epub.dc.title.id"/>
|
384
|
+
</xsl:attribute>
|
385
|
+
<!--
|
386
|
+
<xsl:attribute name="prefer">
|
387
|
+
<xsl:value-of select="$epub.meta.title.id"/>
|
388
|
+
</xsl:attribute>
|
389
|
+
-->
|
390
|
+
<xsl:value-of select="normalize-space($doc.title)"/>
|
391
|
+
</dc:title>
|
392
|
+
</xsl:if>
|
393
|
+
|
394
|
+
<xsl:if test="$epub.include.metadata.dcterms != 0">
|
395
|
+
<!-- equivalent meta title element -->
|
396
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
397
|
+
<xsl:attribute name="property">dcterms:title</xsl:attribute>
|
398
|
+
<xsl:attribute name="id">
|
399
|
+
<xsl:value-of select="$epub.meta.title.id"/>
|
400
|
+
</xsl:attribute>
|
401
|
+
<xsl:value-of select="normalize-space($doc.title)"/>
|
402
|
+
</xsl:element>
|
403
|
+
</xsl:if>
|
404
|
+
</xsl:template>
|
405
|
+
|
406
|
+
<xsl:template name="metadata.language">
|
407
|
+
<xsl:variable name="lang">
|
408
|
+
<xsl:call-template name="l10n.language"/>
|
409
|
+
</xsl:variable>
|
410
|
+
|
411
|
+
<xsl:if test="$epub.include.metadata.dc.elements != 0">
|
412
|
+
<dc:language>
|
413
|
+
<xsl:if test="$kindle.extensions = 0">
|
414
|
+
<xsl:attribute name="id">
|
415
|
+
<xsl:value-of select="$epub.dc.language.id"/>
|
416
|
+
</xsl:attribute>
|
417
|
+
</xsl:if>
|
418
|
+
<xsl:value-of select="$lang"/>
|
419
|
+
</dc:language>
|
420
|
+
</xsl:if>
|
421
|
+
|
422
|
+
<xsl:if test="$epub.include.metadata.dcterms != 0">
|
423
|
+
<!-- equivalent meta lang element -->
|
424
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
425
|
+
<xsl:attribute name="property">dcterms:language</xsl:attribute>
|
426
|
+
<xsl:attribute name="id">
|
427
|
+
<xsl:value-of select="$epub.meta.language.id"/>
|
428
|
+
</xsl:attribute>
|
429
|
+
<xsl:value-of select="$lang"/>
|
430
|
+
</xsl:element>
|
431
|
+
</xsl:if>
|
432
|
+
</xsl:template>
|
433
|
+
|
434
|
+
<xsl:template name="metadata.modified">
|
435
|
+
<xsl:variable name="local.datetime" select="date:date-time()"/>
|
436
|
+
<xsl:variable name="utc.datetime">
|
437
|
+
<xsl:call-template name="convert.date.to.utc">
|
438
|
+
<xsl:with-param name="date" select="$local.datetime"/>
|
439
|
+
</xsl:call-template>
|
440
|
+
</xsl:variable>
|
441
|
+
<xsl:choose>
|
442
|
+
<xsl:when test="string-length($utc.datetime) != 0">
|
443
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
444
|
+
<xsl:attribute name="property">dcterms:modified</xsl:attribute>
|
445
|
+
<xsl:value-of select="$utc.datetime"/>
|
446
|
+
</xsl:element>
|
447
|
+
<xsl:comment>The preceding date value is actually local time (not UTC) in UTC format because there is no function in XSLT 1.0 to generate a correct UTC time</xsl:comment>
|
448
|
+
</xsl:when>
|
449
|
+
<xsl:otherwise>
|
450
|
+
<xsl:message terminate="yes">
|
451
|
+
<xsl:text>ERROR: no last-modified date value could be determined, </xsl:text>
|
452
|
+
<xsl:text>so cannot output required meta element with </xsl:text>
|
453
|
+
<xsl:text>dcterms:modified attribute. Exiting.</xsl:text>
|
454
|
+
</xsl:message>
|
455
|
+
</xsl:otherwise>
|
456
|
+
</xsl:choose>
|
457
|
+
</xsl:template>
|
458
|
+
|
459
|
+
<xsl:template name="convert.date.to.utc">
|
460
|
+
<xsl:param name="date" select="''"/>
|
461
|
+
<!-- input format is YYYY-MM-DDTHH:MM:SS-X:00
|
462
|
+
where -X:00 is the offset from UTC. -->
|
463
|
+
|
464
|
+
<!-- output format is YYYY-MM-DDTHH:MM:SSZ with no offset -->
|
465
|
+
<!-- FIX ME: Not so easy without a proper UTC date function. -->
|
466
|
+
<!-- Currently it just converts the local time to this format, which is
|
467
|
+
not the correct UTC time. -->
|
468
|
+
<xsl:value-of select="concat(substring($date,1,19), 'Z')"/>
|
469
|
+
</xsl:template>
|
470
|
+
|
471
|
+
<!-- This cover meta element used by kindlegen, at least -->
|
472
|
+
<xsl:template name="metadata.cover">
|
473
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
474
|
+
<xsl:variable name="cover.image"
|
475
|
+
select="$info//d:mediaobject[@role='cover' or ancestor::d:cover]"/>
|
476
|
+
|
477
|
+
<xsl:if test="$cover.image">
|
478
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
479
|
+
<xsl:attribute name="content">
|
480
|
+
<xsl:value-of select="$epub.cover.image.id"/>
|
481
|
+
</xsl:attribute>
|
482
|
+
<xsl:attribute name="name">cover</xsl:attribute>
|
483
|
+
</xsl:element>
|
484
|
+
</xsl:if>
|
485
|
+
</xsl:template>
|
486
|
+
|
487
|
+
<xsl:template name="metadata.other.info">
|
488
|
+
<!-- Take info relative to selected root element -->
|
489
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
490
|
+
|
491
|
+
<xsl:apply-templates select="$info/*" mode="opf.metadata"/>
|
492
|
+
</xsl:template>
|
493
|
+
|
494
|
+
<xsl:template match="*" mode="opf.metadata">
|
495
|
+
<!-- default is no output -->
|
496
|
+
</xsl:template>
|
497
|
+
|
498
|
+
<xsl:template match="d:authorgroup" mode="opf.metadata">
|
499
|
+
<xsl:apply-templates select="*" mode="opf.metadata"/>
|
500
|
+
</xsl:template>
|
501
|
+
|
502
|
+
<xsl:template match="d:author|d:corpauthor" mode="opf.metadata">
|
503
|
+
<xsl:variable name="n">
|
504
|
+
<xsl:choose>
|
505
|
+
<xsl:when test="self::d:corpauthor">
|
506
|
+
<xsl:apply-templates/>
|
507
|
+
</xsl:when>
|
508
|
+
<xsl:when test="d:org/d:orgname">
|
509
|
+
<xsl:apply-templates select="d:org/d:orgname"/>
|
510
|
+
</xsl:when>
|
511
|
+
<xsl:when test="d:orgname">
|
512
|
+
<xsl:apply-templates select="d:orgname"/>
|
513
|
+
</xsl:when>
|
514
|
+
<xsl:otherwise>
|
515
|
+
<xsl:call-template name="person.name">
|
516
|
+
<xsl:with-param name="node" select="."/>
|
517
|
+
</xsl:call-template>
|
518
|
+
</xsl:otherwise>
|
519
|
+
</xsl:choose>
|
520
|
+
</xsl:variable>
|
521
|
+
|
522
|
+
<xsl:if test="string-length($n) != 0">
|
523
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
524
|
+
<xsl:attribute name="id">
|
525
|
+
<xsl:value-of select="concat($epub.meta.creator.id, position())"/>
|
526
|
+
</xsl:attribute>
|
527
|
+
<xsl:attribute name="property">dcterms:creator</xsl:attribute>
|
528
|
+
<xsl:value-of select="normalize-space(string($n))"/>
|
529
|
+
</xsl:element>
|
530
|
+
|
531
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
532
|
+
<dc:creator>
|
533
|
+
<xsl:attribute name="id">
|
534
|
+
<xsl:value-of select="concat($epub.dc.creator.id, position())"/>
|
535
|
+
</xsl:attribute>
|
536
|
+
<xsl:value-of select="$n"/>
|
537
|
+
</dc:creator>
|
538
|
+
</xsl:if>
|
539
|
+
</xsl:if>
|
540
|
+
</xsl:template>
|
541
|
+
|
542
|
+
<xsl:template match="d:editor" mode="opf.metadata">
|
543
|
+
<xsl:variable name="n">
|
544
|
+
<xsl:choose>
|
545
|
+
<xsl:when test="d:orgname">
|
546
|
+
<xsl:apply-templates select="d:orgname"/>
|
547
|
+
</xsl:when>
|
548
|
+
<xsl:otherwise>
|
549
|
+
<xsl:call-template name="person.name">
|
550
|
+
<xsl:with-param name="node" select="."/>
|
551
|
+
</xsl:call-template>
|
552
|
+
</xsl:otherwise>
|
553
|
+
</xsl:choose>
|
554
|
+
</xsl:variable>
|
555
|
+
|
556
|
+
<xsl:variable name="name">
|
557
|
+
<xsl:choose>
|
558
|
+
<xsl:when test="string-length($editor.property) != 0">
|
559
|
+
<xsl:value-of select="$editor.property"/>
|
560
|
+
</xsl:when>
|
561
|
+
<xsl:otherwise>
|
562
|
+
<xsl:text>contributor</xsl:text>
|
563
|
+
</xsl:otherwise>
|
564
|
+
</xsl:choose>
|
565
|
+
</xsl:variable>
|
566
|
+
|
567
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
568
|
+
<xsl:attribute name="property">
|
569
|
+
<xsl:text>dcterms:</xsl:text>
|
570
|
+
<xsl:value-of select="$name"/>
|
571
|
+
</xsl:attribute>
|
572
|
+
<xsl:value-of select="normalize-space($n)"/>
|
573
|
+
</xsl:element>
|
574
|
+
|
575
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
576
|
+
<xsl:choose>
|
577
|
+
<xsl:when test="$name = 'creator'">
|
578
|
+
<dc:creator>
|
579
|
+
<xsl:value-of select="normalize-space($n)"/>
|
580
|
+
</dc:creator>
|
581
|
+
</xsl:when>
|
582
|
+
<xsl:when test="$name = 'contributor'">
|
583
|
+
<dc:contributor>
|
584
|
+
<xsl:value-of select="normalize-space($n)"/>
|
585
|
+
</dc:contributor>
|
586
|
+
</xsl:when>
|
587
|
+
<xsl:otherwise>
|
588
|
+
<xsl:element namespace="{$dc.namespace}" name="{$name}">
|
589
|
+
<xsl:value-of select="normalize-space($n)"/>
|
590
|
+
</xsl:element>
|
591
|
+
</xsl:otherwise>
|
592
|
+
</xsl:choose>
|
593
|
+
</xsl:if>
|
594
|
+
|
595
|
+
</xsl:template>
|
596
|
+
|
597
|
+
<xsl:template match="d:corpcredit" mode="opf.metadata">
|
598
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
599
|
+
<xsl:attribute name="property">dcterms:contributor</xsl:attribute>
|
600
|
+
<xsl:value-of select="normalize-space(.)"/>
|
601
|
+
</xsl:element>
|
602
|
+
|
603
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
604
|
+
<dc:contributor>
|
605
|
+
<xsl:value-of select="normalize-space(.)"/>
|
606
|
+
</dc:contributor>
|
607
|
+
</xsl:if>
|
608
|
+
</xsl:template>
|
609
|
+
|
610
|
+
<xsl:template match="d:collab|d:othercredit" mode="opf.metadata">
|
611
|
+
<xsl:variable name="content">
|
612
|
+
<xsl:choose>
|
613
|
+
<xsl:when test="d:collabname">
|
614
|
+
<xsl:apply-templates select="d:collabname"/>
|
615
|
+
</xsl:when>
|
616
|
+
<xsl:when test="d:org/d:orgname">
|
617
|
+
<xsl:apply-templates select="d:org/d:orgname"/>
|
618
|
+
</xsl:when>
|
619
|
+
<xsl:when test="d:orgname">
|
620
|
+
<xsl:apply-templates select="d:orgname"/>
|
621
|
+
</xsl:when>
|
622
|
+
<xsl:when test="d:personname|d:firstname|d:surname|d:othername">
|
623
|
+
<xsl:call-template name="person.name"/>
|
624
|
+
</xsl:when>
|
625
|
+
<xsl:otherwise>
|
626
|
+
<xsl:value-of select="."/>
|
627
|
+
</xsl:otherwise>
|
628
|
+
</xsl:choose>
|
629
|
+
</xsl:variable>
|
630
|
+
|
631
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
632
|
+
<xsl:attribute name="property">dcterms:contributor</xsl:attribute>
|
633
|
+
<xsl:value-of select="normalize-space($content)"/>
|
634
|
+
</xsl:element>
|
635
|
+
|
636
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
637
|
+
<dc:contributor>
|
638
|
+
<xsl:value-of select="normalize-space($content)"/>
|
639
|
+
</dc:contributor>
|
640
|
+
</xsl:if>
|
641
|
+
|
642
|
+
</xsl:template>
|
643
|
+
|
644
|
+
<xsl:template match="d:date|d:pubdate" mode="opf.metadata">
|
645
|
+
<xsl:variable name="date">
|
646
|
+
<xsl:call-template name="format.meta.date">
|
647
|
+
<xsl:with-param name="string" select="normalize-space(.)"/>
|
648
|
+
</xsl:call-template>
|
649
|
+
</xsl:variable>
|
650
|
+
|
651
|
+
<xsl:if test="string-length($date) != 0">
|
652
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
653
|
+
<xsl:attribute name="property">dcterms:date</xsl:attribute>
|
654
|
+
<xsl:value-of select="$date"/>
|
655
|
+
</xsl:element>
|
656
|
+
|
657
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
658
|
+
<dc:date>
|
659
|
+
<xsl:value-of select="$date"/>
|
660
|
+
</dc:date>
|
661
|
+
</xsl:if>
|
662
|
+
</xsl:if>
|
663
|
+
|
664
|
+
</xsl:template>
|
665
|
+
|
666
|
+
<!-- EPUB3 meta date should be of the form:
|
667
|
+
YYYY, YYYY-MM or YYYY-MM-DD -->
|
668
|
+
<xsl:template name="format.meta.date">
|
669
|
+
<xsl:param name="string" select="''"/>
|
670
|
+
<xsl:param name="node" select="."/>
|
671
|
+
|
672
|
+
<!-- FIXME: this needs further work, so just check the
|
673
|
+
string format and return the date string for now -->
|
674
|
+
<xsl:variable name="normalized"
|
675
|
+
select="translate($string, '0123456789', '##########')"/>
|
676
|
+
|
677
|
+
<xsl:variable name="date.ok">
|
678
|
+
<xsl:choose>
|
679
|
+
<xsl:when test="string-length($string) = 4 and
|
680
|
+
$normalized = '####'">1</xsl:when>
|
681
|
+
<xsl:when test="string-length($string) = 7 and
|
682
|
+
$normalized = '####-##'">1</xsl:when>
|
683
|
+
<xsl:when test="string-length($string) = 10 and
|
684
|
+
$normalized = '####-##-##'">1</xsl:when>
|
685
|
+
<xsl:when test="string-length($string) = 10 and
|
686
|
+
$normalized = '####-##-##'">1</xsl:when>
|
687
|
+
<xsl:otherwise>0</xsl:otherwise>
|
688
|
+
</xsl:choose>
|
689
|
+
</xsl:variable>
|
690
|
+
|
691
|
+
<xsl:if test="$date.ok = 0">
|
692
|
+
<xsl:message>
|
693
|
+
<xsl:text>WARNING: wrong metadata date format: '</xsl:text>
|
694
|
+
<xsl:value-of select="$string"/>
|
695
|
+
<xsl:text>' in element </xsl:text>
|
696
|
+
<xsl:value-of select="local-name($node/..)"/>
|
697
|
+
<xsl:text>/</xsl:text>
|
698
|
+
<xsl:value-of select="local-name($node)"/>
|
699
|
+
<xsl:text>. It must be in one of these forms: </xsl:text>
|
700
|
+
<xsl:text>YYYY, YYYY-MM, or YYYY-MM-DD.</xsl:text>
|
701
|
+
</xsl:message>
|
702
|
+
</xsl:if>
|
703
|
+
|
704
|
+
<!-- return the string anyway -->
|
705
|
+
<xsl:value-of select="$string"/>
|
706
|
+
|
707
|
+
</xsl:template>
|
708
|
+
|
709
|
+
|
710
|
+
<!-- Space separate the compontents of the abstract (dropping the inline markup, sadly) -->
|
711
|
+
<xsl:template match="d:abstract" mode="opf.metadata">
|
712
|
+
<xsl:variable name="content">
|
713
|
+
<xsl:for-each select="d:formalpara|d:para|d:simpara|d:title">
|
714
|
+
<xsl:choose>
|
715
|
+
<xsl:when test="self::d:formalpara">
|
716
|
+
<xsl:value-of select="normalize-space(string(d:title))"/>
|
717
|
+
<xsl:text>: </xsl:text>
|
718
|
+
<xsl:value-of select="normalize-space(string(d:para))"/>
|
719
|
+
</xsl:when>
|
720
|
+
<xsl:otherwise>
|
721
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
722
|
+
</xsl:otherwise>
|
723
|
+
</xsl:choose>
|
724
|
+
<xsl:if test="self::d:title">
|
725
|
+
<xsl:text>:</xsl:text>
|
726
|
+
</xsl:if>
|
727
|
+
<xsl:if test="not(position() = last())">
|
728
|
+
<xsl:text> </xsl:text>
|
729
|
+
</xsl:if>
|
730
|
+
</xsl:for-each>
|
731
|
+
</xsl:variable>
|
732
|
+
|
733
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
734
|
+
<xsl:attribute name="property">dcterms:description</xsl:attribute>
|
735
|
+
<xsl:copy-of select="$content"/>
|
736
|
+
</xsl:element>
|
737
|
+
|
738
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
739
|
+
<dc:description>
|
740
|
+
<xsl:copy-of select="$content"/>
|
741
|
+
</dc:description>
|
742
|
+
</xsl:if>
|
743
|
+
</xsl:template>
|
744
|
+
|
745
|
+
<xsl:template match="d:subjectset" mode="opf.metadata">
|
746
|
+
<xsl:apply-templates select="d:subject/d:subjectterm" mode="opf.metadata"/>
|
747
|
+
</xsl:template>
|
748
|
+
|
749
|
+
<xsl:template match="d:subjectterm" mode="opf.metadata">
|
750
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
751
|
+
<xsl:attribute name="property">dcterms:subject</xsl:attribute>
|
752
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
753
|
+
</xsl:element>
|
754
|
+
|
755
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
756
|
+
<dc:subject>
|
757
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
758
|
+
</dc:subject>
|
759
|
+
</xsl:if>
|
760
|
+
</xsl:template>
|
761
|
+
|
762
|
+
<xsl:template match="d:keywordset" mode="opf.metadata">
|
763
|
+
<xsl:apply-templates select="d:keyword" mode="opf.metadata"/>
|
764
|
+
</xsl:template>
|
765
|
+
|
766
|
+
<xsl:template match="d:keyword" mode="opf.metadata">
|
767
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
768
|
+
<xsl:attribute name="property">dcterms:subject</xsl:attribute>
|
769
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
770
|
+
</xsl:element>
|
771
|
+
|
772
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
773
|
+
<dc:subject>
|
774
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
775
|
+
</dc:subject>
|
776
|
+
</xsl:if>
|
777
|
+
</xsl:template>
|
778
|
+
|
779
|
+
<xsl:template match="d:publisher" mode="opf.metadata">
|
780
|
+
<xsl:apply-templates select="d:publishername" mode="opf.metadata"/>
|
781
|
+
</xsl:template>
|
782
|
+
|
783
|
+
<xsl:template match="d:publishername" mode="opf.metadata">
|
784
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
785
|
+
<xsl:attribute name="property">dcterms:publisher</xsl:attribute>
|
786
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
787
|
+
</xsl:element>
|
788
|
+
|
789
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
790
|
+
<dc:publisher>
|
791
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
792
|
+
</dc:publisher>
|
793
|
+
</xsl:if>
|
794
|
+
</xsl:template>
|
795
|
+
|
796
|
+
<xsl:template match="d:bibliocoverage" mode="opf.metadata">
|
797
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
798
|
+
<xsl:attribute name="property">dcterms:coverage</xsl:attribute>
|
799
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
800
|
+
</xsl:element>
|
801
|
+
|
802
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
803
|
+
<dc:coverage>
|
804
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
805
|
+
</dc:coverage>
|
806
|
+
</xsl:if>
|
807
|
+
</xsl:template>
|
808
|
+
|
809
|
+
<xsl:template match="d:bibliorelation" mode="opf.metadata">
|
810
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
811
|
+
<xsl:attribute name="property">dcterms:relation</xsl:attribute>
|
812
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
813
|
+
</xsl:element>
|
814
|
+
|
815
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
816
|
+
<dc:relation>
|
817
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
818
|
+
</dc:relation>
|
819
|
+
</xsl:if>
|
820
|
+
</xsl:template>
|
821
|
+
|
822
|
+
<xsl:template match="d:bibliosource" mode="opf.metadata">
|
823
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
824
|
+
<xsl:attribute name="property">dcterms:source</xsl:attribute>
|
825
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
826
|
+
</xsl:element>
|
827
|
+
|
828
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
829
|
+
<dc:source>
|
830
|
+
<xsl:value-of select="normalize-space(string(.))"/>
|
831
|
+
</dc:source>
|
832
|
+
</xsl:if>
|
833
|
+
</xsl:template>
|
834
|
+
|
835
|
+
<xsl:template match="d:copyright" mode="opf.metadata">
|
836
|
+
<xsl:variable name="copyright.date">
|
837
|
+
<xsl:call-template name="copyright.years">
|
838
|
+
<xsl:with-param name="years" select="d:year"/>
|
839
|
+
<xsl:with-param name="print.ranges" select="$make.year.ranges"/>
|
840
|
+
<xsl:with-param name="single.year.ranges" select="$make.single.year.ranges"/>
|
841
|
+
</xsl:call-template>
|
842
|
+
</xsl:variable>
|
843
|
+
|
844
|
+
<!-- if no docbook date element, use copyright year for single date metadata -->
|
845
|
+
<xsl:if test="not(../d:date)">
|
846
|
+
<xsl:variable name="date.content">
|
847
|
+
<xsl:call-template name="format.meta.date">
|
848
|
+
<xsl:with-param name="string">
|
849
|
+
<xsl:call-template name="copyright.years">
|
850
|
+
<xsl:with-param name="years" select="d:year[last()]"/>
|
851
|
+
<xsl:with-param name="print.ranges" select="0"/>
|
852
|
+
<xsl:with-param name="single.year.ranges" select="0"/>
|
853
|
+
</xsl:call-template>
|
854
|
+
</xsl:with-param>
|
855
|
+
</xsl:call-template>
|
856
|
+
</xsl:variable>
|
857
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
858
|
+
<xsl:attribute name="property">dcterms:date</xsl:attribute>
|
859
|
+
<xsl:copy-of select="$date.content"/>
|
860
|
+
</xsl:element>
|
861
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
862
|
+
<dc:date>
|
863
|
+
<xsl:copy-of select="$date.content"/>
|
864
|
+
</dc:date>
|
865
|
+
</xsl:if>
|
866
|
+
</xsl:if>
|
867
|
+
|
868
|
+
<xsl:variable name="rights.content">
|
869
|
+
<xsl:call-template name="gentext">
|
870
|
+
<xsl:with-param name="key" select="'Copyright'"/>
|
871
|
+
</xsl:call-template>
|
872
|
+
<xsl:call-template name="gentext.space"/>
|
873
|
+
<xsl:text>©</xsl:text>
|
874
|
+
<xsl:call-template name="gentext.space"/>
|
875
|
+
<xsl:value-of select="$copyright.date"/>
|
876
|
+
<xsl:call-template name="gentext.space"/>
|
877
|
+
<xsl:apply-templates select="d:holder" mode="titlepage.mode"/>
|
878
|
+
</xsl:variable>
|
879
|
+
|
880
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
881
|
+
<xsl:attribute name="property">dcterms:rights</xsl:attribute>
|
882
|
+
<xsl:copy-of select="$rights.content"/>
|
883
|
+
</xsl:element>
|
884
|
+
<xsl:if test="$epub.include.optional.metadata.dc.elements != 0">
|
885
|
+
<dc:rights>
|
886
|
+
<xsl:copy-of select="$rights.content"/>
|
887
|
+
</dc:rights>
|
888
|
+
</xsl:if>
|
889
|
+
|
890
|
+
<xsl:element name="meta" namespace="{$opf.namespace}">
|
891
|
+
<xsl:attribute name="property">dcterms:rightsHolder</xsl:attribute>
|
892
|
+
<xsl:apply-templates select="d:holder" mode="titlepage.mode"/>
|
893
|
+
</xsl:element>
|
894
|
+
</xsl:template>
|
895
|
+
|
896
|
+
<xsl:template name="package.guide">
|
897
|
+
|
898
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
899
|
+
|
900
|
+
<xsl:variable name="toc.params">
|
901
|
+
<xsl:call-template name="find.path.params">
|
902
|
+
<xsl:with-param name="node" select="."/>
|
903
|
+
<xsl:with-param name="table" select="normalize-space($generate.toc)"/>
|
904
|
+
</xsl:call-template>
|
905
|
+
</xsl:variable>
|
906
|
+
|
907
|
+
<xsl:if test="contains($toc.params, 'toc') or
|
908
|
+
$info/d:cover or
|
909
|
+
$info//d:mediaobject[@role='cover' or ancestor::d:cover]">
|
910
|
+
<xsl:element namespace="{$opf.namespace}" name="guide">
|
911
|
+
<xsl:if test="$info/d:cover or
|
912
|
+
$info//d:mediaobject[@role='cover' or ancestor::d:cover]">
|
913
|
+
<xsl:element namespace="{$opf.namespace}" name="reference">
|
914
|
+
<xsl:attribute name="href">
|
915
|
+
<xsl:value-of select="$epub.cover.filename" />
|
916
|
+
</xsl:attribute>
|
917
|
+
<xsl:attribute name="type">cover</xsl:attribute>
|
918
|
+
<xsl:attribute name="title">Cover</xsl:attribute>
|
919
|
+
</xsl:element>
|
920
|
+
</xsl:if>
|
921
|
+
|
922
|
+
<xsl:if test="contains($toc.params, 'toc')">
|
923
|
+
<xsl:element namespace="{$opf.namespace}" name="reference">
|
924
|
+
<xsl:attribute name="href">
|
925
|
+
<xsl:call-template name="toc-href">
|
926
|
+
<xsl:with-param name="node" select="."/>
|
927
|
+
</xsl:call-template>
|
928
|
+
</xsl:attribute>
|
929
|
+
<xsl:attribute name="type">toc</xsl:attribute>
|
930
|
+
<xsl:attribute name="title">Table of Contents</xsl:attribute>
|
931
|
+
</xsl:element>
|
932
|
+
</xsl:if>
|
933
|
+
</xsl:element>
|
934
|
+
</xsl:if>
|
935
|
+
</xsl:template>
|
936
|
+
|
937
|
+
|
938
|
+
<xsl:template name="package-identifier">
|
939
|
+
|
940
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
941
|
+
|
942
|
+
<xsl:choose>
|
943
|
+
<xsl:when test="$info/d:biblioid">
|
944
|
+
<xsl:if test="$info/d:biblioid[1][@class = 'doi' or
|
945
|
+
@class = 'isbn' or
|
946
|
+
@class = 'isrn' or
|
947
|
+
@class = 'istc' or
|
948
|
+
@class = 'issn']">
|
949
|
+
<xsl:text>urn:</xsl:text>
|
950
|
+
<xsl:value-of select="$info/d:biblioid[1]/@class"/>
|
951
|
+
<xsl:text>:</xsl:text>
|
952
|
+
</xsl:if>
|
953
|
+
<xsl:value-of select="normalize-space($info/d:biblioid[1])"/>
|
954
|
+
</xsl:when>
|
955
|
+
<xsl:when test="$info/d:isbn">
|
956
|
+
<xsl:text>urn:isbn:</xsl:text>
|
957
|
+
<xsl:value-of select="$info/d:isbn[1]"/>
|
958
|
+
</xsl:when>
|
959
|
+
<xsl:when test="$info/d:issn">
|
960
|
+
<xsl:text>urn:issn:</xsl:text>
|
961
|
+
<xsl:value-of select="$info/d:issn[1]"/>
|
962
|
+
</xsl:when>
|
963
|
+
<xsl:otherwise>
|
964
|
+
<xsl:choose>
|
965
|
+
<xsl:when test="$info/d:invpartnumber">
|
966
|
+
<xsl:value-of select="$info/d:invpartnumber[1]"/>
|
967
|
+
</xsl:when>
|
968
|
+
<xsl:when test="$info/d:issuenum">
|
969
|
+
<xsl:value-of select="$info/d:issuenum[1]"/>
|
970
|
+
</xsl:when>
|
971
|
+
<xsl:when test="$info/d:productnumber">
|
972
|
+
<xsl:value-of select="$info/d:productnumber[1]"/>
|
973
|
+
</xsl:when>
|
974
|
+
<xsl:when test="$info/d:seriesvolnums">
|
975
|
+
<xsl:value-of select="$info/d:seriesvolnums[1]"/>
|
976
|
+
</xsl:when>
|
977
|
+
<xsl:when test="$info/d:volumenum">
|
978
|
+
<xsl:value-of select="$info/d:volumenum[1]"/>
|
979
|
+
</xsl:when>
|
980
|
+
<!-- Deprecated -->
|
981
|
+
<xsl:when test="$info/d:pubsnumber">
|
982
|
+
<xsl:value-of select="$info/d:pubsnumber[1]"/>
|
983
|
+
</xsl:when>
|
984
|
+
</xsl:choose>
|
985
|
+
<xsl:text>_</xsl:text>
|
986
|
+
<xsl:choose>
|
987
|
+
<xsl:when test="@id">
|
988
|
+
<xsl:value-of select="@id"/>
|
989
|
+
</xsl:when>
|
990
|
+
<xsl:when test="@xml:id">
|
991
|
+
<xsl:value-of select="@xml:id"/>
|
992
|
+
</xsl:when>
|
993
|
+
<xsl:otherwise>
|
994
|
+
<!-- TODO: Do UUIDs here -->
|
995
|
+
<xsl:value-of select="generate-id(.)"/>
|
996
|
+
</xsl:otherwise>
|
997
|
+
</xsl:choose>
|
998
|
+
</xsl:otherwise>
|
999
|
+
</xsl:choose>
|
1000
|
+
</xsl:template>
|
1001
|
+
|
1002
|
+
<!-- EPUB3: add epub:type attribute where appropriate -->
|
1003
|
+
<xsl:template match="*" mode="common.html.attributes">
|
1004
|
+
<xsl:param name="class" select="local-name(.)"/>
|
1005
|
+
<xsl:param name="inherit" select="0"/>
|
1006
|
+
<xsl:call-template name="generate.html.lang"/>
|
1007
|
+
<xsl:call-template name="dir">
|
1008
|
+
<xsl:with-param name="inherit" select="$inherit"/>
|
1009
|
+
</xsl:call-template>
|
1010
|
+
<xsl:apply-templates select="." mode="class.attribute">
|
1011
|
+
<xsl:with-param name="class" select="$class"/>
|
1012
|
+
</xsl:apply-templates>
|
1013
|
+
<xsl:call-template name="generate.html.title"/>
|
1014
|
+
<xsl:apply-templates select="." mode="epub.type"/>
|
1015
|
+
</xsl:template>
|
1016
|
+
|
1017
|
+
<xsl:template match="*" mode="epub.type" priority="-1"/>
|
1018
|
+
|
1019
|
+
<xsl:template match="d:chapter
|
1020
|
+
|d:appendix
|
1021
|
+
|d:epigraph
|
1022
|
+
|d:warning
|
1023
|
+
|d:preface
|
1024
|
+
|d:index
|
1025
|
+
|d:colophon
|
1026
|
+
|d:glossary
|
1027
|
+
|d:biblioentry
|
1028
|
+
|d:bibliography
|
1029
|
+
|d:dedication
|
1030
|
+
|d:sidebar
|
1031
|
+
|d:footnote
|
1032
|
+
|d:glossterm
|
1033
|
+
|d:glossdef
|
1034
|
+
|d:bridgehead
|
1035
|
+
|d:part" mode="epub.type">
|
1036
|
+
<xsl:variable name="type" select="local-name()"/>
|
1037
|
+
|
1038
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1039
|
+
<xsl:attribute name="epub:type">
|
1040
|
+
<xsl:value-of select="$type"/>
|
1041
|
+
</xsl:attribute>
|
1042
|
+
</xsl:if>
|
1043
|
+
</xsl:template>
|
1044
|
+
|
1045
|
+
<xsl:template match="d:section[parent::d:chapter] | d:sect1" mode="epub.type">
|
1046
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1047
|
+
<xsl:attribute name="epub:type">subchapter</xsl:attribute>
|
1048
|
+
</xsl:if>
|
1049
|
+
</xsl:template>
|
1050
|
+
|
1051
|
+
<xsl:template match="d:section[not(parent::d:chapter)] |
|
1052
|
+
d:sect2 |
|
1053
|
+
d:sect3 |
|
1054
|
+
d:sect4 |
|
1055
|
+
d:sect5 |
|
1056
|
+
d:sect6" mode="epub.type">
|
1057
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1058
|
+
<xsl:attribute name="epub:type">division</xsl:attribute>
|
1059
|
+
</xsl:if>
|
1060
|
+
</xsl:template>
|
1061
|
+
|
1062
|
+
<xsl:template match="d:note|d:tip|d:caution|d:important" mode="epub.type">
|
1063
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1064
|
+
<xsl:attribute name="epub:type">notice</xsl:attribute>
|
1065
|
+
</xsl:if>
|
1066
|
+
</xsl:template>
|
1067
|
+
|
1068
|
+
<xsl:template match="d:orderedlist|d:itemizedlist|d:variablelist|d:simplelist" mode="epub.type">
|
1069
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1070
|
+
<xsl:attribute name="epub:type">list</xsl:attribute>
|
1071
|
+
</xsl:if>
|
1072
|
+
</xsl:template>
|
1073
|
+
|
1074
|
+
<xsl:template match="d:listitem" mode="epub.type">
|
1075
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1076
|
+
<xsl:attribute name="epub:type">list-item</xsl:attribute>
|
1077
|
+
</xsl:if>
|
1078
|
+
</xsl:template>
|
1079
|
+
|
1080
|
+
<!-- EPUB3: to add attributes to root output element -->
|
1081
|
+
<xsl:template name="root.attributes">
|
1082
|
+
<!-- collect and output all namespace declarations -->
|
1083
|
+
<xsl:call-template name="all.namespaces"/>
|
1084
|
+
</xsl:template>
|
1085
|
+
|
1086
|
+
<xsl:template name="all.namespaces">
|
1087
|
+
<!-- add the epub3 namespaces to the top output element -->
|
1088
|
+
<xsl:variable name="temp">
|
1089
|
+
<epub:foo/>
|
1090
|
+
<m:foo/>
|
1091
|
+
<pls:foo/>
|
1092
|
+
<ssml:foo/>
|
1093
|
+
<svg:foo/>
|
1094
|
+
</xsl:variable>
|
1095
|
+
|
1096
|
+
<xsl:variable name="nodes" select="exsl:node-set($temp)"/>
|
1097
|
+
<xsl:for-each select="$nodes//*/namespace::*">
|
1098
|
+
<xsl:copy-of select="."/>
|
1099
|
+
</xsl:for-each>
|
1100
|
+
|
1101
|
+
</xsl:template>
|
1102
|
+
|
1103
|
+
<xsl:template name="add.package.namespaces">
|
1104
|
+
<!-- add the epub3 package namespaces to the top output element -->
|
1105
|
+
<xsl:variable name="temp">
|
1106
|
+
<dc:foo/>
|
1107
|
+
<dcterms:foo/>
|
1108
|
+
</xsl:variable>
|
1109
|
+
|
1110
|
+
<xsl:variable name="nodes" select="exsl:node-set($temp)"/>
|
1111
|
+
<xsl:for-each select="$nodes//*[local-name(.) ='foo']/namespace::*">
|
1112
|
+
<xsl:if test="contains(., 'purl.org')">
|
1113
|
+
<xsl:copy-of select="."/>
|
1114
|
+
</xsl:if>
|
1115
|
+
</xsl:for-each>
|
1116
|
+
|
1117
|
+
</xsl:template>
|
1118
|
+
|
1119
|
+
|
1120
|
+
<xsl:template name="footnotes.attributes">
|
1121
|
+
<xsl:if test="$epub.output.epub.types != 0">
|
1122
|
+
<xsl:attribute name="epub:type">footnotes</xsl:attribute>
|
1123
|
+
</xsl:if>
|
1124
|
+
</xsl:template>
|
1125
|
+
|
1126
|
+
<xsl:template name="package.manifest">
|
1127
|
+
<xsl:element name="manifest" namespace="{$opf.namespace}">
|
1128
|
+
<xsl:if test="$epub.include.ncx != 0">
|
1129
|
+
<xsl:call-template name="manifest.ncx"/>
|
1130
|
+
</xsl:if>
|
1131
|
+
<xsl:call-template name="manifest.fonts"/>
|
1132
|
+
<xsl:call-template name="manifest.toc"/>
|
1133
|
+
<xsl:call-template name="manifest.css"/>
|
1134
|
+
<xsl:call-template name="manifest.cover"/>
|
1135
|
+
<xsl:call-template name="manifest.other.items"/>
|
1136
|
+
<xsl:call-template name="manifest.content.items"/>
|
1137
|
+
<xsl:call-template name="user.manifest.items"/>
|
1138
|
+
</xsl:element>
|
1139
|
+
</xsl:template>
|
1140
|
+
|
1141
|
+
<xsl:template name="user.manifest.items"/>
|
1142
|
+
|
1143
|
+
<xsl:template name="manifest.css">
|
1144
|
+
<xsl:if test="$html.stylesheet != ''">
|
1145
|
+
<xsl:call-template name="css.item">
|
1146
|
+
<xsl:with-param name="stylesheets" select="$html.stylesheet"/>
|
1147
|
+
</xsl:call-template>
|
1148
|
+
</xsl:if>
|
1149
|
+
<xsl:if test="string-length($docbook.css.source) != 0">
|
1150
|
+
<xsl:variable name="dfilename">
|
1151
|
+
<xsl:call-template name="css.output.filename">
|
1152
|
+
<xsl:with-param name="src" select="$docbook.css.source"/>
|
1153
|
+
</xsl:call-template>
|
1154
|
+
</xsl:variable>
|
1155
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1156
|
+
<xsl:attribute name="media-type">text/css</xsl:attribute>
|
1157
|
+
<xsl:attribute name="id">docbook-css</xsl:attribute>
|
1158
|
+
<xsl:attribute name="href">
|
1159
|
+
<xsl:value-of select="$dfilename"/>
|
1160
|
+
</xsl:attribute>
|
1161
|
+
</xsl:element>
|
1162
|
+
</xsl:if>
|
1163
|
+
<xsl:if test="string-length($custom.css.source) != 0">
|
1164
|
+
<xsl:variable name="cfilename">
|
1165
|
+
<xsl:call-template name="css.output.filename">
|
1166
|
+
<xsl:with-param name="src" select="$custom.css.source"/>
|
1167
|
+
</xsl:call-template>
|
1168
|
+
</xsl:variable>
|
1169
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1170
|
+
<xsl:attribute name="media-type">text/css</xsl:attribute>
|
1171
|
+
<xsl:attribute name="id">custom-css</xsl:attribute>
|
1172
|
+
<xsl:attribute name="href">
|
1173
|
+
<xsl:value-of select="$cfilename"/>
|
1174
|
+
</xsl:attribute>
|
1175
|
+
</xsl:element>
|
1176
|
+
</xsl:if>
|
1177
|
+
</xsl:template>
|
1178
|
+
|
1179
|
+
<xsl:template name="css.item">
|
1180
|
+
<xsl:param name="stylesheets" select="''"/>
|
1181
|
+
<xsl:param name="count" select="1"/>
|
1182
|
+
|
1183
|
+
<xsl:choose>
|
1184
|
+
<xsl:when test="contains($stylesheets, ' ')">
|
1185
|
+
<xsl:variable name="css.filename" select="substring-before($stylesheets, ' ')"/>
|
1186
|
+
<xsl:if test="$css.filename != ''">
|
1187
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1188
|
+
<xsl:attribute name="media-type">text/css</xsl:attribute>
|
1189
|
+
<xsl:attribute name="id">
|
1190
|
+
<xsl:text>html-css</xsl:text>
|
1191
|
+
<xsl:if test="$count > 1">
|
1192
|
+
<xsl:value-of select="$count"/>
|
1193
|
+
</xsl:if>
|
1194
|
+
</xsl:attribute>
|
1195
|
+
<xsl:attribute name="href">
|
1196
|
+
<xsl:value-of select="$css.filename"/>
|
1197
|
+
</xsl:attribute>
|
1198
|
+
</xsl:element>
|
1199
|
+
</xsl:if>
|
1200
|
+
|
1201
|
+
<xsl:call-template name="css.item">
|
1202
|
+
<xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
|
1203
|
+
<xsl:with-param name="count" select="$count + 1"/>
|
1204
|
+
</xsl:call-template>
|
1205
|
+
</xsl:when>
|
1206
|
+
<xsl:otherwise>
|
1207
|
+
<xsl:if test="$stylesheets != ''">
|
1208
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1209
|
+
<xsl:attribute name="media-type">text/css</xsl:attribute>
|
1210
|
+
<xsl:attribute name="id">
|
1211
|
+
<xsl:text>html-css</xsl:text>
|
1212
|
+
<xsl:if test="$count > 1">
|
1213
|
+
<xsl:value-of select="$count"/>
|
1214
|
+
</xsl:if>
|
1215
|
+
</xsl:attribute>
|
1216
|
+
<xsl:attribute name="href">
|
1217
|
+
<xsl:value-of select="$stylesheets"/>
|
1218
|
+
</xsl:attribute>
|
1219
|
+
</xsl:element>
|
1220
|
+
</xsl:if>
|
1221
|
+
</xsl:otherwise>
|
1222
|
+
</xsl:choose>
|
1223
|
+
</xsl:template>
|
1224
|
+
|
1225
|
+
<xsl:template name="manifest.ncx">
|
1226
|
+
<xsl:element name="item" namespace="{$opf.namespace}">
|
1227
|
+
<xsl:attribute name="id">
|
1228
|
+
<xsl:value-of select="$epub.ncx.manifest.id"/>
|
1229
|
+
</xsl:attribute>
|
1230
|
+
<xsl:attribute name="href">
|
1231
|
+
<xsl:value-of select="$epub.ncx.filename"/>
|
1232
|
+
</xsl:attribute>
|
1233
|
+
<xsl:attribute name="media-type">
|
1234
|
+
<xsl:value-of select="$epub.ncx.mediatype"/>
|
1235
|
+
</xsl:attribute>
|
1236
|
+
</xsl:element>
|
1237
|
+
</xsl:template>
|
1238
|
+
|
1239
|
+
<xsl:template name="manifest.fonts"/>
|
1240
|
+
|
1241
|
+
<!--Misc items in the manifest based on content -->
|
1242
|
+
<xsl:template name="manifest.other.items">
|
1243
|
+
</xsl:template>
|
1244
|
+
|
1245
|
+
|
1246
|
+
<xsl:template name="manifest.cover">
|
1247
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
1248
|
+
<xsl:variable name="cover.image"
|
1249
|
+
select="$info//d:mediaobject[@role='cover' or ancestor::d:cover]"/>
|
1250
|
+
|
1251
|
+
<xsl:if test="$cover.image">
|
1252
|
+
|
1253
|
+
<!-- generate the manifest link to that page -->
|
1254
|
+
<xsl:variable name="olist" select="$cover.image/d:imageobject|$cover.image/d:imageobjectco
|
1255
|
+
|$cover.image/d:videoobject|$cover.image/d:audioobject
|
1256
|
+
|$cover.image/d:textobject"/>
|
1257
|
+
|
1258
|
+
<xsl:variable name="object.index">
|
1259
|
+
<xsl:call-template name="select.mediaobject.index">
|
1260
|
+
<xsl:with-param name="olist" select="$olist"/>
|
1261
|
+
<xsl:with-param name="count" select="1"/>
|
1262
|
+
</xsl:call-template>
|
1263
|
+
</xsl:variable>
|
1264
|
+
|
1265
|
+
<xsl:variable name="object" select="$olist[position() = $object.index]"/>
|
1266
|
+
|
1267
|
+
<xsl:variable name="output_filename">
|
1268
|
+
<xsl:call-template name="mediaobject.filename">
|
1269
|
+
<xsl:with-param name="object" select="$object"/>
|
1270
|
+
</xsl:call-template>
|
1271
|
+
</xsl:variable>
|
1272
|
+
|
1273
|
+
<xsl:variable name="image.filename">
|
1274
|
+
<xsl:if test="$img.src.path != '' and
|
1275
|
+
not(starts-with($output_filename, '/')) and
|
1276
|
+
not(contains($output_filename, '://'))">
|
1277
|
+
<xsl:value-of select="$img.src.path"/>
|
1278
|
+
</xsl:if>
|
1279
|
+
<xsl:value-of select="$output_filename"/>
|
1280
|
+
</xsl:variable>
|
1281
|
+
<xsl:variable name="image.extension">
|
1282
|
+
<xsl:call-template name="filename-extension">
|
1283
|
+
<xsl:with-param name="filename" select="$image.filename"/>
|
1284
|
+
</xsl:call-template>
|
1285
|
+
</xsl:variable>
|
1286
|
+
|
1287
|
+
<xsl:variable name="image.type">
|
1288
|
+
<xsl:call-template name="graphic.format.content-type">
|
1289
|
+
<xsl:with-param name="format" select="translate($image.extension,
|
1290
|
+
&lowercase;, &uppercase;)"/>
|
1291
|
+
</xsl:call-template>
|
1292
|
+
</xsl:variable>
|
1293
|
+
|
1294
|
+
<!-- Reference to cover html file -->
|
1295
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1296
|
+
<xsl:attribute name="id">
|
1297
|
+
<xsl:value-of select="$epub.cover.filename.id"/>
|
1298
|
+
</xsl:attribute>
|
1299
|
+
<xsl:attribute name="href">
|
1300
|
+
<xsl:value-of select="$epub.cover.filename"/>
|
1301
|
+
</xsl:attribute>
|
1302
|
+
<xsl:attribute name="media-type">
|
1303
|
+
<xsl:value-of select="$epub.xhtml.mediatype"/>
|
1304
|
+
</xsl:attribute>
|
1305
|
+
</xsl:element>
|
1306
|
+
|
1307
|
+
<!-- special item with property="cover-image" -->
|
1308
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1309
|
+
<xsl:attribute name="id">
|
1310
|
+
<xsl:value-of select="$epub.cover.image.id"/>
|
1311
|
+
</xsl:attribute>
|
1312
|
+
<xsl:attribute name="properties">cover-image</xsl:attribute>
|
1313
|
+
<xsl:attribute name="href">
|
1314
|
+
<xsl:value-of select="$image.filename"/>
|
1315
|
+
</xsl:attribute>
|
1316
|
+
<xsl:if test="$image.type">
|
1317
|
+
<xsl:attribute name="media-type">
|
1318
|
+
<xsl:value-of select="$image.type"/>
|
1319
|
+
</xsl:attribute>
|
1320
|
+
</xsl:if>
|
1321
|
+
</xsl:element>
|
1322
|
+
|
1323
|
+
<!-- And generate the cover html file -->
|
1324
|
+
<xsl:apply-templates select="$cover.image"/>
|
1325
|
+
|
1326
|
+
</xsl:if>
|
1327
|
+
</xsl:template>
|
1328
|
+
|
1329
|
+
<xsl:template name="manifest.toc">
|
1330
|
+
<xsl:variable name="toc.params">
|
1331
|
+
<xsl:call-template name="find.path.params">
|
1332
|
+
<xsl:with-param name="node" select="."/>
|
1333
|
+
<xsl:with-param name="table" select="normalize-space($generate.toc)"/>
|
1334
|
+
</xsl:call-template>
|
1335
|
+
</xsl:variable>
|
1336
|
+
|
1337
|
+
<xsl:if test="contains($toc.params, 'toc')">
|
1338
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1339
|
+
<xsl:attribute name="id">
|
1340
|
+
<xsl:value-of select="$epub.html.toc.id"/>
|
1341
|
+
</xsl:attribute>
|
1342
|
+
<xsl:attribute name="properties">nav</xsl:attribute>
|
1343
|
+
<xsl:attribute name="media-type">
|
1344
|
+
<xsl:value-of select="$epub.xhtml.mediatype"/>
|
1345
|
+
</xsl:attribute>
|
1346
|
+
<xsl:attribute name="href">
|
1347
|
+
<xsl:call-template name="toc-href">
|
1348
|
+
<xsl:with-param name="node" select="."/>
|
1349
|
+
</xsl:call-template>
|
1350
|
+
</xsl:attribute>
|
1351
|
+
</xsl:element>
|
1352
|
+
</xsl:if>
|
1353
|
+
</xsl:template>
|
1354
|
+
|
1355
|
+
<xsl:template name="toc-href">
|
1356
|
+
<xsl:param name="node" select="."/>
|
1357
|
+
<!-- FIXME -->
|
1358
|
+
<xsl:apply-templates select="$node" mode="recursive-chunk-filename">
|
1359
|
+
<xsl:with-param name="recursive" select="true()"/>
|
1360
|
+
</xsl:apply-templates>
|
1361
|
+
<xsl:text>-toc</xsl:text>
|
1362
|
+
<xsl:value-of select="$html.ext"/>
|
1363
|
+
</xsl:template>
|
1364
|
+
|
1365
|
+
<xsl:template match="*" mode="recursive-chunk-filename">
|
1366
|
+
<!-- placeholder for real template in chunking stylesheet -->
|
1367
|
+
<xsl:value-of select="concat(local-name(.), '-', generate-id(.))"/>
|
1368
|
+
</xsl:template>
|
1369
|
+
|
1370
|
+
<xsl:template name="manifest.content.items">
|
1371
|
+
<xsl:apply-templates select="." mode="package.manifest"/>
|
1372
|
+
<xsl:call-template name="manifest.images"/>
|
1373
|
+
</xsl:template>
|
1374
|
+
|
1375
|
+
<xsl:template match="text()" mode="package.manifest"/>
|
1376
|
+
|
1377
|
+
<xsl:template match="d:mediaobject|d:mediaobjectco|d:inlinemediaobject" priority="1"
|
1378
|
+
mode="package.manifest">
|
1379
|
+
<!-- These are handled out of line so a unique list is created
|
1380
|
+
to remove duplicate references -->
|
1381
|
+
</xsl:template>
|
1382
|
+
|
1383
|
+
<xsl:template match="*" mode="package.manifest">
|
1384
|
+
|
1385
|
+
<xsl:variable name="is.chunk">
|
1386
|
+
<xsl:call-template name="chunk">
|
1387
|
+
<xsl:with-param name="node" select="."/>
|
1388
|
+
</xsl:call-template>
|
1389
|
+
</xsl:variable>
|
1390
|
+
|
1391
|
+
<xsl:if test="$is.chunk != 0">
|
1392
|
+
<xsl:variable name="href">
|
1393
|
+
<xsl:call-template name="href.target.with.base.dir">
|
1394
|
+
<xsl:with-param name="context" select="/"/>
|
1395
|
+
</xsl:call-template>
|
1396
|
+
</xsl:variable>
|
1397
|
+
|
1398
|
+
<xsl:variable name="id" select="concat($epub.package.id.prefix, generate-id())"/>
|
1399
|
+
|
1400
|
+
<xsl:variable name="properties.set">
|
1401
|
+
<xsl:call-template name="svg.property"/>
|
1402
|
+
<xsl:text> </xsl:text>
|
1403
|
+
<xsl:call-template name="mathml.property"/>
|
1404
|
+
</xsl:variable>
|
1405
|
+
|
1406
|
+
<xsl:variable name="properties" select="normalize-space($properties.set)"/>
|
1407
|
+
|
1408
|
+
<xsl:element namespace="{$opf.namespace}" name="item">
|
1409
|
+
<xsl:attribute name="id">
|
1410
|
+
<xsl:value-of select="$id"/>
|
1411
|
+
</xsl:attribute>
|
1412
|
+
<xsl:attribute name="href">
|
1413
|
+
<xsl:value-of select="$href"/>
|
1414
|
+
</xsl:attribute>
|
1415
|
+
<xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
|
1416
|
+
<xsl:if test="string-length($properties) != 0">
|
1417
|
+
<xsl:attribute name="properties">
|
1418
|
+
<xsl:value-of select="$properties"/>
|
1419
|
+
</xsl:attribute>
|
1420
|
+
</xsl:if>
|
1421
|
+
</xsl:element>
|
1422
|
+
</xsl:if>
|
1423
|
+
<xsl:apply-templates mode="package.manifest"/>
|
1424
|
+
|
1425
|
+
</xsl:template>
|
1426
|
+
|
1427
|
+
<xsl:template name="svg.property">
|
1428
|
+
<xsl:param name="this.chunk" select="."/>
|
1429
|
+
|
1430
|
+
<xsl:variable name="genid" select="generate-id($this.chunk)"/>
|
1431
|
+
|
1432
|
+
<!-- get the chunkfast div element for this chunk -->
|
1433
|
+
<xsl:variable name="div" select="$chunkset[@id=$genid or @xml:id=$genid]"/>
|
1434
|
+
|
1435
|
+
<!-- get the chunkfast div element the next chunk -->
|
1436
|
+
<xsl:variable name="nextdiv"
|
1437
|
+
select="($div/following-sibling::cf:div|
|
1438
|
+
$div/following::cf:div|
|
1439
|
+
$div/cf:div)[1]"/>
|
1440
|
+
|
1441
|
+
<!-- get the element corresponding to the next chunk -->
|
1442
|
+
<xsl:variable name="next.chunk" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
|
1443
|
+
|
1444
|
+
<xsl:choose>
|
1445
|
+
<xsl:when test="$next.chunk">
|
1446
|
+
<xsl:variable name="this.imagedata"
|
1447
|
+
select="$this.chunk//d:mediaobject"/>
|
1448
|
+
<xsl:variable name="before.next"
|
1449
|
+
select="$next.chunk/preceding::d:mediaobject"/>
|
1450
|
+
|
1451
|
+
<!-- select for an SVG imagedata in the intersection of them -->
|
1452
|
+
<xsl:variable name="mediaobject.set"
|
1453
|
+
select="$this.imagedata[count(.|$before.next) = count($before.next)]"/>
|
1454
|
+
<xsl:variable name="svg.imagedata">
|
1455
|
+
<xsl:for-each select="$mediaobject.set">
|
1456
|
+
<xsl:variable name="olist" select="d:imageobject[not(@role = 'poster')] |
|
1457
|
+
d:imageobjectco"/>
|
1458
|
+
<xsl:variable name="mediaobject.index">
|
1459
|
+
<xsl:call-template name="select.mediaobject.index">
|
1460
|
+
<xsl:with-param name="olist" select="$olist"/>
|
1461
|
+
</xsl:call-template>
|
1462
|
+
</xsl:variable>
|
1463
|
+
<xsl:variable name="object" select="$olist[position() = $mediaobject.index]"/>
|
1464
|
+
<xsl:if test="$object/d:imagedata[contains(
|
1465
|
+
substring(@fileref, string-length(@fileref)-3,4), '.svg')]">
|
1466
|
+
<xsl:text>svg</xsl:text>
|
1467
|
+
</xsl:if>
|
1468
|
+
</xsl:for-each>
|
1469
|
+
</xsl:variable>
|
1470
|
+
|
1471
|
+
<xsl:if test="contains($svg.imagedata, 'svg')">
|
1472
|
+
<xsl:text>svg</xsl:text>
|
1473
|
+
</xsl:if>
|
1474
|
+
</xsl:when>
|
1475
|
+
<xsl:otherwise>
|
1476
|
+
<xsl:variable name="mediaobject.set"
|
1477
|
+
select="$this.chunk//d:mediaobject"/>
|
1478
|
+
<xsl:variable name="svg.imagedata">
|
1479
|
+
<xsl:for-each select="$mediaobject.set">
|
1480
|
+
<xsl:variable name="olist" select="d:imageobject[not(@role = 'poster')] |
|
1481
|
+
d:imageobjectco"/>
|
1482
|
+
<xsl:variable name="mediaobject.index">
|
1483
|
+
<xsl:call-template name="select.mediaobject.index">
|
1484
|
+
<xsl:with-param name="olist" select="$olist"/>
|
1485
|
+
</xsl:call-template>
|
1486
|
+
</xsl:variable>
|
1487
|
+
<xsl:variable name="object" select="$olist[position() = $mediaobject.index]"/>
|
1488
|
+
<xsl:if test="$object/d:imagedata[contains(
|
1489
|
+
substring(@fileref, string-length(@fileref)-3,4), '.svg')]">
|
1490
|
+
<xsl:text>svg</xsl:text>
|
1491
|
+
</xsl:if>
|
1492
|
+
</xsl:for-each>
|
1493
|
+
</xsl:variable>
|
1494
|
+
|
1495
|
+
<xsl:if test="contains($svg.imagedata, 'svg')">
|
1496
|
+
<xsl:text>svg</xsl:text>
|
1497
|
+
</xsl:if>
|
1498
|
+
</xsl:otherwise>
|
1499
|
+
</xsl:choose>
|
1500
|
+
|
1501
|
+
</xsl:template>
|
1502
|
+
|
1503
|
+
<xsl:template name="mathml.property">
|
1504
|
+
<xsl:param name="this.chunk" select="."/>
|
1505
|
+
|
1506
|
+
<xsl:variable name="genid" select="generate-id($this.chunk)"/>
|
1507
|
+
|
1508
|
+
<!-- get the chunkfast div element for this chunk -->
|
1509
|
+
<xsl:variable name="div" select="$chunkset[@id=$genid or @xml:id=$genid]"/>
|
1510
|
+
|
1511
|
+
<!-- get the chunkfast div element the next chunk -->
|
1512
|
+
<xsl:variable name="nextdiv"
|
1513
|
+
select="($div/following-sibling::cf:div|
|
1514
|
+
$div/following::cf:div|
|
1515
|
+
$div/cf:div)[1]"/>
|
1516
|
+
|
1517
|
+
<!-- get the element corresponding to the next chunk -->
|
1518
|
+
<xsl:variable name="next.chunk" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
|
1519
|
+
|
1520
|
+
<xsl:variable name="this.math"
|
1521
|
+
select="$this.chunk//m:*"/>
|
1522
|
+
<xsl:variable name="before.next"
|
1523
|
+
select="$next.chunk/preceding::m:*"/>
|
1524
|
+
|
1525
|
+
<!-- select for an SVG imagedata in the intersection of them -->
|
1526
|
+
<xsl:variable name="intersection"
|
1527
|
+
select="$this.math[count(.|$before.next) = count($before.next)]"/>
|
1528
|
+
|
1529
|
+
<xsl:if test="count($intersection) != 0">
|
1530
|
+
<xsl:text>mathml</xsl:text>
|
1531
|
+
</xsl:if>
|
1532
|
+
</xsl:template>
|
1533
|
+
|
1534
|
+
<xsl:template name="manifest.image.item">
|
1535
|
+
</xsl:template>
|
1536
|
+
|
1537
|
+
<!-- Need a uniqued list of images -->
|
1538
|
+
<xsl:template name="manifest.images">
|
1539
|
+
<xsl:message>Generating image list ...</xsl:message>
|
1540
|
+
<xsl:variable name="imagelist">
|
1541
|
+
<xsl:choose>
|
1542
|
+
<xsl:when test="$rootid != ''">
|
1543
|
+
<xsl:apply-templates select="key('id', $rootid)" mode="enumerate-images"/>
|
1544
|
+
</xsl:when>
|
1545
|
+
<xsl:otherwise>
|
1546
|
+
<xsl:apply-templates select="/" mode="enumerate-images"/>
|
1547
|
+
</xsl:otherwise>
|
1548
|
+
</xsl:choose>
|
1549
|
+
</xsl:variable>
|
1550
|
+
|
1551
|
+
<xsl:choose>
|
1552
|
+
<xsl:when test="$exsl.node.set.available != 0 and
|
1553
|
+
function-available('set:distinct')">
|
1554
|
+
<xsl:for-each select="set:distinct(exsl:node-set($imagelist)/*)">
|
1555
|
+
<xsl:if test="string-length(tmp-href) != 0">
|
1556
|
+
<!-- convert the child elements to attributes -->
|
1557
|
+
<xsl:element name="item" namespace="{$opf.namespace}">
|
1558
|
+
<xsl:attribute name="id">
|
1559
|
+
<xsl:value-of select="generate-id()"/>
|
1560
|
+
</xsl:attribute>
|
1561
|
+
<xsl:attribute name="href">
|
1562
|
+
<xsl:value-of select="tmp-href"/>
|
1563
|
+
</xsl:attribute>
|
1564
|
+
<xsl:attribute name="media-type">
|
1565
|
+
<xsl:value-of select="media-type"/>
|
1566
|
+
</xsl:attribute>
|
1567
|
+
</xsl:element>
|
1568
|
+
</xsl:if>
|
1569
|
+
</xsl:for-each>
|
1570
|
+
</xsl:when>
|
1571
|
+
<xsl:when test="$exsl.node.set.available != 0">
|
1572
|
+
<xsl:for-each select="exsl:node-set($imagelist)/*">
|
1573
|
+
<xsl:element name="item" namespace="{$opf.namespace}">
|
1574
|
+
<xsl:attribute name="id">
|
1575
|
+
<xsl:value-of select="generate-id()"/>
|
1576
|
+
</xsl:attribute>
|
1577
|
+
<xsl:attribute name="href">
|
1578
|
+
<xsl:value-of select="tmp-href"/>
|
1579
|
+
</xsl:attribute>
|
1580
|
+
<xsl:attribute name="media-type">
|
1581
|
+
<xsl:value-of select="media-type"/>
|
1582
|
+
</xsl:attribute>
|
1583
|
+
</xsl:element>
|
1584
|
+
</xsl:for-each>
|
1585
|
+
</xsl:when>
|
1586
|
+
<xsl:otherwise>
|
1587
|
+
<xsl:message terminate="yes">
|
1588
|
+
<xsl:text>ERROR: cannot process images list without </xsl:text>
|
1589
|
+
<xsl:text>exsl:node-set() function</xsl:text>
|
1590
|
+
</xsl:message>
|
1591
|
+
<!-- cannot do this without node-set() -->
|
1592
|
+
</xsl:otherwise>
|
1593
|
+
</xsl:choose>
|
1594
|
+
|
1595
|
+
</xsl:template>
|
1596
|
+
|
1597
|
+
<xsl:template match="*" mode="enumerate-images">
|
1598
|
+
<xsl:apply-templates mode="enumerate-images"/>
|
1599
|
+
</xsl:template>
|
1600
|
+
|
1601
|
+
<xsl:template match="text()" mode="enumerate-images"/>
|
1602
|
+
|
1603
|
+
<xsl:template match="d:graphic|d:inlinegraphic[@format!='linespecific']"
|
1604
|
+
mode="enumerate-images">
|
1605
|
+
</xsl:template>
|
1606
|
+
|
1607
|
+
<!-- cover image handled separates to give it an extra property attribute -->
|
1608
|
+
<xsl:template match="d:mediaobject[@role='cover' or ancestor::d:cover]"
|
1609
|
+
mode="enumerate-images"/>
|
1610
|
+
|
1611
|
+
<xsl:template match="d:mediaobject|d:inlinemediaobject" mode="enumerate-images">
|
1612
|
+
|
1613
|
+
<xsl:variable name="olist"
|
1614
|
+
select="d:imageobject[not(@role = 'poster')]
|
1615
|
+
|d:imageobjectco
|
1616
|
+
|d:videoobject
|
1617
|
+
|d:audioobject
|
1618
|
+
|d:textobject"/>
|
1619
|
+
|
1620
|
+
<xsl:variable name="object.index">
|
1621
|
+
<xsl:call-template name="select.mediaobject.index">
|
1622
|
+
<xsl:with-param name="olist" select="$olist"/>
|
1623
|
+
<xsl:with-param name="count" select="1"/>
|
1624
|
+
</xsl:call-template>
|
1625
|
+
</xsl:variable>
|
1626
|
+
|
1627
|
+
<xsl:variable name="object" select="$olist[position() = $object.index]"/>
|
1628
|
+
|
1629
|
+
<xsl:apply-templates select="$object" mode="enumerate-images"/>
|
1630
|
+
|
1631
|
+
<!-- also include a poster image if present -->
|
1632
|
+
<xsl:apply-templates select="d:imageobject[@role = 'poster']" mode="enumerate-images"/>
|
1633
|
+
|
1634
|
+
</xsl:template>
|
1635
|
+
|
1636
|
+
<xsl:template match="d:imageobject|d:videoobject|d:audioobject" mode="enumerate-images">
|
1637
|
+
<xsl:param name="object" select="."/>
|
1638
|
+
|
1639
|
+
<xsl:if test="$object">
|
1640
|
+
<xsl:variable name="output_filename">
|
1641
|
+
<xsl:call-template name="mediaobject.filename">
|
1642
|
+
<xsl:with-param name="object" select="$object"/>
|
1643
|
+
</xsl:call-template>
|
1644
|
+
</xsl:variable>
|
1645
|
+
|
1646
|
+
<xsl:variable name="image.filename">
|
1647
|
+
<xsl:if test="$img.src.path != '' and
|
1648
|
+
not(starts-with($output_filename, '/')) and
|
1649
|
+
not(contains($output_filename, '://'))">
|
1650
|
+
<xsl:value-of select="$img.src.path"/>
|
1651
|
+
</xsl:if>
|
1652
|
+
<xsl:value-of select="$output_filename"/>
|
1653
|
+
</xsl:variable>
|
1654
|
+
|
1655
|
+
<xsl:variable name="image.extension">
|
1656
|
+
<xsl:call-template name="filename-extension">
|
1657
|
+
<xsl:with-param name="filename" select="$image.filename"/>
|
1658
|
+
</xsl:call-template>
|
1659
|
+
</xsl:variable>
|
1660
|
+
|
1661
|
+
<xsl:variable name="image.type">
|
1662
|
+
<xsl:call-template name="graphic.format.content-type">
|
1663
|
+
<xsl:with-param name="format" select="translate($image.extension,
|
1664
|
+
&lowercase;, &uppercase;)"/>
|
1665
|
+
</xsl:call-template>
|
1666
|
+
</xsl:variable>
|
1667
|
+
|
1668
|
+
<xsl:element name="tmp-filename" namespace="">
|
1669
|
+
<xsl:element name="tmp-href" namespace="">
|
1670
|
+
<xsl:value-of select="$image.filename"/>
|
1671
|
+
</xsl:element>
|
1672
|
+
<xsl:element name="media-type" namespace="">
|
1673
|
+
<xsl:value-of select="$image.type"/>
|
1674
|
+
</xsl:element>
|
1675
|
+
</xsl:element>
|
1676
|
+
|
1677
|
+
</xsl:if>
|
1678
|
+
</xsl:template>
|
1679
|
+
|
1680
|
+
<!-- Add in the generated images -->
|
1681
|
+
<xsl:template match="d:note|d:caution|d:warning|d:important|d:tip" mode="enumerate-images">
|
1682
|
+
<xsl:if test="$admon.graphics != 0">
|
1683
|
+
<xsl:variable name="image.filename">
|
1684
|
+
<xsl:call-template name="admon.graphic"/>
|
1685
|
+
</xsl:variable>
|
1686
|
+
|
1687
|
+
<xsl:variable name="image.type">
|
1688
|
+
<xsl:call-template name="graphic.format.content-type">
|
1689
|
+
<xsl:with-param name="format" select="translate(
|
1690
|
+
substring-after($admon.graphics.extension,'.'),
|
1691
|
+
&lowercase;, &uppercase;)"/>
|
1692
|
+
</xsl:call-template>
|
1693
|
+
</xsl:variable>
|
1694
|
+
|
1695
|
+
<xsl:element name="tmp-filename" namespace="">
|
1696
|
+
<xsl:element name="tmp-href" namespace="">
|
1697
|
+
<xsl:value-of select="$image.filename"/>
|
1698
|
+
</xsl:element>
|
1699
|
+
<xsl:element name="media-type" namespace="">
|
1700
|
+
<xsl:value-of select="$image.type"/>
|
1701
|
+
</xsl:element>
|
1702
|
+
</xsl:element>
|
1703
|
+
|
1704
|
+
</xsl:if>
|
1705
|
+
</xsl:template>
|
1706
|
+
|
1707
|
+
<xsl:template match="d:callout" mode="enumerate-images">
|
1708
|
+
<!-- process arearefs to get name of callout bug image files -->
|
1709
|
+
<xsl:if test="$callout.graphics != 0">
|
1710
|
+
<xsl:variable name="arearefs">
|
1711
|
+
<xsl:call-template name="callout.arearefs">
|
1712
|
+
<xsl:with-param name="arearefs" select="@arearefs"/>
|
1713
|
+
</xsl:call-template>
|
1714
|
+
</xsl:variable>
|
1715
|
+
|
1716
|
+
<xsl:variable name="nodes" select="exsl:node-set($arearefs)"/>
|
1717
|
+
|
1718
|
+
<xsl:for-each select="$nodes//*[@src]">
|
1719
|
+
<xsl:variable name="image.filename" select="@src"/>
|
1720
|
+
|
1721
|
+
<xsl:variable name="image.type">
|
1722
|
+
<xsl:call-template name="graphic.format.content-type">
|
1723
|
+
<xsl:with-param name="format" select="translate(
|
1724
|
+
substring-after($callout.graphics.extension,'.'),
|
1725
|
+
&lowercase;, &uppercase;)"/>
|
1726
|
+
</xsl:call-template>
|
1727
|
+
</xsl:variable>
|
1728
|
+
|
1729
|
+
<xsl:element name="tmp-filename" namespace="">
|
1730
|
+
<xsl:element name="tmp-href" namespace="">
|
1731
|
+
<xsl:value-of select="$image.filename"/>
|
1732
|
+
</xsl:element>
|
1733
|
+
<xsl:element name="media-type" namespace="">
|
1734
|
+
<xsl:value-of select="$image.type"/>
|
1735
|
+
</xsl:element>
|
1736
|
+
</xsl:element>
|
1737
|
+
</xsl:for-each>
|
1738
|
+
|
1739
|
+
</xsl:if>
|
1740
|
+
</xsl:template>
|
1741
|
+
|
1742
|
+
<xsl:template match="d:co" mode="enumerate-images">
|
1743
|
+
<!-- process co to get name of callout bug image file -->
|
1744
|
+
<xsl:if test="$callout.graphics != 0">
|
1745
|
+
<xsl:variable name="result">
|
1746
|
+
<xsl:apply-templates select="." mode="callout-bug"/>
|
1747
|
+
</xsl:variable>
|
1748
|
+
|
1749
|
+
<xsl:variable name="nodes" select="exsl:node-set($result)"/>
|
1750
|
+
|
1751
|
+
<xsl:for-each select="$nodes//*[@src]">
|
1752
|
+
<xsl:variable name="image.filename" select="@src"/>
|
1753
|
+
|
1754
|
+
<xsl:variable name="image.type">
|
1755
|
+
<xsl:call-template name="graphic.format.content-type">
|
1756
|
+
<xsl:with-param name="format" select="translate(
|
1757
|
+
substring-after($callout.graphics.extension,'.'),
|
1758
|
+
&lowercase;, &uppercase;)"/>
|
1759
|
+
</xsl:call-template>
|
1760
|
+
</xsl:variable>
|
1761
|
+
|
1762
|
+
<xsl:element name="tmp-filename" namespace="">
|
1763
|
+
<xsl:element name="tmp-href" namespace="">
|
1764
|
+
<xsl:value-of select="$image.filename"/>
|
1765
|
+
</xsl:element>
|
1766
|
+
<xsl:element name="media-type" namespace="">
|
1767
|
+
<xsl:value-of select="$image.type"/>
|
1768
|
+
</xsl:element>
|
1769
|
+
</xsl:element>
|
1770
|
+
</xsl:for-each>
|
1771
|
+
|
1772
|
+
</xsl:if>
|
1773
|
+
|
1774
|
+
</xsl:template>
|
1775
|
+
|
1776
|
+
<!-- ======================================================== -->
|
1777
|
+
<!-- NCX templates are for backwards compatibility with EPUB2 -->
|
1778
|
+
<!-- ======================================================== -->
|
1779
|
+
|
1780
|
+
<xsl:template name="ncx">
|
1781
|
+
<xsl:message>Generating NCX file ...</xsl:message>
|
1782
|
+
<xsl:call-template name="write.chunk">
|
1783
|
+
<xsl:with-param name="filename">
|
1784
|
+
<xsl:value-of select="$epub.ncx.pathname" />
|
1785
|
+
</xsl:with-param>
|
1786
|
+
<xsl:with-param name="method" select="'xml'" />
|
1787
|
+
<xsl:with-param name="encoding" select="'utf-8'" />
|
1788
|
+
<xsl:with-param name="indent" select="'no'" />
|
1789
|
+
<xsl:with-param name="quiet" select="$chunk.quietly" />
|
1790
|
+
<xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
|
1791
|
+
<xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
|
1792
|
+
<xsl:with-param name="content">
|
1793
|
+
<xsl:element name="ncx" namespace="{$ncx.namespace}">
|
1794
|
+
<xsl:attribute name="version">2005-1</xsl:attribute>
|
1795
|
+
|
1796
|
+
<!-- Via Martin Goerner: On covers: the IDPF2.0 standard unfortunately does not have a provision for
|
1797
|
+
covers. We had to add one and we did so in conjunction with the IDPF and
|
1798
|
+
various publishers. The tag chosen to define the covers is:
|
1799
|
+
<meta name="cover" content="-reference to a manifest item-">
|
1800
|
+
Then, we also added a bit of logic to get rid cleanly of the HTML cover
|
1801
|
+
people usually add because the logical cover is not specced by the IDPF. So,
|
1802
|
+
if the HTML cover item is marked linear="no" AND there is a guide item of
|
1803
|
+
type="cover" pointing to it AND there is a logical cover specified in a
|
1804
|
+
<meta name="cover"> tag, THEN, the HTML cover is discarded. -->
|
1805
|
+
<xsl:element name="head" namespace="{$ncx.namespace}">
|
1806
|
+
<xsl:if test="/*/*[d:cover or contains(name(.), 'info')]//d:mediaobject[@role='cover' or ancestor::d:cover]">
|
1807
|
+
<xsl:element name="meta" namespace="{$ncx.namespace}">
|
1808
|
+
<xsl:attribute name="name">cover</xsl:attribute>
|
1809
|
+
<xsl:attribute name="content">
|
1810
|
+
<xsl:value-of select="$epub.cover.filename.id"/>
|
1811
|
+
</xsl:attribute>
|
1812
|
+
</xsl:element>
|
1813
|
+
</xsl:if>
|
1814
|
+
<xsl:element name="meta" namespace="{$ncx.namespace}">
|
1815
|
+
<xsl:attribute name="name">dtb:uid</xsl:attribute>
|
1816
|
+
<xsl:attribute name="content"><xsl:call-template name="package-identifier"/></xsl:attribute>
|
1817
|
+
</xsl:element>
|
1818
|
+
</xsl:element>
|
1819
|
+
|
1820
|
+
<xsl:choose>
|
1821
|
+
<xsl:when test="$rootid != ''">
|
1822
|
+
<xsl:variable name="title">
|
1823
|
+
<xsl:if test="$epub.autolabel != 0">
|
1824
|
+
<xsl:variable name="label.markup">
|
1825
|
+
<xsl:apply-templates select="key('id',$rootid)" mode="label.markup" />
|
1826
|
+
</xsl:variable>
|
1827
|
+
<xsl:if test="normalize-space($label.markup)">
|
1828
|
+
<xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
|
1829
|
+
</xsl:if>
|
1830
|
+
</xsl:if>
|
1831
|
+
<xsl:apply-templates select="key('id',$rootid)" mode="title.markup" />
|
1832
|
+
</xsl:variable>
|
1833
|
+
<xsl:variable name="href">
|
1834
|
+
<xsl:call-template name="href.target.with.base.dir">
|
1835
|
+
<xsl:with-param name="object" select="key('id',$rootid)" />
|
1836
|
+
</xsl:call-template>
|
1837
|
+
</xsl:variable>
|
1838
|
+
<xsl:element name="docTitle" namespace="{$ncx.namespace}">
|
1839
|
+
<xsl:element name="text" namespace="{$ncx.namespace}"><xsl:value-of select="normalize-space($title)" /> </xsl:element>
|
1840
|
+
</xsl:element>
|
1841
|
+
<xsl:element name="navMap" namespace="{$ncx.namespace}">
|
1842
|
+
<xsl:apply-templates select="key('id',$rootid)/*" mode="ncx" />
|
1843
|
+
</xsl:element>
|
1844
|
+
</xsl:when>
|
1845
|
+
<xsl:otherwise>
|
1846
|
+
<xsl:variable name="title">
|
1847
|
+
<xsl:if test="$epub.autolabel != 0">
|
1848
|
+
<xsl:variable name="label.markup">
|
1849
|
+
<xsl:apply-templates select="/*" mode="label.markup" />
|
1850
|
+
</xsl:variable>
|
1851
|
+
<xsl:if test="normalize-space($label.markup)">
|
1852
|
+
<xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
|
1853
|
+
</xsl:if>
|
1854
|
+
</xsl:if>
|
1855
|
+
<xsl:apply-templates select="/*" mode="title.markup" />
|
1856
|
+
</xsl:variable>
|
1857
|
+
<xsl:variable name="href">
|
1858
|
+
<xsl:call-template name="href.target.with.base.dir">
|
1859
|
+
<xsl:with-param name="object" select="/" />
|
1860
|
+
</xsl:call-template>
|
1861
|
+
</xsl:variable>
|
1862
|
+
<xsl:element name="docTitle" namespace="{$ncx.namespace}">
|
1863
|
+
<xsl:element name="text" namespace="{$ncx.namespace}">
|
1864
|
+
<xsl:value-of select="normalize-space($title)" />
|
1865
|
+
</xsl:element>
|
1866
|
+
</xsl:element>
|
1867
|
+
<xsl:element name="navMap" namespace="{$ncx.namespace}">
|
1868
|
+
<xsl:choose>
|
1869
|
+
<xsl:when test="$root.is.a.chunk != '0'">
|
1870
|
+
<xsl:apply-templates select="/*" mode="ncx" />
|
1871
|
+
<xsl:apply-templates select="/*/*" mode="ncx" />
|
1872
|
+
</xsl:when>
|
1873
|
+
<xsl:otherwise>
|
1874
|
+
<xsl:apply-templates select="/*/*" mode="ncx" />
|
1875
|
+
</xsl:otherwise>
|
1876
|
+
</xsl:choose>
|
1877
|
+
</xsl:element>
|
1878
|
+
</xsl:otherwise>
|
1879
|
+
|
1880
|
+
</xsl:choose>
|
1881
|
+
</xsl:element>
|
1882
|
+
</xsl:with-param>
|
1883
|
+
</xsl:call-template>
|
1884
|
+
</xsl:template>
|
1885
|
+
|
1886
|
+
<xsl:template match="d:book|
|
1887
|
+
d:article|
|
1888
|
+
d:topic|
|
1889
|
+
d:part|
|
1890
|
+
d:reference|
|
1891
|
+
d:preface|
|
1892
|
+
d:chapter|
|
1893
|
+
d:bibliography|
|
1894
|
+
d:appendix|
|
1895
|
+
d:glossary|
|
1896
|
+
d:section|
|
1897
|
+
d:sect1|
|
1898
|
+
d:sect2|
|
1899
|
+
d:sect3|
|
1900
|
+
d:sect4|
|
1901
|
+
d:sect5|
|
1902
|
+
d:refentry|
|
1903
|
+
d:colophon|
|
1904
|
+
d:bibliodiv[d:title]|
|
1905
|
+
d:setindex|
|
1906
|
+
d:index"
|
1907
|
+
mode="ncx">
|
1908
|
+
<xsl:variable name="depth" select="count(ancestor::*)"/>
|
1909
|
+
<xsl:variable name="title">
|
1910
|
+
<xsl:if test="$epub.autolabel != 0">
|
1911
|
+
<xsl:variable name="label.markup">
|
1912
|
+
<xsl:apply-templates select="." mode="label.markup" />
|
1913
|
+
</xsl:variable>
|
1914
|
+
<xsl:if test="normalize-space($label.markup)">
|
1915
|
+
<xsl:value-of
|
1916
|
+
select="concat($label.markup,$autotoc.label.separator)" />
|
1917
|
+
</xsl:if>
|
1918
|
+
</xsl:if>
|
1919
|
+
<xsl:apply-templates select="." mode="title.markup" />
|
1920
|
+
</xsl:variable>
|
1921
|
+
|
1922
|
+
<xsl:variable name="href">
|
1923
|
+
<xsl:call-template name="href.target.with.base.dir">
|
1924
|
+
<xsl:with-param name="context" select="/" />
|
1925
|
+
<!-- Generate links relative to the location of root file/toc.xml file -->
|
1926
|
+
</xsl:call-template>
|
1927
|
+
</xsl:variable>
|
1928
|
+
|
1929
|
+
<xsl:variable name="id">
|
1930
|
+
<xsl:value-of select="generate-id(.)"/>
|
1931
|
+
</xsl:variable>
|
1932
|
+
<xsl:variable name="order">
|
1933
|
+
<xsl:value-of select="$depth +
|
1934
|
+
count(preceding::d:part|
|
1935
|
+
preceding::d:reference|
|
1936
|
+
preceding::d:book[parent::d:set]|
|
1937
|
+
preceding::d:preface|
|
1938
|
+
preceding::d:chapter|
|
1939
|
+
preceding::d:bibliography|
|
1940
|
+
preceding::d:appendix|
|
1941
|
+
preceding::d:article|
|
1942
|
+
preceding::d:topic|
|
1943
|
+
preceding::d:glossary|
|
1944
|
+
preceding::d:section[not(parent::d:partintro)]|
|
1945
|
+
preceding::d:sect1[not(parent::d:partintro)]|
|
1946
|
+
preceding::d:sect2[not(ancestor::d:partintro)]|
|
1947
|
+
preceding::d:sect3[not(ancestor::d:partintro)]|
|
1948
|
+
preceding::d:sect4[not(ancestor::d:partintro)]|
|
1949
|
+
preceding::d:sect5[not(ancestor::d:partintro)]|
|
1950
|
+
preceding::d:refentry|
|
1951
|
+
preceding::d:colophon|
|
1952
|
+
preceding::d:bibliodiv[d:title]|
|
1953
|
+
preceding::d:index)"/>
|
1954
|
+
</xsl:variable>
|
1955
|
+
|
1956
|
+
<xsl:element name="navPoint" namespace="{$ncx.namespace}">
|
1957
|
+
<xsl:attribute name="id">
|
1958
|
+
<xsl:value-of select="$id"/>
|
1959
|
+
</xsl:attribute>
|
1960
|
+
|
1961
|
+
<xsl:attribute name="playOrder">
|
1962
|
+
<xsl:choose>
|
1963
|
+
<xsl:when test="/*[self::d:set]">
|
1964
|
+
<xsl:value-of select="$order"/>
|
1965
|
+
</xsl:when>
|
1966
|
+
<xsl:when test="$root.is.a.chunk != '0'">
|
1967
|
+
<xsl:value-of select="$order + 1"/>
|
1968
|
+
</xsl:when>
|
1969
|
+
<xsl:otherwise>
|
1970
|
+
<xsl:value-of select="$order - 0"/>
|
1971
|
+
</xsl:otherwise>
|
1972
|
+
</xsl:choose>
|
1973
|
+
</xsl:attribute>
|
1974
|
+
<xsl:element name="navLabel" namespace="{$ncx.namespace}">
|
1975
|
+
<xsl:element name="text" namespace="{$ncx.namespace}"><xsl:value-of select="normalize-space($title)"/> </xsl:element>
|
1976
|
+
</xsl:element>
|
1977
|
+
<xsl:element name="content" namespace="{$ncx.namespace}">
|
1978
|
+
<xsl:attribute name="src">
|
1979
|
+
<xsl:value-of select="$href"/>
|
1980
|
+
</xsl:attribute>
|
1981
|
+
</xsl:element>
|
1982
|
+
<xsl:if test="$depth != 0">
|
1983
|
+
<!-- Don't recurse on root element, but treat it as a single point so
|
1984
|
+
the progress bar shows all top level children -->
|
1985
|
+
<xsl:apply-templates select="d:book[parent::d:set]|d:part|d:reference|d:preface|d:chapter|d:bibliography|d:appendix|d:article|d:topic|d:glossary|d:section|d:sect1|d:sect2|d:sect3|d:sect4|d:sect5|d:refentry|d:colophon|d:bibliodiv[d:title]|d:setindex|d:index" mode="ncx"/>
|
1986
|
+
</xsl:if>
|
1987
|
+
</xsl:element>
|
1988
|
+
|
1989
|
+
</xsl:template>
|
1990
|
+
|
1991
|
+
<xsl:template match="text()" mode="ncx" />
|
1992
|
+
|
1993
|
+
<xsl:template name="package.spine">
|
1994
|
+
|
1995
|
+
<xsl:variable name="toc.params">
|
1996
|
+
<xsl:call-template name="find.path.params">
|
1997
|
+
<xsl:with-param name="node" select="."/>
|
1998
|
+
<xsl:with-param name="table" select="normalize-space($generate.toc)"/>
|
1999
|
+
</xsl:call-template>
|
2000
|
+
</xsl:variable>
|
2001
|
+
|
2002
|
+
<xsl:element namespace="http://www.idpf.org/2007/opf" name="spine">
|
2003
|
+
<xsl:if test="$epub.include.ncx != 0">
|
2004
|
+
<xsl:attribute name="toc">
|
2005
|
+
<xsl:value-of select="$epub.ncx.manifest.id"/>
|
2006
|
+
</xsl:attribute>
|
2007
|
+
</xsl:if>
|
2008
|
+
|
2009
|
+
<xsl:call-template name="spine.cover"/>
|
2010
|
+
|
2011
|
+
|
2012
|
+
<xsl:if test="contains($toc.params, 'toc')">
|
2013
|
+
<xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
|
2014
|
+
<xsl:attribute name="idref"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
|
2015
|
+
<xsl:attribute name="linear">yes</xsl:attribute>
|
2016
|
+
</xsl:element>
|
2017
|
+
</xsl:if>
|
2018
|
+
|
2019
|
+
<!-- TODO: be nice to have a idref="titlepage" here -->
|
2020
|
+
<xsl:choose>
|
2021
|
+
<xsl:when test="$root.is.a.chunk != '0'">
|
2022
|
+
<xsl:apply-templates select="/*" mode="package.spine"/>
|
2023
|
+
</xsl:when>
|
2024
|
+
<xsl:otherwise>
|
2025
|
+
<xsl:apply-templates select="/*/*" mode="package.spine"/>
|
2026
|
+
</xsl:otherwise>
|
2027
|
+
</xsl:choose>
|
2028
|
+
|
2029
|
+
</xsl:element>
|
2030
|
+
</xsl:template>
|
2031
|
+
|
2032
|
+
<xsl:template name="spine.cover">
|
2033
|
+
<xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
|
2034
|
+
<xsl:variable name="cover.image"
|
2035
|
+
select="$info//d:mediaobject[@role='cover' or ancestor::d:cover]"/>
|
2036
|
+
|
2037
|
+
<xsl:if test="$cover.image">
|
2038
|
+
<!-- generate the spine reference to that cover html file -->
|
2039
|
+
<xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
|
2040
|
+
<xsl:attribute name="idref">
|
2041
|
+
<xsl:value-of select="$epub.cover.filename.id"/>
|
2042
|
+
</xsl:attribute>
|
2043
|
+
<xsl:attribute name="linear">
|
2044
|
+
<xsl:choose>
|
2045
|
+
<xsl:when test="$epub.cover.linear">
|
2046
|
+
<xsl:text>yes</xsl:text>
|
2047
|
+
</xsl:when>
|
2048
|
+
<xsl:otherwise>no</xsl:otherwise>
|
2049
|
+
</xsl:choose>
|
2050
|
+
</xsl:attribute>
|
2051
|
+
</xsl:element>
|
2052
|
+
</xsl:if>
|
2053
|
+
</xsl:template>
|
2054
|
+
|
2055
|
+
<xsl:template match="*" mode="package.spine">
|
2056
|
+
<xsl:variable name="is.chunk">
|
2057
|
+
<xsl:call-template name="chunk">
|
2058
|
+
<xsl:with-param name="node" select="."/>
|
2059
|
+
</xsl:call-template>
|
2060
|
+
</xsl:variable>
|
2061
|
+
|
2062
|
+
<xsl:if test="$is.chunk != 0">
|
2063
|
+
<xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
|
2064
|
+
<xsl:attribute name="idref">
|
2065
|
+
<xsl:value-of select="concat($epub.package.id.prefix, generate-id(.))"/>
|
2066
|
+
</xsl:attribute>
|
2067
|
+
</xsl:element>
|
2068
|
+
<xsl:apply-templates select="*|.//d:refentry" mode="package.spine"/>
|
2069
|
+
</xsl:if>
|
2070
|
+
</xsl:template>
|
2071
|
+
|
2072
|
+
<xsl:template match="*" mode="container">
|
2073
|
+
<xsl:call-template name="container"/>
|
2074
|
+
</xsl:template>
|
2075
|
+
|
2076
|
+
<xsl:template name="container">
|
2077
|
+
<!-- The path in rootfile does not include all of base.dir, only the last part -->
|
2078
|
+
<xsl:variable name="full-path-dir">
|
2079
|
+
<xsl:call-template name="filename-basename">
|
2080
|
+
<xsl:with-param name="filename" select="$chunk.base.dir"/>
|
2081
|
+
</xsl:call-template>
|
2082
|
+
</xsl:variable>
|
2083
|
+
<xsl:call-template name="write.chunk">
|
2084
|
+
<xsl:with-param name="filename">
|
2085
|
+
<xsl:value-of select="$epub.container.pathname" />
|
2086
|
+
</xsl:with-param>
|
2087
|
+
<xsl:with-param name="method" select="'xml'" />
|
2088
|
+
<xsl:with-param name="encoding" select="'utf-8'" />
|
2089
|
+
<xsl:with-param name="indent" select="'no'" />
|
2090
|
+
<xsl:with-param name="quiet" select="$chunk.quietly" />
|
2091
|
+
<xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
|
2092
|
+
<xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
|
2093
|
+
|
2094
|
+
<xsl:with-param name="content">
|
2095
|
+
<xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="container">
|
2096
|
+
<xsl:attribute name="version">1.0</xsl:attribute>
|
2097
|
+
<xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfiles">
|
2098
|
+
<xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfile">
|
2099
|
+
<xsl:attribute name="full-path">
|
2100
|
+
<xsl:value-of
|
2101
|
+
select="concat($full-path-dir, $epub.package.filename)"/>
|
2102
|
+
</xsl:attribute>
|
2103
|
+
<xsl:attribute name="media-type">
|
2104
|
+
<xsl:text>application/oebps-package+xml</xsl:text>
|
2105
|
+
</xsl:attribute>
|
2106
|
+
</xsl:element>
|
2107
|
+
</xsl:element>
|
2108
|
+
</xsl:element>
|
2109
|
+
</xsl:with-param>
|
2110
|
+
</xsl:call-template>
|
2111
|
+
</xsl:template>
|
2112
|
+
|
2113
|
+
<xsl:template name="mimetype">
|
2114
|
+
<xsl:call-template name="write.text.chunk">
|
2115
|
+
<xsl:with-param name="filename" select="$epub.mimetype.pathname"/>
|
2116
|
+
<xsl:with-param name="content" select="$epub.mimetype.value"/>
|
2117
|
+
</xsl:call-template>
|
2118
|
+
</xsl:template>
|
2119
|
+
|
2120
|
+
<xsl:template match="d:mediaobject[@role='cover' or ancestor::d:cover]">
|
2121
|
+
<xsl:call-template name="write.chunk">
|
2122
|
+
<xsl:with-param name="filename">
|
2123
|
+
<xsl:value-of select="$epub.cover.pathname" />
|
2124
|
+
</xsl:with-param>
|
2125
|
+
<xsl:with-param name="method" select="'xml'" />
|
2126
|
+
<xsl:with-param name="encoding" select="'utf-8'" />
|
2127
|
+
<xsl:with-param name="indent" select="'no'" />
|
2128
|
+
<xsl:with-param name="quiet" select="$chunk.quietly" />
|
2129
|
+
<xsl:with-param name="content">
|
2130
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="html">
|
2131
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="head">
|
2132
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="title">Cover</xsl:element>
|
2133
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="style">
|
2134
|
+
<xsl:attribute name="type">text/css</xsl:attribute>
|
2135
|
+
<!-- Help the cover image scale nicely in the CSS then apply a max-width to look better in Adobe Digital Editions -->
|
2136
|
+
<xsl:text> img { max-width: 100%; }</xsl:text>
|
2137
|
+
</xsl:element>
|
2138
|
+
</xsl:element>
|
2139
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="body">
|
2140
|
+
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="div">
|
2141
|
+
<xsl:attribute name="id">
|
2142
|
+
<xsl:value-of select="$epub.cover.image.id"/>
|
2143
|
+
</xsl:attribute>
|
2144
|
+
<xsl:choose>
|
2145
|
+
<xsl:when test="d:imageobject[@role='front-large']">
|
2146
|
+
<xsl:apply-templates select="d:imageobject[@role='front-large']"/>
|
2147
|
+
</xsl:when>
|
2148
|
+
<xsl:otherwise>
|
2149
|
+
<xsl:apply-templates select="d:imageobject[1]"/>
|
2150
|
+
</xsl:otherwise>
|
2151
|
+
</xsl:choose>
|
2152
|
+
</xsl:element>
|
2153
|
+
<!-- If this is defined as an explicit cover page, then process
|
2154
|
+
any remaining text -->
|
2155
|
+
<xsl:if test="ancestor::d:cover">
|
2156
|
+
<xsl:apply-templates select="ancestor::d:cover/d:para"/>
|
2157
|
+
</xsl:if>
|
2158
|
+
</xsl:element>
|
2159
|
+
</xsl:element>
|
2160
|
+
</xsl:with-param>
|
2161
|
+
</xsl:call-template>
|
2162
|
+
</xsl:template>
|
2163
|
+
|
2164
|
+
<!-- EPUB3: use <nav> and <ol> in TOC lists -->
|
2165
|
+
<xsl:template name="make.toc">
|
2166
|
+
<xsl:param name="toc-context" select="."/>
|
2167
|
+
<xsl:param name="toc.title.p" select="true()"/>
|
2168
|
+
<xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
|
2169
|
+
|
2170
|
+
<xsl:variable name="nodes.plus" select="$nodes | d:qandaset"/>
|
2171
|
+
|
2172
|
+
<xsl:variable name="toc.title">
|
2173
|
+
<xsl:if test="$toc.title.p">
|
2174
|
+
<xsl:choose>
|
2175
|
+
<xsl:when test="$make.clean.html != 0">
|
2176
|
+
<div class="toc-title">
|
2177
|
+
<xsl:call-template name="gentext">
|
2178
|
+
<xsl:with-param name="key">TableofContents</xsl:with-param>
|
2179
|
+
</xsl:call-template>
|
2180
|
+
</div>
|
2181
|
+
</xsl:when>
|
2182
|
+
<xsl:otherwise>
|
2183
|
+
<p>
|
2184
|
+
<b>
|
2185
|
+
<xsl:call-template name="gentext">
|
2186
|
+
<xsl:with-param name="key">TableofContents</xsl:with-param>
|
2187
|
+
</xsl:call-template>
|
2188
|
+
</b>
|
2189
|
+
</p>
|
2190
|
+
</xsl:otherwise>
|
2191
|
+
</xsl:choose>
|
2192
|
+
</xsl:if>
|
2193
|
+
</xsl:variable>
|
2194
|
+
|
2195
|
+
<xsl:choose>
|
2196
|
+
<xsl:when test="$manual.toc != ''">
|
2197
|
+
<xsl:variable name="id">
|
2198
|
+
<xsl:call-template name="object.id"/>
|
2199
|
+
</xsl:variable>
|
2200
|
+
<xsl:variable name="toc" select="document($manual.toc, .)"/>
|
2201
|
+
<xsl:variable name="tocentry" select="$toc//d:tocentry[@linkend=$id]"/>
|
2202
|
+
<xsl:if test="$tocentry and $tocentry/*">
|
2203
|
+
<div class="toc">
|
2204
|
+
<xsl:copy-of select="$toc.title"/>
|
2205
|
+
<nav epub:type="toc">
|
2206
|
+
<xsl:element name="{$toc.list.type}">
|
2207
|
+
<xsl:call-template name="manual-toc">
|
2208
|
+
<xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
|
2209
|
+
</xsl:call-template>
|
2210
|
+
</xsl:element>
|
2211
|
+
</nav>
|
2212
|
+
</div>
|
2213
|
+
</xsl:if>
|
2214
|
+
</xsl:when>
|
2215
|
+
<xsl:otherwise>
|
2216
|
+
<xsl:choose>
|
2217
|
+
<xsl:when test="$qanda.in.toc != 0">
|
2218
|
+
<div class="toc">
|
2219
|
+
<xsl:copy-of select="$toc.title"/>
|
2220
|
+
<nav epub:type="toc">
|
2221
|
+
<xsl:element name="{$toc.list.type}">
|
2222
|
+
<xsl:if test="$nodes.plus">
|
2223
|
+
<xsl:apply-templates select="$nodes.plus" mode="toc">
|
2224
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2225
|
+
</xsl:apply-templates>
|
2226
|
+
</xsl:if>
|
2227
|
+
</xsl:element>
|
2228
|
+
</nav>
|
2229
|
+
</div>
|
2230
|
+
</xsl:when>
|
2231
|
+
<xsl:otherwise>
|
2232
|
+
<div class="toc">
|
2233
|
+
<xsl:copy-of select="$toc.title"/>
|
2234
|
+
<nav epub:type="toc">
|
2235
|
+
<xsl:element name="{$toc.list.type}">
|
2236
|
+
<xsl:if test="$nodes">
|
2237
|
+
<xsl:apply-templates select="$nodes" mode="toc">
|
2238
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2239
|
+
</xsl:apply-templates>
|
2240
|
+
</xsl:if>
|
2241
|
+
</xsl:element>
|
2242
|
+
</nav>
|
2243
|
+
</div>
|
2244
|
+
</xsl:otherwise>
|
2245
|
+
</xsl:choose>
|
2246
|
+
|
2247
|
+
</xsl:otherwise>
|
2248
|
+
</xsl:choose>
|
2249
|
+
</xsl:template>
|
2250
|
+
|
2251
|
+
<xsl:template name="list.of.titles">
|
2252
|
+
<xsl:param name="toc-context" select="."/>
|
2253
|
+
<xsl:param name="titles" select="'table'"/>
|
2254
|
+
<xsl:param name="nodes" select=".//d:table"/>
|
2255
|
+
|
2256
|
+
<xsl:variable name="epub.type">
|
2257
|
+
<xsl:choose>
|
2258
|
+
<xsl:when test="$titles='table'">lot</xsl:when>
|
2259
|
+
<xsl:when test="$titles='figure'">loi</xsl:when>
|
2260
|
+
<xsl:when test="$titles='equation'">loi</xsl:when>
|
2261
|
+
<xsl:when test="$titles='example'">loi</xsl:when>
|
2262
|
+
<xsl:when test="$titles='procedure'">loi</xsl:when>
|
2263
|
+
<xsl:otherwise>loi</xsl:otherwise>
|
2264
|
+
</xsl:choose>
|
2265
|
+
</xsl:variable>
|
2266
|
+
|
2267
|
+
<xsl:if test="$nodes">
|
2268
|
+
<div class="list-of-{$titles}s">
|
2269
|
+
<nav epub:type="{$epub.type}">
|
2270
|
+
<h4 class="toc-title">
|
2271
|
+
<xsl:call-template name="gentext">
|
2272
|
+
<xsl:with-param name="key">
|
2273
|
+
<xsl:choose>
|
2274
|
+
<xsl:when test="$titles='table'">ListofTables</xsl:when>
|
2275
|
+
<xsl:when test="$titles='figure'">ListofFigures</xsl:when>
|
2276
|
+
<xsl:when test="$titles='equation'">ListofEquations</xsl:when>
|
2277
|
+
<xsl:when test="$titles='example'">ListofExamples</xsl:when>
|
2278
|
+
<xsl:when test="$titles='procedure'">ListofProcedures</xsl:when>
|
2279
|
+
<xsl:otherwise>ListofUnknown</xsl:otherwise>
|
2280
|
+
</xsl:choose>
|
2281
|
+
</xsl:with-param>
|
2282
|
+
</xsl:call-template>
|
2283
|
+
</h4>
|
2284
|
+
|
2285
|
+
<xsl:element name="{$toc.list.type}">
|
2286
|
+
<xsl:apply-templates select="$nodes" mode="toc">
|
2287
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2288
|
+
</xsl:apply-templates>
|
2289
|
+
</xsl:element>
|
2290
|
+
</nav>
|
2291
|
+
</div>
|
2292
|
+
</xsl:if>
|
2293
|
+
</xsl:template>
|
2294
|
+
|
2295
|
+
<!-- EPUB3: add hidden="" for sections below toc.section.depth -->
|
2296
|
+
<xsl:template name="subtoc">
|
2297
|
+
<xsl:param name="toc-context" select="."/>
|
2298
|
+
<xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
|
2299
|
+
|
2300
|
+
<xsl:variable name="nodes.plus" select="$nodes | d:qandaset"/>
|
2301
|
+
|
2302
|
+
<xsl:variable name="depth">
|
2303
|
+
<xsl:choose>
|
2304
|
+
<xsl:when test="local-name(.) = 'section'">
|
2305
|
+
<xsl:value-of select="count(ancestor::d:section) + 1"/>
|
2306
|
+
</xsl:when>
|
2307
|
+
<xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
|
2308
|
+
<xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
|
2309
|
+
<xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
|
2310
|
+
<xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
|
2311
|
+
<xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
|
2312
|
+
<xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
|
2313
|
+
<xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
|
2314
|
+
<xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
|
2315
|
+
<xsl:when test="local-name(.) = 'simplesect'">
|
2316
|
+
<!-- sigh... -->
|
2317
|
+
<xsl:choose>
|
2318
|
+
<xsl:when test="local-name(..) = 'section'">
|
2319
|
+
<xsl:value-of select="count(ancestor::d:section)"/>
|
2320
|
+
</xsl:when>
|
2321
|
+
<xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
|
2322
|
+
<xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
|
2323
|
+
<xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
|
2324
|
+
<xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
|
2325
|
+
<xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
|
2326
|
+
<xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
|
2327
|
+
<xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
|
2328
|
+
<xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
|
2329
|
+
<xsl:otherwise>1</xsl:otherwise>
|
2330
|
+
</xsl:choose>
|
2331
|
+
</xsl:when>
|
2332
|
+
<xsl:otherwise>0</xsl:otherwise>
|
2333
|
+
</xsl:choose>
|
2334
|
+
</xsl:variable>
|
2335
|
+
|
2336
|
+
<xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
|
2337
|
+
|
2338
|
+
<xsl:variable name="subtoc">
|
2339
|
+
<xsl:element name="{$toc.list.type}">
|
2340
|
+
<xsl:choose>
|
2341
|
+
<xsl:when test="$toc.listitem.type = 'li'
|
2342
|
+
and $toc.section.depth > $depth and
|
2343
|
+
( ($qanda.in.toc = 0 and count($nodes)>0) or
|
2344
|
+
($qanda.in.toc != 0 and count($nodes.plus)>0) )
|
2345
|
+
and $toc.max.depth > $depth.from.context">
|
2346
|
+
<!-- No @hidden attribute -->
|
2347
|
+
</xsl:when>
|
2348
|
+
<xsl:otherwise>
|
2349
|
+
<!-- Add empty @hidden attribute if too deep -->
|
2350
|
+
<xsl:attribute name="hidden"></xsl:attribute>
|
2351
|
+
</xsl:otherwise>
|
2352
|
+
</xsl:choose>
|
2353
|
+
|
2354
|
+
<xsl:choose>
|
2355
|
+
<xsl:when test="$qanda.in.toc != 0">
|
2356
|
+
<xsl:apply-templates mode="toc" select="$nodes.plus">
|
2357
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2358
|
+
</xsl:apply-templates>
|
2359
|
+
</xsl:when>
|
2360
|
+
<xsl:otherwise>
|
2361
|
+
<xsl:apply-templates mode="toc" select="$nodes">
|
2362
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2363
|
+
</xsl:apply-templates>
|
2364
|
+
</xsl:otherwise>
|
2365
|
+
</xsl:choose>
|
2366
|
+
</xsl:element>
|
2367
|
+
</xsl:variable>
|
2368
|
+
|
2369
|
+
<xsl:variable name="subtoc.list">
|
2370
|
+
<xsl:choose>
|
2371
|
+
<xsl:when test="$toc.dd.type = ''">
|
2372
|
+
<xsl:copy-of select="$subtoc"/>
|
2373
|
+
</xsl:when>
|
2374
|
+
<xsl:otherwise>
|
2375
|
+
<xsl:element name="{$toc.dd.type}">
|
2376
|
+
<xsl:copy-of select="$subtoc"/>
|
2377
|
+
</xsl:element>
|
2378
|
+
</xsl:otherwise>
|
2379
|
+
</xsl:choose>
|
2380
|
+
</xsl:variable>
|
2381
|
+
|
2382
|
+
<xsl:element name="{$toc.listitem.type}">
|
2383
|
+
<xsl:call-template name="toc.line">
|
2384
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2385
|
+
</xsl:call-template>
|
2386
|
+
<xsl:if test="$toc.listitem.type = 'li'
|
2387
|
+
and
|
2388
|
+
( ($qanda.in.toc = 0 and count($nodes)>0) or
|
2389
|
+
($qanda.in.toc != 0 and count($nodes.plus)>0) ) ">
|
2390
|
+
<xsl:copy-of select="$subtoc.list"/>
|
2391
|
+
</xsl:if>
|
2392
|
+
</xsl:element>
|
2393
|
+
</xsl:template>
|
2394
|
+
|
2395
|
+
<!-- Inserted when a title is blank to avoid epubcheck error -->
|
2396
|
+
<xsl:param name="toc.entry.default.text"> </xsl:param>
|
2397
|
+
|
2398
|
+
<!-- EPUB3: either <a> or <span>, but not both -->
|
2399
|
+
<xsl:template name="toc.line">
|
2400
|
+
<xsl:param name="toc-context" select="."/>
|
2401
|
+
<xsl:param name="depth" select="1"/>
|
2402
|
+
<xsl:param name="depth.from.context" select="8"/>
|
2403
|
+
|
2404
|
+
<xsl:variable name="title">
|
2405
|
+
<xsl:apply-templates select="." mode="title.markup"/>
|
2406
|
+
</xsl:variable>
|
2407
|
+
|
2408
|
+
<a>
|
2409
|
+
<xsl:attribute name="href">
|
2410
|
+
<xsl:call-template name="href.target">
|
2411
|
+
<xsl:with-param name="context" select="$toc-context"/>
|
2412
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2413
|
+
</xsl:call-template>
|
2414
|
+
</xsl:attribute>
|
2415
|
+
|
2416
|
+
<!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
|
2417
|
+
<!-- * as part of the hyperlinked title -->
|
2418
|
+
<xsl:if test="not($autotoc.label.in.hyperlink = 0)">
|
2419
|
+
<xsl:variable name="label">
|
2420
|
+
<xsl:apply-templates select="." mode="label.markup"/>
|
2421
|
+
</xsl:variable>
|
2422
|
+
<xsl:copy-of select="$label"/>
|
2423
|
+
<xsl:if test="$label != ''">
|
2424
|
+
<xsl:value-of select="$autotoc.label.separator"/>
|
2425
|
+
</xsl:if>
|
2426
|
+
</xsl:if>
|
2427
|
+
|
2428
|
+
<xsl:choose>
|
2429
|
+
<xsl:when test="string-length(normalize-space($title)) != 0">
|
2430
|
+
<xsl:copy-of select="$title"/>
|
2431
|
+
</xsl:when>
|
2432
|
+
<xsl:otherwise>
|
2433
|
+
<xsl:value-of select="$toc.entry.default.text"/>
|
2434
|
+
</xsl:otherwise>
|
2435
|
+
</xsl:choose>
|
2436
|
+
</a>
|
2437
|
+
</xsl:template>
|
2438
|
+
|
2439
|
+
<!-- Make sure all text is inside the <a> element for epub3 -->
|
2440
|
+
<xsl:template match="d:figure|d:table|d:example|d:equation|d:procedure" mode="toc">
|
2441
|
+
<xsl:param name="toc-context" select="."/>
|
2442
|
+
|
2443
|
+
<xsl:element name="{$toc.listitem.type}">
|
2444
|
+
<a>
|
2445
|
+
<xsl:attribute name="href">
|
2446
|
+
<xsl:call-template name="href.target">
|
2447
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2448
|
+
</xsl:call-template>
|
2449
|
+
</xsl:attribute>
|
2450
|
+
<xsl:variable name="label">
|
2451
|
+
<xsl:apply-templates select="." mode="label.markup"/>
|
2452
|
+
</xsl:variable>
|
2453
|
+
<xsl:copy-of select="$label"/>
|
2454
|
+
<xsl:if test="$label != ''">
|
2455
|
+
<xsl:value-of select="$autotoc.label.separator"/>
|
2456
|
+
</xsl:if>
|
2457
|
+
<xsl:apply-templates select="." mode="titleabbrev.markup"/>
|
2458
|
+
</a>
|
2459
|
+
</xsl:element>
|
2460
|
+
</xsl:template>
|
2461
|
+
|
2462
|
+
<!-- Remove spans from refentry TOC lines for epub3check -->
|
2463
|
+
<xsl:template match="d:refentry" mode="toc">
|
2464
|
+
<xsl:param name="toc-context" select="."/>
|
2465
|
+
|
2466
|
+
<xsl:variable name="refmeta" select=".//d:refmeta"/>
|
2467
|
+
<xsl:variable name="refentrytitle" select="$refmeta//d:refentrytitle"/>
|
2468
|
+
<xsl:variable name="refnamediv" select=".//d:refnamediv"/>
|
2469
|
+
<xsl:variable name="refname" select="$refnamediv//d:refname"/>
|
2470
|
+
<xsl:variable name="refdesc" select="$refnamediv//d:refdescriptor"/>
|
2471
|
+
<xsl:variable name="title">
|
2472
|
+
<xsl:choose>
|
2473
|
+
<xsl:when test="$refentrytitle">
|
2474
|
+
<xsl:apply-templates select="$refentrytitle[1]" mode="titleabbrev.markup"/>
|
2475
|
+
</xsl:when>
|
2476
|
+
<xsl:when test="$refdesc">
|
2477
|
+
<xsl:apply-templates select="$refdesc" mode="titleabbrev.markup"/>
|
2478
|
+
</xsl:when>
|
2479
|
+
<xsl:when test="$refname">
|
2480
|
+
<xsl:apply-templates select="$refname[1]" mode="titleabbrev.markup"/>
|
2481
|
+
</xsl:when>
|
2482
|
+
</xsl:choose>
|
2483
|
+
</xsl:variable>
|
2484
|
+
|
2485
|
+
<xsl:element name="{$toc.listitem.type}" namespace="http://www.w3.org/1999/xhtml">
|
2486
|
+
<a>
|
2487
|
+
<xsl:attribute name="href">
|
2488
|
+
<xsl:call-template name="href.target">
|
2489
|
+
<xsl:with-param name="toc-context" select="$toc-context"/>
|
2490
|
+
</xsl:call-template>
|
2491
|
+
</xsl:attribute>
|
2492
|
+
<xsl:copy-of select="$title"/>
|
2493
|
+
<xsl:if test="$annotate.toc != 0">
|
2494
|
+
<!-- * DocBook 5 says inlinemediaobject (among other things) -->
|
2495
|
+
<!-- * is allowed in refpurpose; so we need to run -->
|
2496
|
+
<!-- * apply-templates on refpurpose here, instead of value-of -->
|
2497
|
+
<!-- Set allow-anchors=0 to avoid indexterms and other links -->
|
2498
|
+
<xsl:text> - </xsl:text>
|
2499
|
+
<xsl:apply-templates select="d:refnamediv/d:refpurpose" mode="no.anchor.mode"/>
|
2500
|
+
</xsl:if>
|
2501
|
+
</a>
|
2502
|
+
</xsl:element>
|
2503
|
+
</xsl:template>
|
2504
|
+
|
2505
|
+
<!-- Copy these here so relative document() open gets the correct css source -->
|
2506
|
+
<xsl:template name="generate.default.css.file">
|
2507
|
+
<xsl:if test="$make.clean.html != 0 and
|
2508
|
+
$generate.css.header = 0 and
|
2509
|
+
$docbook.css.source != ''">
|
2510
|
+
<!-- Select default file relative to stylesheet -->
|
2511
|
+
<xsl:variable name="css.node" select="document($docbook.css.source)/*[1]"/>
|
2512
|
+
|
2513
|
+
<xsl:call-template name="generate.css.file">
|
2514
|
+
<xsl:with-param name="src" select="$docbook.css.source"/>
|
2515
|
+
<xsl:with-param name="css.node" select="$css.node"/>
|
2516
|
+
</xsl:call-template>
|
2517
|
+
</xsl:if>
|
2518
|
+
</xsl:template>
|
2519
|
+
|
2520
|
+
<xsl:template name="generate.custom.css.file">
|
2521
|
+
<xsl:if test="$custom.css.source != '' and
|
2522
|
+
$generate.css.header = 0">
|
2523
|
+
<!-- Select custom file relative to document -->
|
2524
|
+
<xsl:variable name="css.node" select="document($custom.css.source,.)/*[1]"/>
|
2525
|
+
|
2526
|
+
<xsl:call-template name="generate.css.file">
|
2527
|
+
<xsl:with-param name="src" select="$custom.css.source"/>
|
2528
|
+
<xsl:with-param name="css.node" select="$css.node"/>
|
2529
|
+
</xsl:call-template>
|
2530
|
+
</xsl:if>
|
2531
|
+
</xsl:template>
|
2532
|
+
|
2533
|
+
</xsl:stylesheet>
|