Re: [docbook-apps] DocBook and InDesign

From
Kurt A Richardson <>
Date
2010-06-17T01:56:35+00:00
ID
Thread
Re: [docbook-apps] DocBook and InDesign
On 6/16/2010 11:53 AM, David Link wrote:
> On a slightly different note, what about roundtripping from DocBook 
> XML to HTML and back?  Do people have experience with that, or know 
> any problems therein? 
As I've mentioned in my recent posts I'm a newb to DocBook and XSLT so 
my answer maybe somewhat incomplete and naive.  The XSLT Cookbook (ISBN 
9780596009748) has a chapter on XML to HTML.  From my limited knowledge 
going from DocBook to HTML seems to be rather straigthforward and there 
are a number of stylesheets 'out there' to perform comprehensive Doc 
Book to HTML transformations.  My preferred approach is to use CSS to 
format the (X)HTML and let the DocBook XML <-> XHTML round-trip 
transformation just deal with the content.

What I've struggled with more is HTML (which is mostly flat) to DocBook 
(which is more hierarchic).  I have attached my recent effort to develop 
a route from InDesign exported PDF to DocBook XML (I hope the 
attachments make it through the list management software).  The process 
I have at this point is far too simplistic to be useful at present, but 
I'm hoping I can get into a state whereby I can downconvert several 
thousand InDesign exported PDFs to DocBook with relative ease.  My 
process is:

InDesign created PDF -> Acrobat exported XML -> PDFXML2HTML XSLT -> 
HTML2DBK XSLT -> DocBook XML

It is far from ready to make use of (and is only ever going to work with 
my particular files as is), but the bit I found the most problematic was 
the transformation from HTML to DocBook because of the flat to nested 
hierarchy.  Fortunately, XSLT 2.0 makes this much easier with the 
for-each-group command, and a XSLT snippet on pages 340-342 of Michael 
Kay's incredibly comprehensive XSLT 2.0 and XPath 2.0 4th Edition (ISBN 
9780470192740) - I've barely scrapped the surface of the knowledge 
contained in this book!

I'm still not using the templates properly yet as my transformation from 
<p> to <para> is wrong, the <body> tags are still there - if anyone can 
guide me on how to correct these problems that'd be great!  The 
PDFXML2HTML XSLT is also not ready, but as this is a transformation from 
an already flat hierarchy (Acrobat generated XML) to another flat 
hierarchy (HTML) it really is nothing much more than a one-to-one 
mapping (I had to manually tweak the Eoyang_processed.xml - which is the 
output of the PDFXML2HTML XSLT because it doesn't quite do what I want 
yet).  The flaws in my output files is just a reflection of my limited 
knowledge of XSLT, but I'm already excited about the possibilities a 
deeper understanding of XSLT is going to allow me to explore... so any 
guidance is very much appreciated.  At least the final DocBook XML 
properly contains the nested <sectX> tags, which I was really struggling 
with...

Bye for now, Kurt