New XSLT2 implementation of ISO Schematron: SchXslt

Posted on December 5, 2018 by Rick Jelliffe

There is a promising looking new implementation of Schematron for XSLT2 up at GitHub, the Open Source SchXslt project.  Kudos to David Maus for developing this, and making it available.

It is intended as a drop-in replacement for the most common skeleton implementation (also on GitHub at Schematron), so it has individual include.xsl, expand.xsl, and compile.xsl stylesheets.  While it follows the skeleton architecture that I took from Oliver Becker  and students, it only handles XSLT2 and compile under XSLT2, which allows a deal of simplification and the opportunity for a much neater implementation.

It comes with an XProc library for running with Calabash.  (Because it has the same architecture as Schematron, the ant task on the Schematron repository could be trivially ported to use SchXslt.)

Whatfascinated me was is that the entire implementation, which includes phases, abstract rules, abstract patterns and even the new sch:properties elements, only takes 704 lines of code.  (And because the code is pretty-printed XSLT, over 1/3 of that is whitespace, end-tags or namespace declarations: so perhaps 400 lines of operational code. And most of the code is not complex.)    Contrast with how large an XSD implementation is, and how anti-functional XSD can be when pesky humans need to be involved.

(The only thing I could not see is handling sch:diagnostics, which are useful for example in conjunction with different language selections.  I suppose if you need it, you can lobby David Maus or — even better — make a sample implementation yourself and submit it to him.)

A very welcome addition to the Schematron ecosystem, as Schematron heads into its 19th birthday this month.