Simplified DocBk XML on the Web | 3
Simplified DocBk XML on the Web
Publishing Your Article
If you're brave, you can write your own script or style sheet to convert the Simplified DocBk XML document into HTML that's suitable to put on a Web site, but I wouldn't recommend it unless you really want to get into XML or you're already an expert. As I mentioned before, CSS, XSL, and DSSSL style-sheets already exist. You could modify those to do what my script does. Any element that I don't have an explicit conversion function for will simply create a span tag whose class is the same name as the element. This will make it easy to apply a CSS style sheet to your HTML article. I have a very basic CSS style sheet that I use which you can be download at http://www.webreference.com/perl/tutorial/tutorial.css.
I wrote a Perl script that takes a Simplified DocBk XML article and: splits it into multiple pages, converts it to HTML, and adds all headers and footers I use for Webreference. You can download it at http://www.webreference.com/perl/tutorial/11/webref_generate.pl. Feel free to modify it for your own use and let me know how you like it. The benefit of using such a script is that it saves you from doing all that HTML stuff. I used to spend 1-2 hours for each article changing links and text. I'm sure others are faster, but I only type with 4 fingers :)
To get the script to work on your system, you must have a recent version of Perl and the XML::Parser module. It should work on most *nix and Windows systems. I documented the process on installing the module in a previous tutorial http://www.webreference.com/perl/tutorial/8.
When you run the script, it will either create a bunch of nice HTML files, or it'll croak with an error message. If you get an error message, it either means that the XML is not well formed, or you don't have the XML::Parser module or current version of Perl installed.
Conversion via the Web
I've written a CGI script that will enable you to upload your Simplified DocBk XML article. Upon processing, it returns a zip file containing the HTML files. You can access the upload page at http://www.webreference.com/perl/upload.html. After the XML file has been processed, you should see a popup box prompting you to save the file. Make sure you rename it to a .zip extension when you download it so it will be recognized as such.
Currently, I don't have the code in place to convert DocBook tables, images, or lists. There may be others too. For now, you'll have to add the HTML by hand after it's created. But that's alot easier than doing it from scratch. Plus, when I add features in the future, you'll be able to easily regenerate all your articles without having to do much HTML editing. Lastly, for some reason, when I tried uploading an XML file from a Mac, I get an error. I will try to track this problem down. If any of you Mac users have an answer, please send it my way.