Implementation: Generates HTML pages: click on the errors and be taken to the element in the source.
Author: David Carlisle, Rick Jelliffe
Current version: 1999-11-1Intro: Schematron is a way of using XPath Paths and Expressions to validate that an XML file (file A) obeys certain rules, specified by the user in another XML file (file B).
Examples of user need for this might include:
- Checking that no element X is empty.
- Checking that element Y has no more than n element Z children.
- Checking that element P has element S as its parent.
- Checking that element T has an attribute att present.
- Checking the nesting depth of an element.
- Checking that an IDREF attribute references an element of the correct type.
It does that by using an XML file B, valid to the schema DTD, together with the schematron XSL file, to create an XSLT file (XSL file C).
This is then used with XML file A , to validate your XML file against the rules you have created!
Rules file (XML file B) + schematron.xsl => XSL file C Your XML file A + XSL file C => Report file.The report file finally output informs you of either exceptions (assert elements) or compliances (report elements) that you have specified.
Details: Here is an example of output. The example is WAI: see below for the data and schema.
schematron-report.xslis a Schematron that puts out the error messages as an HTML document with a link to an id that relates to the node (via generate-id(.)) that caused the error message.
verbid.xslis an xsl file that produces a <pre> listing of the original file, with every node annotated with an html name anchor with the XSL generated id.schematron-frame.html is a frameset document that you can look at that gives a listing of the error messages, clicking on one causes the file listing to scroll to the right place.
In this version the filenames are fixed so the output from the Schematron has to be called
schematron-errors.htmland the output from verbid.xsl has to be calledschematron-out.html"Downloading
Download the above files.
Running
So the order is
xt schemafile.xml schematron-report.xsl xxx.xsl xt testfile.xml xxx.xsl schematron-errors.html xt testfile.xml verbid.xsl schematron-out.html netscape schematron-frame.html
Demonstration Schematron Schema
Here are is a demonstration schema.
WAI: Web Accessability Inititative Guidelines
This schema has not been debugged yetget the idea: many of the WAI guidelines can be turned into a schema easily, so some parts don't work. But most of it works. You can . Here is the schema, and here is an evil test file. And here is the result, as generated by schematron-report.
Of course, any HTML in XML file or XHTML file can be used. The test file is certainly not good or even valid HTML (against the HTML DTDs). But you can see that this WAI schema does not require documents that are valid; it only is interested in validating the patterns that WAI is interested in. (Actually, I have just made each section in the WAI guidelines into a pattern: this perhaps is slack, since really a pattern should be a bunch or rules that are somehow interconnecting.)
Copyright (C) Rick Jelliffe, Academia Sinica Computing Centre. Thanks to David Pawson for the introductory material. The Schematron software and this page are available for any public use, under the conditions of the GPL or MPL, but please mention our names in any documentation or About screens for any products that uses it. Comments, fixes and upgrades welcome: email ricko@gate.sinica.edu.tw