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="com.saxonica.ee.jaxp.ValidatingReader", 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.Feature 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:

Name

Value

http://saxon.sf.net/feature/licenseFileLocation

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

http://saxon.sf.net/feature/schemaURIResolverClass

Class used to resolve URIs of schema documents.

http://saxon.sf.net/feature/schema-validation-mode

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

http://saxon.sf.net/feature/standardErrorOutputFile

Log file to capture validation errors.

http://saxon.sf.net/feature/xsd-version

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