Don’t panic — I’m not trying to sell you anything despite the acronyms in the subject line.

In my quest to bring docbook XML into 1990’s, when users could easily change the fonts of their documents at the slightest whim, I ran across an interesting chapter in XML in a Nutshell. It mentions that many modern browsers can actually render XML documents that reference a CSS stylesheet. Ok. I knew this was clearly going to be an exercise in pain, but I had to see how painful. Remember, I want to turn docbook into PDF with my choice of fonts, not Fop’s.

So I cruise over to the docbook project site and pick up a few of the contributed CSS files. I create a very simple docbook file and reference one of these CSS files. I used Opera on both Linux and Windows, I used IE 5.5, I used Mozilla. I got nothing but the XML file back without formating.

mmm.

Upon closer inspection, it was clear that these CSS files were meant for HTML files, not raw XML. So, I hacked up this lame CSS file:

/* jjohn’s CSS hack for docbook —
This is to get BROWSERS to render XML.
There is *NO* transformational step */

para {
display: block;
font-family: courier;
font-size: 12pt;
}

title {
display: block;
font-family: verdana;
font-size: 14pt;
font-weight: bold;
}

Ah-HA! Progress! I got the XML to render (weakly) in Galeon but as a proof-of-concept test, it worked as expected. Now, how to get this into PDF. Well, Galeon can print PS to a file, which I did. Unfortunately the funky fonts I had picked didn’t get into the PS, so I didn’t even bother running ps2pdf. I think that’s weird because the fonts do show up on screen. But then, I don’t really understand the implementation of rendering fonts.

Still, this seems like a promising line of research. Does anyone here know if the Mozilla project has a command line CSS processor that will vomit forth Postscript? That would be super-fantastic. Heck if I had that, I could go docbook->HTML->CSS->PS->PDF and hopefully get formatting AND fonts. Excellent.

[Original use.perl.org post and comments.]