XSLT (Extensible Stylesheet Language Transformations) is a language for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG.

The XSLT processor is part of Axional Server core services and it's commonly used to transform XML documents into FO XML documents prior to be sent to the FOP processor.

1 Saxon vs Xalan

Axional Server supports either Xalan and Saxon XSLT processors.

Saxon 9 is actively developed while Xalan development is stalled since many years. This is also because Saxon 9 is an XSLT 2 procesor while Xalan is an XSLT 1 processor.

There is no point in struggling with XSLT 1 while XSLT 2 is available since a few years already. Xalan is licensed under Apache 2.0 and Saxon is licensed under Mozilla Public License (MPL).

From a usage point of view there is not really a difference - it will be a difference only if you change the processor code yourself, in case of MPL you need to make available your changes to the code.

1.1 Saxon issues

One issue with Saxon 9 HE is that it does not support extensions directly, but you can register integrated extensions though the API or by passing an Initializer class in the command line that will register those extensions. However, XSLT 2.0 provides many new functions and instructions as standard so it is less likely that you will need extensions. Any way, integrate a Java function is not as easy as in Xalan.

We can read about Saxon Java integration using Saxon HE from here

Another issue with Saxon 9 HE is that it does not support javascript calls. So the Xalan with Mozilla Rhino integration is a key point in favor of Xalan when javascript is need.

Saxon 9 also includes support for XSLT 3.0 (currently this is a working draft) but with Saxon you have early access to some of the new additions in XSLT 3.

2 Command line processor

The XSL processor can be run from command line using the followning command:

$ bin/XSLProcessor.sh -xsl {file} -xml {file} -out {file} [-encoding {encoding}]
Argument Description
xsl xsl transformation file
xml xml file with xml data to transform
out output transformed file
encoding file encoding (default is utf-8)

3 Selecting XSL the processor

Server can select either Xalan or Saxon XSLT procesors. By default Xalan is preferred cause if supportes either java and javascript call during XSLT transform.

Selecting the XSL processor can be done by:

TransformerFactory xalan = XMLFactory.getDocumentBuilderFactory(DocumentBuilderType.XALAN);          
TransformerFactory saxon = XMLFactory.getDocumentBuilderFactory(DocumentBuilderType.SAXON);

4 Selecting XML the processor

The same way, you can select the XML processor to be used and select either Xerces or Saxon.

Selecting the XML processor can be done by:

DocumentBuilderFactory xerces = XMLFactory.getDocumentBuilderFactory(DocumentBuilderType.XERCES);          
DocumentBuilderFactory saxon  = XMLFactory.getDocumentBuilderFactory(DocumentBuilderType.SAXON);