WIPIVERSE All articles

DocBook

DocBook is a semantic markup language used for authoring technical documentation. It was originally intended for writing technical documents related to computer hardware and software, but it can be used for other sorts of documentation as well.

As a semantic language, DocBook enables users to create document content in a presentation-neutral form that captures the logical structure of the content. Documents written in DocBook can be published in a variety of output formats—including HTML, XHTML, EPUB, PDF, man pages, WebHelp, and HTML Help—without requiring changes to the source. This portability means a document needs to be written once and can then be transformed into multiple formats rather than being rewritten for each.

Technical Design

DocBook is an XML language. In its current version (5.x), DocBook's language is formally defined by a RELAX NG schema with integrated Schematron rules. W3C XML Schema + Schematron and Document Type Definition (DTD) versions of the schema also exist but are considered non-standard.

DocBook documents describe the meaning of their contents rather than their visual appearance. For example, a document marks a particular section as an "abstract" without specifying how it should be visually formatted; it is left to an external processing tool to decide where and how the abstract should appear in the final output.

DocBook provides a large number of semantic element tags, divided into three broad categories:

  • Structural tags specify broad characteristics of content, such as set, book, part, article, chapter, appendix, and dedication. Structural elements are the only permitted top-level elements in a DocBook document.
  • Block-level tags include elements such as paragraphs and lists. Sequential block-level elements render one "after" another, with the directionality depending on the writing system of the language.
  • Inline-level tags include elements such as emphasis and hyperlinks. They wrap text within a block-level element and do not break the text when rendered, though they typically cause distinct typographical treatment.

DocBook semantics are neutral to language-based concepts such as text directionality, allowing documents to be rendered in different writing systems.

History

DocBook began in 1991 in discussion groups on Usenet and eventually became a joint project of HAL Computer Systems and O'Reilly & Associates. It spawned its own maintenance organization, the Davenport Group, before moving in 1998 to the SGML Open consortium, which subsequently became OASIS. DocBook is currently maintained by the DocBook Technical Committee at OASIS.

DocBook originally started as an SGML application; an equivalent XML application was later developed and has since replaced the SGML version for most uses. Until DocBook 5, the format was defined normatively by a DTD. Starting with DocBook 5, the RELAX NG version is the normative form from which the other formats are generated. DocBook 4.x documents are not compatible with DocBook 5 but can be converted via an XSLT stylesheet.

DocBook was adopted widely by the open source community, becoming a standard for documentation in projects including FreeBSD, KDE, GNOME desktop documentation, the GTK+ API references, the Linux kernel documentation (which, as of July 2016, was transitioning to Sphinx/reStructuredText), and the work of the Linux Documentation Project.

Authoring and Processing

Because DocBook is XML, documents can be created and edited with any text editor or dedicated XML editor. The format provides schema files for popular XML schema languages, enabling content completion and validation in XML editors. Documents can also be validated against the schema using standard XML tools.

Output generation from DocBook source is most commonly accomplished using the DocBook XSL stylesheets, which transform DocBook documents into formats such as HTML, XSL-FO (for later conversion to PDF), RTF, man pages, and HTML Help. These stylesheets can generate tables of contents, glossaries, and indexes, and can select designated portions of a master document to produce different versions such as tutorials or quick-reference guides.

Simplified DocBook

Simplified DocBook is a small subset of DocBook designed for single documents such as articles or white papers. It was created to offer the convenience of DocBook without a steep learning curve; "books" are not supported in this subset. The Simplified DocBook DTD is currently at version 1.1.

Standards and File Formats

DocBook files typically use the .dbk or .xml filename extensions and have the Internet media type application/docbook+xml. The format is developed and maintained by OASIS. Key standard versions include DocBook 5.2 (February 2024) and DocBook 4.5 (October 2006). DocBook is an open format.

Criticism

Some technical writers have criticized aspects of DocBook. Ingo Schwarze, the author of OpenBSD's mandoc, considered DocBook inferior to the semantic mdoc macro for man pages, describing certain semantic parts as "bloated, redundant, and incomplete at the same time" compared to mdoc elements. Schwarze also found the DocBook specification insufficiently specific about tag usage, non-portable across versions, and inconsistent in some details.

Browse

More topics to explore

    Browse all articles