This page contains references to the first (and surely incomplete) implementation of a Java API for the Schematron. It is based on version 1.5 but doesn't make use of all the 1.5 features yet.
Authors: Anna Hovhannisian, Oliver Becker
Version: 0.1, 2001-04-02
The Schematron can be used as an approach for validating XML data based on patterns in trees. Since XSLT patterns and XPath expressions are the foundations of this approach, implementations of the Schematron are in general XSLT based. The output of an XSLT processor is the result of the validation process.
Applications which want to benefit from the Schematron approach need a way to to access the results of this validation process. Java based applications may use the API described on this page.
A Schematron generated validation stylesheet outputs a well-formed
XML instance, which can be access via specific methods of a
schematron.Result object. Since a preprocessor (called
meta-stylesheet) is responsible for the format of the validation result,
such a special preprocessor is part of the API package.
Outline of the validation result:
<RESULT>
<TITLE>The title of the schema</TITLE>
<element>
<ASSERT>violated assertions for element</ASSERT>
</element>
<element>
<REPORT>reported messages for element</REPORT>
</element>
...
</RESULT>
The Schematron Java API consists of 3 files contained in the package
schematron:
Validator: An object representing a single
Schematron schema, used to validate multiple XML instances.
Result: An object representing the result of a
Schematron based validation.
preprocessor.xslt: The meta-stylesheet for the
Schematron Java API
Schematron.javajava Schematron <schema.xml>
<xml-source.xml> [phase] [element]schema.xml is the Schematron schema,
xml-source.xml is the XML instance to be validated,
phase is the value which will be passed as
phase-parameter to the meta-stylesheet (if specified) and
element is the name of an element, whose
report and assert messages will be printed (if specified).
build.xml which may
be used with Ant.
Needed external classes:
lib subdirectory.
Ideally the meta-stylesheet for the Schematron Java API should use a
skeleton. Unfortunately the latest Xalan 2.0.1 (which implements the
TrAX API of JAXP 1.1) has still a bug with
xsl:namespace-alias of imported stylesheets.
Saxon 6.2.2 has a problem on UNIX platforms to resolve the URI of a
stylesheet which is given as a local file.
For this reason no skeleton is used, the preprocessor.xslt contained in the package is a standalone meta-stylesheet (a slightly extended skeleton1-5.xsl).
schematron.Result class.
Which methods with which return types are necessary for an easy
and convenient usage inside of a Java application?
ASSERT, REPORT, ... elements
is bad.
|