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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
DocBook stylesheets for EPUB 3 output
=============================================
This directory contains XSL stylesheets
for generating EPUB3 output from DocBook content.
For more information on EPUB3, see:
http://idpf.org/epub/30
These EPUB3 stylesheets are a customization layer on
top of the xhtml5/ stylesheets in this distribution, which
are in turn a customization layer on top of the
xhtml/ stylesheets in this distribution.
Using a customization layer enables the EPUB3
stylesheets to inherit all the features of the
XHTML stylesheets while making the minimum changes
for them to produce valid EPUB3.
Usage
-----------
The general process for creating an EPUB3 ebook is:
1. Generate chunked XHTML5 content that validates against
the EPUB3 schemas, and generate the EPUB3 package
files.
2. Copy any image files into the output directory.
3. Run a zip command to create an .epub file.
4. Validate the .epub file.
Following are the steps in more detail.
1. Create the XHTML5 files.
-----------------------------
The first step is handled by these stylesheets.
To generate EPUB3-compatible XHTML5 files,
use one of the following stylesheets as you would any
other DocBook XSL stylesheet:
epub3/chunk.xsl - Chunked output.
epub3/profile-chunk.xsl - Profiled chunk output.
Although the stylesheet directory contains a docbook.xsl
stylesheet for single file output, that is not useful for
generated EPUB3.
You should set the $base.dir stylesheet param to the
subdirectory that will contain the .xhtml files and
the epub package files. Here is an example using xsltproc:
xsltproc \
--stringparam base.dir ebook1/OEBPS/ \
epub3/chunk.xsl \
mybook.xml
After processing a document with this setting, you should find
the following output:
ebook1/mimetype - required mimetype file.
ebook1/META-INF/container.xml - required container file
ebook1/OEBPS/package.opf - required package file
ebook1/OEBPS/toc.ncx - optional NCX file for backwards compatibility
ebook1/OEBPS/docbook-epub.css - CSS file
ebook1/OEBPS/*.xhtml - The chunked content files.
2. Copy image files
---------------------------
Manually copy any image files used in the document
into the corresponding locations in the $base.dir
directory. For example, if your document contains:
<imagedata fileref="images/caution.png"/>
In this example base.dir, you would copy the file to:
ebook1/OEBPS/images/caution.png
You can get a list of image files from the manifest file
named ebook1/OEBPS/package.opf that is created by the
stylesheet. It includes references to image files for
callouts and admonitions if they are used in the output.
Note that the header and footer images are turned off for
EPUB3 output.
3. Create the epub3 file.
-----------------------------
Change to the directory containing the base.dir (ebook1
in this example), and run the following zip command to
create the epub file:
zip -r -X mybook.epub mimetype META-INF OEBPS
The -r option means recursively include all directories.
The -X option excludes extra file attributes (required by epub3).
The "mybook.epub" in this example is the output file.
The other three arguments must appear in this order.
4. Validating with epubcheck 3
-----------------------------------
There is a java program that can be used to check an
epub3 file for conformance. It is currently available
from this website:
http://code.google.com/p/epubcheck/wiki/EPUBCheck30
That website provides a download link, and information on
how to run the command.
Testing with EPUB readers
----------------------------
The EPUB3 standard is not yet widely supported. The output of
these stylesheets has been tested in the following readers:
Apple iBooks on an iPod and iPad.
- Handles videodata and audiodata.
- Does not format MathML yet.
- Handles SVG.
Firefox browser with the EPUBReader version 1.4.10 add-on.
- Formats MathML nicely.
- Does not handle videodata or audiodata yet.
- Handles SVG.
Ibis EPUB3 preview version
- Does not format MathML yet.
- Does not handle videodata or audiodata yet.
- Handles SVG with external viewer.
EPUB metadata
========================
The info child of the document's root element is used
by the stylesheet to create EPUB metadata. Note that
metadata is plain text, so element content is converted
to text using the XSL normalize-space() function.
Here is the current mapping of info elements to EPUB
metadata. Any others are ignored for metadata, but
may appear on the EPUB HTML titlepage, depending on the
titlepage customization.
NOTE: the <dc:*> elements (not attributes of meta) duplicate
the meta elements for backwards compatibility, per the
EPUB3 specification. They can be turned off with the
$epub.include.optional.metadata.dc.elements parameter.
abstract
---------
The content must be converted to a text string for the
OPF metadata. The stylesheet converts only title, para,
formalpara, and simpara children in an abstract. All other
child elements are ignored. It puts any title first.
The OPF output appears as:
<meta property="dcterms:description">title: abstract text</meta>
<dc:description>title: abstract text</dc:description>
author
-------
If uses a personname child, then it applies the
DocBook XSL person.name template to arrange the name.
Otherwise processes org or orgname into the content.
Then it outputs:
<meta id="meta-creator1" property="dcterms:creator">Firstname Surname</meta>
<dc:creator id="pub-creator1">Firstname Surname</dc:creator>
If there are multiple authors, the number in the id attribute
is incremented each time.
authorgroup
-------------
Applies templates to all of its children.
bibliocoverage
---------------
<meta property="dcterms:coverage">bibliocoverage text</meta>
<dc:coverage>bibliocoverage text</dc:coverage>
biblioid
--------------
This usually has @class="isbn" for the ISBN number. It is used
as the EPUB3 unique-identifier. That isbn value
is also output as follows:
<meta id="meta-identifier" property="dcterms:identifier">urn:isbn:value</meta>
<dc:identifier id="pub-identifier">urn:isbn:value</dc:identifier>
A biblioid element with other class names are converted in a similar manner.
bibliorelation
----------------
<meta property="dcterms:relation">bibliorelation text</meta>
<dc:relation>bibliorelation text</dc:relation>
bibliosource
----------------
<meta property="dcterms:source">bibliosource text</meta>
<dc:source>bibliosource text</dc:source>
collab
------------
If a personname child is used, then it calls the
person.name template, otherwise is uses the orgname or
collabname text.
<meta property="dcterms:contributor">collab text</meta>
<dc:contributor>collab text</dc:contributor>
copyright
-------------
Arranges the copyright elements into a text string with
copyright symbol, dates, and holder, and then
generates:
<meta property="dcterms:right">Copyright text</meta>
<dc:right>Copyright text</dc:right>
Also, if there is no info/date element, then the copyright
year is used to generate:
<meta property="dcterms:date">year</meta>
<dc:date>year</dc:date>
corpauthor
------------
<meta id="meta-creator1" property="dcterms:creator">corpauthor text</meta>
<dc:creator id="pub-creator1">corpauthor text</dc:creator>
corpcredit
------------
<meta property="dcterms:contributor">corpcredit text</meta>
<dc:contributor>corpcredit text</dc:contributor>
date
-------------
<meta property="dcterms:date">date text</meta>
<dc:date>date text</dc:date>
See also: copyright.
editor
--------------
If a personname child is used, then it calls the
person.name template, otherwise is uses the orgname text.
An editor can be considered as either a creator (when there
is no author) or a contributor. The stylesheet parameter
'editor.property' can be set to either 'creator' or
'contributor' (default) at runtime. So the output is either:
<meta property="dcterms:contributor">editor text</meta>
<dc:contributor>editor text</dc:contributor>
or
<meta property="dcterms:creator">editor text</meta>
<dc:creator>editor text</dc:creator>
isbn, issn, etc.
-----------------
Handled like biblioid @class="isbn".
keyword
-----------
<meta property="dcterms:subject">keyword text</meta>
<dc:subject>keyword text</dc:subject>
keywordset
------------
Applies templates to its children.
othercredit
------------
Handled like collab.
pubdate
------------
Handled like date.
publisher
--------------
Applies templates only to publishername.
publishername
---------------
<meta property="dcterms:publisher">publishername text</meta>
<dc:publisher>publishername text</dc:publisher>
subjectset
--------------
Applies templates to subject/subjecterm descendants.
subjectterm
------------------
<meta property="dcterms:subject">subjecterm text</meta>
<dc:subject>subjecterm text</dc:subject>
|