Auto-generating Standards from Schematron Schemas
by Rick Jelliffe
I've made a little stylesheet that converts Schematron schemas into ISO Standard annexes. Each pattern becomes a separate clause, and assertions are treated as constraints and report statements are treated as errors that must be reported. The stylesheet handles abstract rules and abstract patterns (though these are starting to go into XPath territory and so are borderline ugly), and the @see attribute. Phases are treated as conformance profiles. Diagnostics are stripped out, they might perhaps have some use in application standards rather than document standards.
As well as its assertions, Schematron allows quite a bit of rich text and titles. The stylesheet handles bullet and numbered lists, most kinds of inline styling. The output is validated against eh RELAX NG Compact schema from the draft TR that I was using. (I had to clean up numbered lists a little: the drft stylesheet provided its own autonumbering when using <ol>.)
So is this a serious idea? Actually, yes. Schematron was developed with the human aspect of schemas as a very high priority, unlike any other schema language that I am aware of. By design, it is intended to be useful for generating documentation suitable for domain experts rather than XPath developers. (I am working on a commercial product that provides this as part of a collaborative schema development environment; the betas look good.)
So I hope that as more organizations take up Schematron to specify part or all of their standards, they will adopt this kind of approach, so that they end up with standards with no gaps between what is required and what is validatable. Note that you can still make Schematron assertions even when there is no XPath to check it: so Schematron does not back you into the corner that other schema languages do, where you have no high level constructs to document constraints beyond the capability of the validation expression language: refer to Expressing untested and untestable constraints in Schematron.
The stylesheet and an example
Schematron Validation Reporting Language is a small language specified as part of ISO Schematron for representing the output of a validation,. It can then be transformed into lots of other uses.
First: here is the Schematron schema for SVRL, unchanged from the ISO standard except I added three IDs that were missing (the XSLT expects patterns to have IDs): Download file
Next, here is the XSLT script: Download file
Here is the output from the script, using the SC34 schema: Download file
And , here is that output then converted to HTML, using the draft previewing script from ISO. (The SourceForge project has an XSL-FO generator): Download file
As a bonus, here is a blank XSLT template with all the Schematron elements exposed, for anyone who wants to make their own complex pretty-printer/transformer for Schematron schemas:
Download file
The annex generated is, I think, pretty acceptable as a draft standard, especially since the schema was written as a real schema and not as text in a standard per se. Obviously some things can be improved, such as being consistent with 'should' and 'is', but I think this is a viable, useful and efficient approach to improving the quality of standards for XML vocabularies and document types.
1 Comments
Phil Fearon 2007-08-19 00:51:52 |
Your collaborative schema development environment, will this have improved support for XPath developers than we currently get?
|