This week I was looking at the DocBook mark-up and experimented with convertion of DocBook content into ePub. There seems to be a very good fit there. I was able to create a XSLT stylesheet to transform a couple of O’Reilly-published books into ePub. Here is a sample: Greg Kroah-Hartman‘s “Linux Kernel in a Nutshell” book as ePub (IE sniffes it as zip, but it is really an epub file). Unfortunately, I only can post it with freely distributable clip art, no embedded fonts and with low-quality gif images for the illustrations in the book, so it does not look quite as good as the original (but with the right resources it is possible to make it look as good).
The XSLT stylesheet, a simple bash script that drives it and the free art that I have used can be downloaded here. If you want to run it yourself, this is what you need:
- Find some UNIX-like environment, in particular bash, xsltproc and zip commands. I have used Cygwin on Windows XP.
- Unzip downloaded file into some folder.
- Copy source DocBook XML (available at the book’s web site) into that folder; main book file should be named book.xml.
- Copy images into epub/OEBPS/images
- Run ./epub.sh
- If everything goes right, ePub file will be written into book.epub
For this particular book you should also add author’s name and book identifier into the book source (or it will be missing from the metadata and title page). Insert the following into the book.xml after the title tag:
I have only tried XSLT stylesheet with one other DocBook, which is certainly not enough testing; thus, I don’t think it will work with arbitrary DocBook content. If someone wants to take it from there, it would be fantastic because I won’t have time to polish it. The right thing to do is, of course, to integrate this capability into the existing XSLT framework for DocBook which is used to publish DocBook content into XSL:FO and PDF.
And, thank you, Greg for writing this book and for making the DocBook sources available!