I have a large amount of highly structured data (Bible verse translations and commentary) in an SQL database that I would like to make available in as widely usable an ebook format (or formats) as possible. The formatting is going to require a little bit more that a flat text rendering to include section headings, verse numbering, clear delineation between types of content (translated text of Scripture formatted differently than commentary), linked cross references, and a Table of Contents.

I presume that I should be generating an in-between format of some sort such as an XML file based on my data set that can then be transformed using XSLT or a similar system to a finished ebook format, but I don't know what this should be. I don't want to re-invent the wheel any more than necessary.

  • Is this generally the right workflow or am I missing the boat somewhere?
  • What should the in-between format be? Are there standards for this that will make the secondary transformation easier than others?

I suppose I should note that this is not a one time project that I can hack together using some GUI tools or web services — the whole process must be scriptable from start to finish. I intend to make the ebook generation an option from an extant site as an export option with customizable data ranges, translations, etc.

2 Answers 2


I have done projects like this. I am assuming that you know how to select the data you need from your database. I would suggest you develop a template based on pandoc's extended markdown (to get the cross-referencing), merge the data with the template and then script pandoc to convert that to EPUB2 and PDF. If you want to offer a Kindle-compatible ebook (and you are giving it away), you could then script Kindlegen (available from Amazon) to turn the EPUB2 into a MOBI file.

This isn't a trivial undertaking, but it should be doable.


I recommend you generate some mark up format supported as input for pandoc (i.e. markdown, reST, HTML) and generate the EPUB from that.

You should have no trouble scripting pandoc, but you would need some work automating the generation of the markup from your database (but not more than you would have generating XML).

  • If post-processing is needed, I can recommend the free software Sigil.
    – Raphael
    Jan 26, 2014 at 1:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.