XQuery/DocBook to PDF

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Motivation[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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:

<book xmlns="http://docbook.org/ns/docbook"
    xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
        <title>Converting DocBook to PDF using XQuery</title>
            <orgname>Kelly McCreary &amp; Associates</orgname>
        <subtitle>Why DocBook and PDF</subtitle>
            <title>Introduction to DocBook</title>
            <subtitle>Getting Started with DocBook Version</subtitle>
                <title>Page Layout vs. Scrolling HTML</title>
                <subtitle>Why PDF is Used For Printing</subtitle>
                <para>Printing and pagination will still be important till ePub becomes standardized.</para>
            <title>XQuery Typeswitch Transforms</title>
            <subtitle>How To Get Comfortable with Recursive Programs</subtitle>
                <title>Why XQuery Can Replace XSLT</title>
                <subtitle>One language for the server</subtitle>
                <subtitle>A language for paginated layout</subtitle>