Running Validation from Ant

It is possible to use the Saxon schema validator using the standard Ant tasks xmlvalidate and schemavalidate. To use Saxon rather than Xerces as the validation engine, specify the attribute classname="", and make sure Saxon-EE is on the classpath.

The schema to be used for validation can be specified using the xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes in the instance document, or (in the case of the schemavalidate task) using the schemavalidate/schema child element or the schemavalidate/@noNamespaceFile or schemavalidate/@noNamespaceURL attributes.

The attributes lenient and fullchecking have no effect.

The child element schemavalidate/attribute can be used to set options. Any option defined by the constants in class net.sf.saxon.lib.FeatureKeys can be specified, provided the required value is expressible as a string (for boolean values, use "true" and "false"). Saxon also recognizes some property names defined by the Apache Xerces product, for compatibility.

Properties of particular interest include the following:



The filename where the Saxon-EE license file is found.

Class used to resolve URIs of schema documents.

strict or lax: determines whether validation fails if no element declaration can be found for the top-level element.

Log file to capture validation errors.

1.0 or 1.1 depending on the version of the XML Schema (XSD) Recommendation to be supported. Default is 1.0.