Apache FOP with Saxon on Ubuntu

Apache FOP is a print formatter that uses XSL formatting objects (XSL-FO) to transform XML into a PDF for viewing or printing. We use FOP in uzERP to output documents like invoices, orders and reports. Recently, I wanted to use some XSLT2.0 features in a document that I was developing for a uzERP customer, but FOP uses Xalan as its default transformation engine and that only supports XSLT1.0.

FOP is a Java application and XML processing is pluggable using the Java API for XML Processing (JAXP), so Xalan can be replaced with an alternative processor. We are deploying our customer systems on Ubuntu 14.04 and packages are available for Saxon 6.5.5, an XSLT processor that supports new features first defined in the XSLT 1.1 working draft. This was enough for me to be able to use the format-date function and a few others in my stylesheet, but

How to persuade FOP to use Saxon?

First of all, install the Saxon packages:

Copy the FOP command line script:

Edit the copied script file:

I want this script to override the standard FOP script when using the fop command, so added a system wide alias by creating a file called fop-alias.sh in /etc/profile.d with the following contents:

With all that done, the fop command will now load the Saxon XSLT processor, which enables access to a number of useful extensions not available in XLST1.0

uzERP – Free Software for Growing Businesses

Since May 2014, I’ve been working as a developer and consultant with uzERP LLP on their free, Open Source ERP system, uzERP.

Since May 2014, I’ve been working as a developer and consultant with uzERP LLP on their ERP system uzERP.

uzERP is an open source ERP system for small and growing businesses who need  fully integrated software that covers the complete order lifecycle from sales lead to product/service delivery.

More about uzERP