views:

42

answers:

3

I am new to docbook, but can not find a decent way to write some pieces of html code directly in the docbook xml structure. The best I could find was dbhtml-include, but it requires a separate html file to parse.

Is it possible to write a few html lines directly ?

What I am actually trying to do is to write math with mathjax inside docbook. There may be a smarter way to do this though.

Thanks for any help.

+2  A: 

Is it possible to write a few html lines directly ?

It is always possible "to write directly" in XSLT and you can modify any XSLT stylesheet, including those of DocBook, to do so. A simple example below:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/">
   <html>
     Hello, World!
   </html>
 </xsl:template>
</xsl:stylesheet>

However, intersparsing XSLT and html is an antipattern that leads od spaghetti-like code that is unreadable and difficult to maintain.

This explains the design decision of Norm Walsh for dbhtml-include.

A very powerful design pattern also is to have a form-like html that contains a few XML elements which after the transformation are substituted with specific content -- the fill-in-the-blanks pattern.

Dimitre Novatchev
Thanks, I kind of figured it was not standard and bad habit, since I found limited hits on google. I knew the XSLT option, but have to think it through, before I use it. The problem is I have to add one template for each math figure I add, which is quite a lot.
Bo Jensen
I will leave it unanswered a bit and see if others have better suggestions, otherwise I will mark yours as best.
Bo Jensen
@Bo, Yes, customizing DocBook stylesheets can be a lot of work
Dimitre Novatchev
Thanks a lot Dimitre, it's in fact possible to make what I want quite easy with such a template. I just had to validate it with some experiments and it works fine.
Bo Jensen
A: 

FWIW, I usually just generate a barebones HTML page and then customize it with something like Sitemesh. Going from XML -> XSL -> Fully Customized HTML is generally a royal pain unless you are a master of figuring out some of the most complex XSLT stylesheets humanity has ever seen.

tobrien
I agree, but in this case I am using boost quickbook (which uses docbook underneath), which has done all the work for me. I only need to be able to write mathjax formulas, which I now have working with under 10 lines of code. That's a good enough solution for me.
Bo Jensen
A: 

some advice; If you have a XML and XSL, you can easily generate HTML by XEP. I think it is too usefull. If have any questions, you can visit the forum of RenderX: http://cooltools.renderx.com Also you can try a trial version of XEP from (http://www.renderx.com/tools/index.html)

Vardges