Implementation: Generates standard messages in the format used by emacs and XED: plug it in and use it in interactive editors.
Author: Rick Jelliffe
Current version: 2001-02-15
Requires: any XSLT implementation which sends xml:message to output (standard error?) with the correct file and line number information. XT does this.
Intro: 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). File B is called a schematron schema instance.
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-message.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.
Download the file schematron-message.xsl and the file skeleton1-5.xsl. You need an XSLT implementation with the correct behaviour too, e.g. XT from jclark.com
So the order isxt schemafile.xml schematron-message.xsl xxx.xsl xt datafile.xml xxx.xsl
If you are using another XSLT processor, you may find the Connect utility useful.
Demonstration Schematron Schema
Here are is a demonstration schema.
WAI: Web Accessability Inititative Guidelines
Many of the WAI guidelines can be turned into a schema easily. Here is the schema, and here is an evil test file. And here is part of the result:file:/project3/xml/public_html/resource/schematron/schematron-message/waitest.xml:12: (1.1) An image element should have some descriptive text: an alt or longdesc attribute. (Web Content Accessibility Guidelines 1.0, Guideline 1) file:/project3/xml/public_html/resource/schematron/schematron-message/waitest.xml:15: (1.1) An input element should have some descriptive text: an alt or longdesc attribute. (Web Content Accessibility Guidelines 1.0, Guideline 1) file:/project3/xml/public_html/resource/schematron/schematron-message/waitest.xml:18: (1.1) An applet element should have some descriptive text: an alt or longdesc attribute. (Web Content Accessibility Guidelines 1.0, Guideline 1) file:/project3/xml/public_html/resource/schematron/schematron-message/waitest.xml:20: (1.1) A map element should have some descriptive text: an alt attribute or a link. (Web Content Accessibility Guidelines 1.0, Guideline 1)generated by schematron-message.
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.
Copyright (C) 2000,2001 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 email@example.com