Converting XML Schemas to Schematron: (#3) post processing the Schematron schema

This article first appeared on a blog at O'Reilly on October 26, 2007.  Links have not been checked.

I’m going to jump to the end now. Here is a little XSLT stylesheet that is a little specialist, and probably not much use outside this application, but if anyone else is autogenerating large Schematron schemas using lot of simple abstract rules, it may be useful.

Our XSD to Schematron implementation generates large Schematron schemas. We knew they would, but small is beautiful. This script trims the generated schema down by merging some kinds of rules.

We use Schematron abstract rules for handing data typing: there can be quite a lot of rules containing just the same sch:extends element and value. In a trial for merging these we brought a 9000 line generated schema down to about 5000 line; not bad.

Download file COMPRESS.XSLT