Skip to content

DocBookCssStylesheets

Thomas Schraitle edited this page Nov 1, 2018 · 3 revisions
Clone this wiki locally

CSS for HTML/XHTML

The HTML output from the DSSSL and XSL stylesheets includes additional formatting information to further style the output using CSS. A number of CSS stylesheets are available that take advantage of this extra information.

CSS for XML

CSS can be used directly on the XML Docbook. (See: Associating Style Sheets with XML documents).

You just have to add a PI :


<!DOCTYPE book ... >

<?xml-stylesheet href="../docbook.xml.css" type="text/css"?>

<book ... >

Modern browsers such as Netscape 7 and Microsoft Internet Explorer 6 are capable of rendering XML content directly using a CSS style sheet. In other words it is not necessary to first render or transform an XML document into HTML before viewing it in a browser. Also, a number of XML editors use a CSS style sheet to control the way in which the 'editor pane' appears. Insert the lines above to inform your browser where to find the CSS style sheet which will determine the way that the XML document is displayed

You can find such CSS distributed with Xmlmind XML Editor.

The CSS Style sheet for DocBook associated with the XMLmind editor appears to be quite comprehensive. It is divided into a number of 'include' files. The 'master' css file can be found in the \config\docbook\css\ directory of the installation directory. The Docbook CSS files do not appear to be available on the XMLmind website independently. You have to download the whole (free version) of the XMLmind editor.

On a Microsoft Windows computer the following scriptlet should reformat the XMLmind css file to be an all-in-one CSS file (as opposed to using CSS includes)

rem ** Substitute the full path to your XMLmind installation directory below
cd \Program Files\XMLmind_XML_Editor\config\docbook\css
type ..\..\sdocbook\css\sdocbook.incl docbook.incl ..\..\sdocbook\css\print.incl > docbook-complete.css

Another DocBook XML CSS: MozBook (example).


I created some CSS stylesheets for Docbook a while back. They need a lot more work, but include an experiment using Mozilla's XBL binding stuff that makes <ulink> 'work'. It's always interesting to see them crash the latest version of Mozilla.


Based on the stylesheet linked above I developed my own stylesheet which you can find here:wysiwygDocBook (current version: 1.0) . The site includes a demo, which is only in German right now.


If you already have a CSS file for your DocBook XML document, you can use CSSToXSLFO to transform it directly to XSL-FO. CSSToXSLFO is a utility which can convert an XML document, together with a CSS2 style sheet, into an XSL-FO document, which can then be converted into PDF, PostScript, etc. with an XSL-FO processor. It has special support for the XHTML vocabulary, because that is the most obvious language it would be used for. The tool has a number of page-related extensions. It also comes with an API in the form of an XML filter.