Reputation: 4478
I've been thinking about using Saxon 9.6 as XSD 1.1 validator with XSD Assertions. Is it possible to define my own error messages (not the default ones) using Saxon validator?
Upvotes: 0
Views: 557
Reputation: 163352
Several mechanisms come to mind.
First, you can define your own messages associated with assertions and indeed other facets:
http://www.saxonica.com/documentation/index.html#!schema-processing/extensions11/saxon.message
Second, you can send all validation messages to an XML report file, which you can then transform. Use -report:filename
on the Validate command line, or SchemaValidator.setValidityReporting()
in the s9api API. The format of the report file is defined by a schema which is available in the saxon-resources.zip
download file.
You could use an ErrorListener
as suggested by @kjhughes - the error information in the ValidationException
object passed to the ErrorListener is in quite a structured form - but (a) I think the XML report is easier to manipulate, and (b) we have found that in validation runs reporting a few hundred errors, the cost of creating the exception objects needed by the ErrorListener
interface can be quite a significant part of the overall run time. Java Exceptions weren't really designed for this purpose.
Upvotes: 1