We should package it all in one jar file (schematron-ant.jar) so that it is just as simple as dropping the jar file in the Ant lib directory.
In other words, it should contain the Java classes and the required XSLT meta-template, so that there is no dependency on anything else.
It should not be trivial, it should be Monkey-proof!
The configuration of the XSLT transformer should be inherited from the JAXP properties.
They should allow the Ant task to:
This task checks that the XML are valid against a set of ISO Schematron constraints.
The task uses the XSLT transformer implementation provided by JAXP by default.
To use the schematron task, you must include a taskdef in your project file.
<taskdef name="schematron" classname="com.topologi.ant.Schematron"/>
Alternatively, you can add the schematron task to your list of ant task definitions.
Attribute | Description | Required |
---|---|---|
schema | the path to the schematron schema file. | Yes |
file | the file(s) you want to check. (optionally can use an embedded fileset) | Only if no fileset is defined |
phase | the ISO Schematron phase to use (ignored if no phase was specified in the schema) | No |
queryLanguageBinding | the expresion language or schema language version to use. values: "xslt" (default), "xslt2", "xpath" "xpath2", "1.5", "1.6", "old" | No |
A fileset Ant concept can be used in order to process a list of files.
Validates test.xml
against the set of Schematron constraints in
test.sch
.
<schematron schema="test.sch"> <fileset dir="test" includes="**/*.xml"/> </schematron>
Validates all the XML files in the 'test' directory using the ISO Schematron constraints
defined in test.sch
.
<schematron schema="test.sch" phase="critical"> <fileset dir="test" includes="**/*.xml"/> </schematron>
Validates all the XML files in the 'test' directory using the ISO Schematron constraints
defined in test.sch
and specifying the phase critical
<?xml version="1.0"?> <project name="SchematronExample" default="validate" basedir="."> <target name="validate"> <taskdef name="schematron" classname="com.topologi.ant.SchematronTask" classpath="../lib/ant-schematron.jar"/> <schematron schema="test.sch"> <fileset dir="xml" includes="**/*.xml"/> </schematron> </target> </project>
Complete example of a project validating files with Schematron.