DocBook + Images != Fun
I've been using DocBook for a little while now, and I have to say, I wish there was a better alternative (something which provides a nice base format for the creation of multiple formats). My latest niggle is working with images. Like most things with DocBook, the solution starts off only a little difficult, then gets a fair bit more complicated.
Before I go on, I realise a big part of my complaint is to do with XSLT: at the end of the day, XSLT really is just about transforming the XML, and not about building finished documents. Any yet I can't help but feel that whatever solution a person uses for document creation should encompass the whole shebang, from the core documents to the images they contain.
Back to the topic of conversation, DocBook and Images. Getting the initial block of XML needed for images isn't that hard, and here it is:
<mediaobject id="Registry Types">
<imageobject role="fo">
<imagedata format="SVG" fileref="RegistryTypes.svg">
</imagedata>
<imageobject role="html">
<imagedata format="PNG" fileref="RegistryTypes.png">
</imagedata>
</imageobject>
</imageobject></mediaobject>
You'll notice that I've specified two formats, one for the PDF generation and one for the HTML generation. This represents the fact that scalable vector graphic support is still not as widely accepted as we'd like. So, now we've got to create multiple images to support two formats. I could have just used a raster image for the PDF, but due to the need for higher print quality (and also the fact that Magic Draw doesn't provide configurable dpi on it's rasters) I chose to do both formats.
Now comes the trick: the 'fileref' is not relevant to either the HTML XSLT transformation or the FO XSLT transformation, it's only relevant to either the final destination of the HTML or as I would deem incorrectly, the base directory of the fop Ant task.
For the HTML, what this means is that you have to define appropriate tasks to copy the images to a directory accessible to the final production. Not too difficult but worth remembering.
For the PDF generation, you need to ensure that the images are relative to the base path where the Ant script is run... so the above declaration should probably be changed to something like "images/RegistryTypes.svg" so the "fop" task can access the required images.
