Skip to content
An XSLT-based Schematron processor.
Branch: master
Clone or download
Latest commit 4458674 May 23, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs/api Add API documentation Apr 11, 2019
lib Downgrade to XSpec v1.1.0 Feb 20, 2019
src Properly resolve samedoc reference May 23, 2019
.gitignore Unignore lib/xspec Feb 20, 2019
.gitmodules Add XSpec as subproject Feb 20, 2019
LICENSE Update copyright date Feb 16, 2019
Makefile Add make target clean Feb 16, 2019
README.md Add information about API in README Apr 11, 2019
pom.xml [java] Schematron JAXP validation Apr 17, 2019

README.md

SchXslt [ʃˈɛksl̩t] – An XSLT-based Schematron processor

SchXslt is copyright (c) 2018,2019 by David Maus <dmaus@dmaus.name> and released under the terms of the MIT license.

DOI

SchXslt is a conforming Schematron processor implemented entirely in XSLT. It operates as a three-stage transformation process that translates a Schematron to an XSLT validation stylesheet. This stylesheet outputs a validation report in the Schematron Validation Report Language (SVRL) when applied to an instance document.

With this respect it operates much like the "skeleton" implementation by Rick Jelliffe and others. It differes from the "skeleton" in that it only supports XSLT 2 aus query language binding and requires an XSLT processor supporting XSLT 2.0 or higher.

Compiling Schematron to validation stylesheet

Step 1: Incorporate external definitions

All external definitions referenced by sch:include and sch:extends are recursively copied into the source Schematron. The base URI of external definitions is preserved such that relative URI references still resolve to the right documents.

This step can be skipped if the Schematron does not reference external definitions.

The responsible stylesheet is include.xsl.

saxon -xsl:src/main/resources/xslt/include.xsl -o:stage-1.sch </path/to/schematron>

Step 2: Expand abstract patterns and rules

Abstract patterns and rules are instantiated.

This step can be skipped if the Schematron does not define abstract patterns or rules.

The responsible stylesheet is expand.xsl.

saxon -xsl:src/main/resources/xslt/expand.xsl -o:stage-2.sch stage-1.sch

Step 3: Compile validation stylesheet

Compiles an XSLT 2.0 validation stylesheet that creates an SVRL report document.

The responsible stylesheet is compile-for-svrl.xsl.

This stylesheet takes an optional argument 'phase' to validate in the selected phase. If no phase is requested the value of the @defaultPhase attribute is used if present. Otherwise, it defaults to phase '#ALL' and validates all patterns.

saxon -xsl:src/main/resources/xslt/compile-for-svrl.xsl -o:stage-3.xsl stage-2.sch [phase=myphase]

Using XProc

With an XProc 1.0 processor installed you can create the validation stylesheet with the step compile-schematron.xpl.

calabash -i </path/to/schematron> -o:stage-3.xsl src/main/resources/xproc/compile-schematron.xpl

Lastly, SchXslt comes with another XProc step validate-with-schematron.xpl that performs schematron validation using SchXslt's stylesheets. To run it from the command line you have to pipe the document to validate in the input port source, and the Schematron in the input port schema. The step sends the validation report to the result output port.

calabash -i source=</path/to/document> -i schema=</path/to/schema> src/main/resources/xproc/validate-with-schematron.xpl

The callback API

SchXslt lets you customize the parts of the validation stylesheet that report on active patterns, fired rule, failed assertions, and successful reports. The compiler calls named templates in the https://doi.org/10.5281/zenodo.1495494#api namespace that are expected to create the part of the validation stylesheet that handles respective reporting.

You can find the API documentation in the docs/api directory.

Testsuite

SchXslt comes with a set of https://github.com/xspec/xspec definitions that test internals of the processor (test/resources/impl) and SchXslt against the ISO specification (test/resources/spec).

The test runner relies on XProc XSpec and XSpec to be installed as Git submodules in the lib/ directory.

To execute the test suite run the runner with Calabash.

calabash src/test/resources/runner.xpl
You can’t perform that action at this time.