XMLto - Convert DocBook XML to HTML & PDF

Convert DocBook XML to HTML and PDF formats with XMLto. Learn how to use XMLto for document conversion, including XSL overrides and custom stylesheets.

XMLto

XMLto is a command-line utility designed to convert DocBook XML documents into various output formats, primarily HTML and PDF. It leverages XSL stylesheets to perform the transformations, making it a powerful tool for technical writers and developers who need to generate documentation from a single source.

Convert DocBook XML to PDF

To convert your DocBook XML file to a PDF document, you can use the following command. This is a common use case for generating printable documentation.

# To convert DocBook XML to PDF
xmlto pdf mydoc.xml

Convert DocBook XML to HTML

XMLto can also transform your XML source into HTML. This is useful for creating web-based documentation. You can specify an output directory to keep your generated files organized.

# To convert DocBook XML to HTML
xmlto -o html-dir html mydoc.xml

Generate Single HTML File

If you prefer a single HTML file instead of a set of linked pages, XMLto provides an option for that. This can be convenient for simpler documentation sets or for embedding in other contexts.

# To convert DocBook XML to single HTML file
xmlto html-nochunks mydoc.xml

Modify Output with XSL Override

XMLto allows you to customize the transformation process by overriding default XSL stylesheets. For instance, you can use a specific XSL file for PDF output, potentially to include custom headers or footers.

# To modify output with XSL override
xmlto -m ulink.xsl pdf mydoc.xml

Use Non-Default XSL Stylesheet

For more advanced customization, you can specify an entirely different XSL stylesheet to be used for the conversion. This gives you fine-grained control over the final output's structure and appearance.

# To use non-default xsl
xmlto -x mystylesheet.xsl pdf mydoc.xml

External Resources