XQuery/DocBook to PDF

Motivation
You want to convert your DocBook 5 files to PDF format. PDF standardized page-layout format that allows you to to print books using standards.

Method
We will create an XQuery module with one main TypeSwitch statement for each of the main elements of DocBook. This will create an XSL-FO file that can then be converted directly to PDF using the Apache-FO 1.0 processor.

This will be done entirely using XQuery. No XSLT will be required.

Sample Input Document
We will start with a simple DocBook 5 document. This document used the DocBook namespace and includes the xlink namespace. A very small sample of the document might have the following structure: