Skip to content
Philip Helger edited this page Feb 21, 2023 · 11 revisions

Welcome to the ph-schematron wiki

ph-schematron is a Java library that validates XML documents via ISO Schematron.

Schematron is an XML based validation language to validate XML documents.

Schematron is part of the ISO 19757 standard "Information technology — Document Schema Definition Languages (DSDL)", Part 3 "Rule-based validation — Schematron". Until version 2016 the standard was free, since the 2020 version the standard needs to be bought.

This Wiki should provide you with all the information you need for version 6 and later releases. See the menu on the right side for your sub-navigation.

The following table shows the different Schematron implementations supported by ph-schematron:

Schematron implementation Rule representation Module Handler Class Comment
ISO Schematron SCH ph-schematron-xslt SchematronResourceSCH Inefficient, as the SCH is converted to XSLT all the time
ISO Schematron XSLT ph-schematron-xslt SchematronResourceXSLT
SchXslt SCH ph-schematron-schxslt SchematronResourceSchXslt_XSLT2 Inefficient, as the SCH is converted to XSLT all the time. After conversion use SchematronResourceXSLT
Pure SCH ph-schematron-pure SchematronResourcePure Is limited to XPath expressions. Can not handle XSLT expressions

Using the [Maven plugin] is a good way to convert the SCH files to XSLT files at build time.

Project modules

The project module structure was heavily reworked for version 6 to be more modular and flexible.

ph-schematron-api

This module contains the basic shared components used by the different implementation modules (see below). This module is always required.

It transitively depends on ph-commons, ph-xml, ph-jaxb, SLF4J and Saxon HE.

ph-schematron-xslt

This module uses the original XSLTs provided by the https://github.com/schematron/schematron project.

The dependency for ph-schematron-xslt looks like this, replacing x.y.z with the latest version number:

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

ph-schematron-schxslt

This module uses the XSLTs provided by the https://github.com/schxslt/schxslt project. This module was added for the v6 major release and might need additional tweeking, especially in the direction of parameters and configurability.

The dependency for ph-schematron-schxslt looks like this, replacing x.y.z with the latest version number:

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

ph-schematron-pure

Alternatively ph-schematron-pure offers a Java-native implementation for the Schematron XPath binding which offers superior performance over the XSLT approach but can only be used, if the Schematron rules consist purely of XPath expressions and don't contain any XSLT.

The dependency for ph-schematron-pure looks like this, replacing x.y.z with the latest version number:

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

Note: up to and including v5.x the Maven groupId was com.helger.

ph-schematron-validator

It is a validator for Schematron definitions based on RelaxNG definition. This is NOT for validation XML documents against Schematron rules.

Add the following to your pom.xml to use this artifact, replacing x.y.z with the latest version number:

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