For would-be Docbook writers and veteran Docbook users who are interested in using EPUB rather than PDF as their final output, the XSL stylesheets provided by the Docbook team can be downloaded from Sourceforge and provides a pretty good output for use with ebook readers. Used in conjunction with Sigil, you can easily create exceptional and well-supported EPUBs for a variety of devices.
This brief tutorial reviews the basics of creating an EPUB from Docbook XML using the stylesheets and examine the markup/ebook using popular EPUB editor, Sigil. This 2-part article includes the following:
1. Docbook Setup
2. XSLTPROC
3. EPUB Images
4. Mimetype
5. Compressing and renaming
6. Editing in Sigil
7. Testing in Okular, Calibre, EPUBReader for Mozilla Firefox
Docbook Setup
OpenSUSE and Fedora users may already have the basic packages for working with Docbook including xsltproc, Docbook 5, and fo. Although I downloaded the latest stylesheets for Docbook through Sourceforge, Linux users can also install the software packages using their software manager.
Before exporting to EPUB, go through the normal steps to validate your Docbook XML file. For this article, the pre-tasks involved the following:
1. Wrote a fictional technical document, Bond Gaming Headset Quickstart Guide using Bluefish Editor.
2. Validated the document using xmllint in Konsole.
3. Placed PNG, SVG, and other image files in the same folder as the Docbook XML file.
XSLTPROC
Take note that this example uses Docbook 5.0 though the steps using earlier versions are the same. In a terminal such as Yakuake or Konsole, input:
xsltproc <path and filename of the epub stylesheet> <xml filename>
With 914b.xml as my Docbook XML file and my Docbook XML stylesheets stored in the default openSUSE /usr folder, I typed the following in Konsole:
xsltproc /usr/share/xml/docbook/stylesheet/nwalsh5/1.76.1/epub/docbook.xsl 914b.xml
The command will produce two folders:
1. META-INF
2. OEBPS
EPUB Images
Move your images into the OEBPS folder. In this example, there are only two PNGs. If you placed the images in a folder, make sure your XML accurately points to the correct source folder.
Mimetype
Although this is an optional step, create a mimetype file using a plain text editor. To create a mimetype for your EPUB file:
1. Launch Kwrite (or any text editor).
2. Enter the following text:
application/epub+zip
3. Save the mimetype file in the same parent folder as META-INF and OEBPS with the filename mimetype (the file extension .txt is unnecessary). This ensures that an operating system/application recognizes the final EPUB as an epub or zip file and will be associated with the correct application or service.
Continued in Docbook and EPUB Part 2
0 comments:
Post a Comment