TypesBook - Merge DocBook XML Files

TypesBook logo

TypesBook is a TypeScript / Node.js command-line utility and library that merges a set of DocBook XML documents and their dependencies into a single, clean XML file.

The source code is available on GitHub under the EPL-1.0 License.

Quick example

Install the package globally from npm:

npm install -g typesbook

Then merge a main DocBook file and its included modules into a single output file:

typesbook -i book.xml -o build/merged_book.xml

Why TypesBook

Publishing large multi-file DocBook documentation sets as PDFs or single-file formats often requires resolving external entities, xi:include directives, and catalogs before rendering.

TypesBook streamlines this process:

  • Resolves Entities Automatically: Uses an included OASIS catalog to resolve external entities and schemas seamlessly.
  • Single-File Output: Flattens a modular documentation tree into a standalone XML document that is immediately ready for downstream processors like CSSMedia.
  • Modern Node.js Stack: Built with pure TypeScript, requiring no legacy Java runtimes or complex Ant scripts.

Usage

Run typesbook from the command line to view the help text and parameters:

typesbook -i <file> -o <file> [-g <catalog>]
Parameter Description
-i, --input <file> Main DocBook XML input file
-o, --output <file> Merged XML output file
-g, --catalog <file> (Optional) OASIS catalog to resolve DTDs and external entities

Publishing DocBook to PDF with CSSMedia

Once TypesBook generates a single, unified XML file, you can feed it directly into CSSMedia along with a CSS stylesheet to generate a publication-quality PDF—just like the multi-language xml_gap sample.

For example, to merge and render a document:

# Step 1: Merge the modular DocBook files into one
typesbook -i book.xml -o build/merged_book.xml

# Step 2: Render the merged XML directly to PDF using CSSMedia
cssmedia -x build/merged_book.xml -c book.css -p book.pdf