XSLT processors - phax/ph-schematron GitHub Wiki

XSLT processors (since v11.0.0)

The XSLT based engines of ph-schematron run on a selectable XSLT processor:

Engine (ESchematronEngine) Handler class Saxon phoxtrot
iso-schematron SchematronResourceSCH yes yes
schxslt SchematronResourceSchXslt_XSLT2 yes yes
schxslt2 SchematronResourceSchXslt2 yes yes
xslt SchematronResourceXSLT yes yes
pure-xslt SchematronResourcePureXslt yes no
pure-xpath SchematronResourcePureXPath Saxon XPath no

ESchematronEngine.isXsltProcessorSelectable () tells whether an engine can run on both.

The processors

Processor ID Module Notes
Saxon HE saxon ph-schematron-saxon The reference. Saxon-HE 13.1
phoxtrot phoxtrot ph-schematron-phoxtrot A Java XPath 3.1 / XSLT 3.0 processor without Saxon

The engine modules (ph-schematron-isosch, ph-schematron-schxslt, ph-schematron-schxslt2, ph-schematron-xslt) depend on no processor. Add exactly one of the processor modules as dependency, replacing x.y.z with the latest version number:

<dependency>
  <groupId>com.helger.schematron</groupId>
  <artifactId>ph-schematron-saxon</artifactId>
  <version>x.y.z</version>
</dependency>

or

<dependency>
  <groupId>com.helger.schematron</groupId>
  <artifactId>ph-schematron-phoxtrot</artifactId>
  <version>x.y.z</version>
</dependency>

Selecting the processor

  • If exactly one processor is on the class path, it is used automatically.
  • If none is on the class path, building a resource fails with an IllegalStateException that names the modules to add.
  • If both are on the class path, the processor must be selected explicitly, otherwise building a resource fails with an IllegalStateException.

Select the processor in the builder of the resource (or of its config):

final SchematronResourceSCH aSCH = SchematronResourceSCH.builder (aSchematron)
                                                        .xsltProcessor (new PhoxtrotXsltProcessor ())
                                                        .build ();

SchematronXsltProcessorRegistry finds the processors on the class path: getAllProcessors (), getProcessorOfID ("phoxtrot"), getDefaultProcessor () and getProcessorOfIDOrDefault (String).

The processor is part of the compilation cache key, so the same Schematron can be cached for both processors at the same time.

The Maven plugin and the ANT tasks have the parameter xsltProcessor.

phoxtrot settings

phoxtrot requires Java 21 (as does ph-schematron since v11.0.0). PhoxtrotTransformerFactories creates the factories with secure processing, like the Saxon ones, plus:

Setting Default Method
Step limit of a transformation none (XsltTransformRequest.UNLIMITED_STEPS), as with Saxon PhoxtrotTransformerFactories.setMaxSteps (long)
Nesting depth limit of templates and functions none (XsltTransformRequest.UNLIMITED_DEPTH), as with Saxon: only the stack of the thread PhoxtrotTransformerFactories.setMaxDepth (int)
Thread of compilations and transformations the phoxtrot thread pool, with a large stack PhoxtrotTransformerFactories.setThreading (EThreading)

Both settings apply to factories created afterwards, so set them before the first validation. EThreading.CALLING_THREAD uses the stack of the caller, which may be too small for the recursive ISO Schematron conversion of long expressions.

Known differences to Saxon

Saxon is the reference. The created XSLT and the SVRL are compared for all test files of ph-schematron and all four engines; the SVRL is identical for all of them. The following differences are known and reported to phoxtrot:

  • The values of generate-id() differ, so the IDs of patterns created from abstract patterns (and the internal names of the SchXslt engines) differ in the created XSLT and in svrl:active-pattern/@id.
  • Error messages differ in their text; the error codes are the same.

On both processors ph-schematron checks for an interrupt of the calling thread between the conversion steps (SchematronInterruptedException); phoxtrot additionally stops a running transformation when the calling thread is interrupted.

DOM input

How an XML instance passed as javax.xml.transform.dom.DOMSource (or via the Node based methods) is validated depends on the processor:

Processor Plain DOMSource SaxonDOMSource
Saxon Every XPath step navigates the wrapped DOM (slow for large documents) Copied once per validation into Saxon's native tree
phoxtrot Copied once per validation into the phoxtrot tree Same as a plain DOMSource

phoxtrot therefore needs no counterpart of SaxonDOMSource: every DOM is validated on a snapshot, with the same consequences as described for SaxonDOMSource (DOM object identity is not retained). XML read by ph-schematron itself (e.g. from an IReadableResource) is validated on the native tree of both processors.

Speed

Measured on 2026-11-11 (Apple M5, JDK 21, Saxon-HE 13.1, phoxtrot 0.2.0-SNAPSHOT; details in docs/benchmarks/2026-11-11-phoxtrot-vs-saxon.md of the repository):

  • Validation with a compiled Schematron is 4 to 10 % faster on phoxtrot than on Saxon for documents with 2,000 or more elements, with 5 to 10 % more allocation. For very small documents (about 60 µs per validation) phoxtrot takes about 1.1 times Saxon's time.
  • Converting a Schematron to XSLT takes 1.38 times Saxon's time on phoxtrot for the ISO Schematron engine, 1.21 times for SchXslt 1 and is on par for SchXslt 2 (measured on 2026-11-16, after the abstract pattern expansion of the ISO Schematron engine was changed to use a key; before, the ISO conversion was about 8 times faster on phoxtrot).

Memory

The phoxtrot tree of an input document needs 1.4 to 4.3 times the heap of the Saxon TinyTree (as measured by phoxtrot).

⚠️ **GitHub.com Fallback** ⚠️