1 DocBook stylesheets for EPUB 3 output
2 =============================================
4 This directory contains XSL stylesheets
5 for generating EPUB3 output from DocBook content.
6 For more information on EPUB3, see:
8 http://idpf.org/epub/30
10 These EPUB3 stylesheets are a customization layer on
11 top of the xhtml5/ stylesheets in this distribution, which
12 are in turn a customization layer on top of the
13 xhtml/ stylesheets in this distribution.
14 Using a customization layer enables the EPUB3
15 stylesheets to inherit all the features of the
16 XHTML stylesheets while making the minimum changes
17 for them to produce valid EPUB3.
19 If you need to customize the epub3 stylesheet, see the section
20 below titled "Customizing the epub3 stylesheet".
24 The general process for creating an EPUB3 ebook is:
26 1. Generate chunked XHTML5 content that validates against
27 the EPUB3 schemas, and generate the EPUB3 package
30 2. Copy any image files into the output directory.
32 3. Run a zip command to create an .epub file.
34 4. Validate the .epub file.
37 Following are the steps in more detail.
39 1. Create the XHTML5 files.
40 -----------------------------
42 The first step is handled by these stylesheets.
43 To generate EPUB3-compatible XHTML5 files,
44 use one of the following stylesheets as you would any
45 other DocBook XSL stylesheet:
47 epub3/chunk.xsl - Chunked output.
48 epub3/profile-chunk.xsl - Profiled chunk output.
50 Although the stylesheet directory contains a docbook.xsl
51 stylesheet for single file output, that is not useful for
54 You should set the $base.dir stylesheet param to the
55 subdirectory that will contain the .xhtml files and
56 the epub package files. Here is an example using xsltproc:
59 --stringparam base.dir ebook1/ \
63 Make sure you don't include the OEBPS directory in base.dir.
65 After processing a document with this setting, you should find
68 ebook1/mimetype - required mimetype file.
69 ebook1/META-INF/container.xml - required container file
70 ebook1/OEBPS/package.opf - required package file
71 ebook1/OEBPS/toc.ncx - optional NCX file for backwards compatibility
72 ebook1/OEBPS/docbook-epub.css - CSS file
73 ebook1/OEBPS/*.xhtml - The chunked content files.
77 ---------------------------
79 Manually copy any image files used in the document
80 into the corresponding locations in the $base.dir
81 directory. For example, if your document contains:
83 <imagedata fileref="images/caution.png"/>
85 In this example base.dir, you would copy the file to:
87 ebook1/OEBPS/images/caution.png
89 You can get a list of image files from the manifest file
90 named ebook1/OEBPS/package.opf that is created by the
91 stylesheet. It includes references to image files for
92 callouts and admonitions if they are used in the output.
93 Note that the header and footer images are turned off for
97 3. Create the epub3 file.
98 -----------------------------
99 Change to the directory containing the base.dir (ebook1
100 in this example), and run the following zip command to
101 create the epub file:
103 zip -r -X mybook.epub mimetype META-INF OEBPS
105 The -r option means recursively include all directories.
106 The -X option excludes extra file attributes (required by epub3).
107 The "mybook.epub" in this example is the output file.
108 The other three arguments must appear in this order.
111 4. Validating with epubcheck 3
112 -----------------------------------
114 There is a java program that can be used to check an
115 epub3 file for conformance. It is currently available
118 http://code.google.com/p/epubcheck/wiki/EPUBCheck30
120 That website provides a download link, and information on
121 how to run the command.
124 Testing with EPUB readers
125 ----------------------------
126 The EPUB3 standard is not yet widely supported. The output of
127 these stylesheets has been tested in the following readers:
129 Apple iBooks on an iPod and iPad.
130 - Handles videodata and audiodata.
131 - Does not format MathML yet.
134 Firefox browser with the EPUBReader version 1.4.10 add-on.
135 - Formats MathML nicely.
136 - Does not handle videodata or audiodata yet.
139 Ibis EPUB3 preview version
140 - Does not format MathML yet.
141 - Does not handle videodata or audiodata yet.
142 - Handles SVG with external viewer.
145 Customizing the epub3 stylesheet
146 ---------------------------------
147 As with all DocBook stylesheets that generate chunked output, a
148 customization requires two files: one for chunking behavior and
149 one for element formatting. Most people only need to customize
150 element formatting, but you still need the two files to keep the
151 proper import precedence. See this doc for details about this
154 http://www.sagehill.net/docbookxsl/ChunkingCustomization.html
156 Here is an example of the chunking stylesheet, which is the one you
157 apply to your document when processing:
159 custom-epub3-chunk.xsl
160 --------------------------------------------------------------------
161 <?xml version="1.0"?>
162 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
163 xmlns:d="http://docbook.org/ns/docbook"
165 exclude-result-prefixes="d">
167 <!-- Import the element customization module, shown below -->
168 <xsl:import href="custom-epub3-elements.xsl"/>
170 <!-- import stock DocBook XSL file; use a catalog for local files-->
171 <xsl:import href="http://cdn.docbook.org/release/xsl/current/xhtml/chunk-common.xsl"/>
173 <!-- include (not import) stock DocBook XSL file; use a catalog for local files-->
174 <xsl:include href="http://cdn.docbook.org/release/xsl/current/xhtml/chunk-code.xsl"/>
176 <!-- include (not import) stock DocBook XSL file; use a catalog for local files-->
177 <xsl:include href="http://cdn.docbook.org/release/xsl/current/epub3/epub3-chunk-mods.xsl"/>
179 <!-- Add here any templates that change chunking behavior.
180 That is, any templates copied from chunk-common.xsl or
181 chunk-core.xsl and modified. Any such customized templates
182 with a @match attribute must also have a priority="1"
183 attribute to override the original in chunk-code.xsl -->
186 --------------------------------------------------------------------
188 The following stylesheet file is imported by the above file.
190 custom-epub3-elements.xsl
191 --------------------------------------------------------------------
192 <?xml version="1.0" encoding="utf-8"?>
194 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
195 xmlns="http://www.w3.org/1999/xhtml"
196 xmlns:d="http://docbook.org/ns/docbook"
197 exclude-result-prefixes="#default d"
200 <xsl:import href="http://cdn.docbook.org/release/xsl/current/xhtml5/docbook.xsl"/>
201 <xsl:include href="http://cdn.docbook.org/release/xsl/current/epub3/epub3-element-mods.xsl"/>
203 <!-- Add here any templates that change element format. Any
204 such customized templates with a @match attribute must also
205 have a priority="1" attribute to override the original. -->
207 <!-- Add here any templates that change element formatting.
208 That is, any templates not copied from chunk-common.xsl or
209 chunk-core.xsl. Any customized templates with a @match
210 attribute must also have a priority="1" attribute to
211 override the original. -->
214 --------------------------------------------------------------------
219 ========================
220 The info child of the document's root element is used
221 by the stylesheet to create EPUB metadata. Note that
222 metadata is plain text, so element content is converted
223 to text using the XSL normalize-space() function.
225 Here is the current mapping of info elements to EPUB
226 metadata. Any others are ignored for metadata, but
227 may appear on the EPUB HTML titlepage, depending on the
228 titlepage customization.
230 NOTE: the <dc:*> elements (not attributes of meta) duplicate
231 the meta elements for backwards compatibility, per the
232 EPUB3 specification. They can be turned off with the
233 $epub.include.optional.metadata.dc.elements parameter.
237 The content must be converted to a text string for the
238 OPF metadata. The stylesheet converts only title, para,
239 formalpara, and simpara children in an abstract. All other
240 child elements are ignored. It puts any title first.
241 The OPF output appears as:
243 <meta property="dcterms:description">title: abstract text</meta>
244 <dc:description>title: abstract text</dc:description>
249 If uses a personname child, then it applies the
250 DocBook XSL person.name template to arrange the name.
251 Otherwise processes org or orgname into the content.
254 <meta id="meta-creator1" property="dcterms:creator">Firstname Surname</meta>
255 <dc:creator id="pub-creator1">Firstname Surname</dc:creator>
257 If there are multiple authors, the number in the id attribute
258 is incremented each time.
263 Applies templates to all of its children.
268 <meta property="dcterms:coverage">bibliocoverage text</meta>
269 <dc:coverage>bibliocoverage text</dc:coverage>
274 This usually has @class="isbn" for the ISBN number. It is used
275 as the EPUB3 unique-identifier. That isbn value
276 is also output as follows:
278 <meta id="meta-identifier" property="dcterms:identifier">urn:isbn:value</meta>
279 <dc:identifier id="pub-identifier">urn:isbn:value</dc:identifier>
281 A biblioid element with other class names are converted in a similar manner.
286 <meta property="dcterms:relation">bibliorelation text</meta>
287 <dc:relation>bibliorelation text</dc:relation>
292 <meta property="dcterms:source">bibliosource text</meta>
293 <dc:source>bibliosource text</dc:source>
298 If a personname child is used, then it calls the
299 person.name template, otherwise is uses the orgname or
302 <meta property="dcterms:contributor">collab text</meta>
303 <dc:contributor>collab text</dc:contributor>
308 Arranges the copyright elements into a text string with
309 copyright symbol, dates, and holder, and then
312 <meta property="dcterms:right">Copyright text</meta>
313 <dc:right>Copyright text</dc:right>
315 Also, if there is no info/date element, then the copyright
316 year is used to generate:
318 <meta property="dcterms:date">year</meta>
319 <dc:date>year</dc:date>
324 <meta id="meta-creator1" property="dcterms:creator">corpauthor text</meta>
325 <dc:creator id="pub-creator1">corpauthor text</dc:creator>
330 <meta property="dcterms:contributor">corpcredit text</meta>
331 <dc:contributor>corpcredit text</dc:contributor>
336 <meta property="dcterms:date">date text</meta>
337 <dc:date>date text</dc:date>
344 If a personname child is used, then it calls the
345 person.name template, otherwise is uses the orgname text.
347 An editor can be considered as either a creator (when there
348 is no author) or a contributor. The stylesheet parameter
349 'editor.property' can be set to either 'creator' or
350 'contributor' (default) at runtime. So the output is either:
352 <meta property="dcterms:contributor">editor text</meta>
353 <dc:contributor>editor text</dc:contributor>
357 <meta property="dcterms:creator">editor text</meta>
358 <dc:creator>editor text</dc:creator>
363 Handled like biblioid @class="isbn".
368 <meta property="dcterms:subject">keyword text</meta>
369 <dc:subject>keyword text</dc:subject>
374 Applies templates to its children.
389 Applies templates only to publishername.
394 <meta property="dcterms:publisher">publishername text</meta>
395 <dc:publisher>publishername text</dc:publisher>
400 Applies templates to subject/subjecterm descendants.
405 <meta property="dcterms:subject">subjecterm text</meta>
406 <dc:subject>subjecterm text</dc:subject>