title_body: What is the easiest workflow to publish ePub files from highly structured database content? 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.
upvoted_answer: 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).