-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtei2epub.xsl
187 lines (152 loc) · 6.9 KB
/
tei2epub.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="3.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="urn:stylesheet-functions"
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="f xd">
<xd:doc type="stylesheet">
<xd:short>TEI stylesheet to convert a TEI document to ePub.</xd:short>
<xd:detail>This stylesheet is the main entry point for the TEI to ePub conversion. It contains no
templates itself, but collects all stylesheets, and sets several global variables.</xd:detail>
<xd:author>Jeroen Hellingman</xd:author>
<xd:copyright>2012, Jeroen Hellingman</xd:copyright>
</xd:doc>
<xsl:include href="modules/functions.xsl"/>
<xsl:include href="modules/utils.xsl"/>
<xsl:include href="modules/utils.epub.xsl"/>
<xsl:include href="modules/betacode.xsl"/>
<xsl:include href="modules/spellout.xsl"/>
<xsl:include href="modules/configuration.xsl"/>
<xsl:include href="modules/log.xsl"/>
<xsl:include href="modules/localization.xsl"/>
<xsl:include href="modules/header.xsl"/>
<xsl:include href="modules/inline.xsl"/>
<xsl:include href="modules/rend.xsl"/>
<xsl:include href="modules/css.xsl"/>
<xsl:include href="modules/references.xsl"/>
<xsl:include href="modules/titlepage.xsl"/>
<xsl:include href="modules/block.xsl"/>
<xsl:include href="modules/notes.xsl"/>
<xsl:include href="modules/numbers.xsl"/>
<xsl:include href="modules/drama.xsl"/>
<xsl:include href="modules/contents.xsl"/>
<xsl:include href="modules/index.xsl"/>
<xsl:include href="modules/divisions.xsl"/>
<xsl:include href="modules/splitter.xsl"/>
<xsl:include href="modules/tables.xsl"/>
<xsl:include href="modules/lists.xsl"/>
<xsl:include href="modules/formulas.xsl"/>
<xsl:include href="modules/figures.xsl"/>
<xsl:include href="modules/colophon.xsl"/>
<xsl:include href="modules/gutenberg.xsl"/>
<xsl:include href="modules/facsimile.xsl"/>
<xsl:include href="modules/stripns.xsl"/>
<xsl:include href="modules/variables.xsl"/>
<xsl:include href="modules/tei2opf.xsl"/>
<xsl:include href="modules/tei2ncx.xsl"/>
<xsl:include href="modules/tei2epubnav.xsl"/>
<xsl:output name="xhtml"
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
method="xml"
encoding="utf-8"/>
<xsl:output name="xml"
doctype-public=""
doctype-system=""
method="xml"
indent="yes"
encoding="utf-8"/>
<xsl:output name="xml-noindent"
doctype-public=""
doctype-system=""
method="xml"
indent="no"
encoding="utf-8"/>
<xsl:output
method="xml"
doctype-system="about:legacy-compat"
encoding="utf-8"
indent="no"/>
<!--====================================================================-->
<xsl:param name="basename" select="'book'"/>
<xsl:param name="path" select="'ePub'"/>
<xsl:param name="epubversion" select="'3.0.1'"/> <!-- Values: '3.1' or '3.0.1' -->
<xsl:param name="optionPrinceMarkup" select="'No'"/> <!-- Should always be 'No' for ePub -->
<!--====================================================================-->
<xsl:variable name="mimeType" select="'application/xhtml+xml'"/>
<xsl:variable name="encoding" select="document('')/xsl:stylesheet/xsl:output[not(@name)]/@encoding"/>
<xsl:variable name="outputMethod" select="document('')/xsl:stylesheet/xsl:output/@method"/>
<xsl:variable name="outputFormat" select="'epub'"/>
<xsl:variable name="p.element" select="'p'"/>
<!--====================================================================-->
<xd:doc>
<xd:short>Main stylesheet for ePub generation.</xd:short>
<xd:detail>
<p>This XSLT-stylesheet is intended to be the first triggered, and will initiate
generation of various ePub elements.</p>
</xd:detail>
</xd:doc>
<xsl:template match="/">
<xsl:call-template name="mimetype"/>
<xsl:call-template name="container"/>
<xsl:call-template name="external-css-stylesheets"/>
<xsl:call-template name="copy-smil-files"/>
<xsl:apply-templates mode="opf"/>
<xsl:apply-templates mode="ncx"/>
<xsl:apply-templates mode="ePubNav"/>
<xsl:apply-templates/>
</xsl:template>
<!--====================================================================-->
<!-- Mimetype file -->
<xd:doc>
<xd:short>Generate the file with the ePub mimetype: application/epub+zip.</xd:short>
</xd:doc>
<xsl:template name="mimetype">
<xsl:result-document
href="{$path}/mimetype"
method="text"
encoding="UTF-8">
<xsl:copy-of select="f:log-info('Generated file: {1}/mimetype.', ($path))"/>
<xsl:text>application/epub+zip</xsl:text>
</xsl:result-document>
</xsl:template>
<!--====================================================================-->
<!-- Container file -->
<xd:doc>
<xd:short>Generate the container file which points to the OPF file, as required by ePub.</xd:short>
</xd:doc>
<xsl:template name="container">
<xsl:result-document format="xml" href="{$path}/META-INF/container.xml">
<xsl:copy-of select="f:log-info('Generated container file: {1}/META-INF/container.xml.', ($path))"/>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="{$basename}.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
</xsl:result-document>
</xsl:template>
<!--====================================================================-->
<!-- SMIL files -->
<xd:doc>
<xd:short>Collect all SMIL-files with media-overlays, and copy them into the output.</xd:short>
</xd:doc>
<xsl:template name="copy-smil-files">
<xsl:for-each select="//*[f:has-rend-value(@rend, 'media-overlay')]">
<xsl:call-template name="copy-xml-file">
<xsl:with-param name="filename" select="f:rend-value(@rend, 'media-overlay')"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!--====================================================================-->
<!-- Cover -->
<xsl:template name="cover">
<xsl:result-document
href="{$path}/cover.xhtml"
method="xml"
encoding="UTF-8">
<xsl:copy-of select="f:log-info('Generated cover file: {1}/cover.xhtml.', ($path))"/>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>