Publishing DocBook Documents

$Revision: 1.4 $

$Date: 2005/10/31 18:50:56 $

Creating and editing XML documents is usually only half the battle. After you've composed your document, you'll want to publish it. Publishing, for our purposes, means either print or web publishing. For XML documents, this is usually accomplished with some kind of stylesheet. In some environments, it is now possible to publish an XML document on the Web simply by putting it online with a stylesheet.

A Survey of Stylesheet Languages

Over the years, a number of attempts have been made to produce a standard stylesheet language and, failing that, a large number of proprietary languages have been developed.


First, the U.S. Department of Defense, in an attempt to standardize stylesheets across military branches, created the Output Specification, which is defined in MIL-PRF-28001C, Markup Requirements and Generic Style Specification for Electronic Printed Output and Exchange of Text.[4]

Commonly called FOSIs (for Formatting Output Specification Instances), they are supported by a few products including ADEPT Publisher by Arbortext and DL Composer by Datalogics.


Next, the International Organization for Standardization (ISO) created DSSSL, the Document Style Semantics and Specification Language. Subsets of DSSSL are supported by Jade and a few other tools, but it never achieved widespread support.


The W3C CSS Working Group created CSS as a style attachment language for HTML, and, more recently, XML.


Most recently, the XML effort has identified a standard Extensible Style Language (XSL) as a requirement. The W3C XSL Working Group is currently pursuing that effort.

Stylesheet Examples

By way of comparison, here's an example of each of the standard style languages. In each case, the stylesheet fragment shown contains the rules that reasonably formatted the following paragraph:

This is an example paragraph. It should be presented in a
reasonable body font. <emphasis>Emphasized</emphasis> words
should be printed in italics. A single level of 
<emphasis>Nested <emphasis>emphasis</emphasis> should also
be supported.</emphasis>

FOSI stylesheet

FOSIs are SGML documents. The element in the FOSI that controls the presentation of specific elements is the e-i-c (element in context) element. A sample FOSI fragment is shown in Example 4.1, “A Fragment of a FOSI Stylesheet”.

Example 4.1. A Fragment of a FOSI Stylesheet

<e-i-c gi="para">
    <textbrk startln="1" endln="1">

<e-i-c gi="emphasis">
  <charlist inherit="1">
    <font posture="italic">

<e-i-c gi="emphasis" context="emphasis">
  <charlist inherit="1">
    <font posture="upright">

DSSSL stylesheet

DSSSL stylesheets are written in a Scheme-like language. It is the element function that controls the presentation of individual elements. See the example in Example 4.2, “A Fragment of a DSSSL Stylesheet”.

Example 4.2. A Fragment of a DSSSL Stylesheet

(element para
  (make paragraph

(element emphasis
  (make sequence
    font-posture: 'italic

(element (emphasis emphasis)
  (make sequence
    font-posture: 'upright

CSS stylesheet

CSS stylesheets consist of selectors and formatting properties, as shown in Example 4.3, “A Fragment of a CSS Stylesheet”.

Example 4.3. A Fragment of a CSS Stylesheet

para              { display: block }
emphasis          { display: inline;
                    font-style: italic; }
emphasis emphasis { display: inline;
                    font-style: upright; }

XSL stylesheet

XSL stylesheets are XML documents, as shown in Example 4.4, “A Fragment of an XSL Stylesheet”. The element in the XSL stylesheet that controls the presentation of specific elements is the xsl:template element.

Example 4.4. A Fragment of an XSL Stylesheet


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"

<xsl:template match="para">   

<xsl:template match="emphasis">
  <fo:sequence font-style="italic">

<xsl:template match="emphasis/emphasis">
  <fo:sequence font-style="upright">


Using Jade and DSSSL to Publish DocBook Documents

Jade is a free tool that applies DSSSL stylesheets to SGML and XML documents. As distributed, Jade can output RTF, TeX, MIF, and SGML. The SGML backend can be used for SGML to SGML transformations (for example, DocBook to HTML).

For more information about Jade and DSSSL, see the first edition of this book.

Using XSL to Publish DocBook Documents

For more information about using XSL to publish DocBook documents, see DocBook XSL: The Complete Guide by Bob Stayton.

[4] See Formally Published CALS Standards for more information.