Bug #2599
closedSchema validation errors are not reported through ErrorHandler
100%
Description
With the latest Saxon 9.7.0.2, not all the schema validation errors are not reported through the org.xml.sax.ErrorHandler interface. I'm using the SchemaFactory JAXP API for validating an XML instance against an XML Schema .
I can reproduce the problem by running the next Java Class:
public class SchemaValidation {
/**
* Error handler for collecting Saxon validation errors.
*/
private static ErrorHandler errorHandler = new ErrorHandler() {
@Override
public void warning(SAXParseException we) throws SAXException {
System.out.println("Warning: " + we);
}
@Override
public void fatalError(SAXParseException fe) throws SAXException {
System.out.println("Fatal error: " + fe);
}
@Override
public void error(SAXParseException ee) throws SAXException {
System.out.println("Error: " + ee);
}
};
public static void main(String[] args) throws SAXException, FileNotFoundException, IOException {
File schemaFile = new File("samples/validation/personal.xsd");
File xmlFile = new File("samples/validation/personal-schema.xml");
SchemaFactoryImpl schemaFactory = new com.saxonica.ee.jaxp.SchemaFactoryImpl();
// Set error handler
schemaFactory.setErrorHandler(errorHandler);
// Strict schema validation
schemaFactory.setProperty(FeatureKeys.SCHEMA_VALIDATION, Validation.STRICT);
Schema schema = schemaFactory.newSchema(schemaFile);
Validator newValidator = schema.newValidator();
newValidator.setErrorHandler(errorHandler);
newValidator.validate(new SAXSource(new InputSource(new FileInputStream(xmlFile))));
}
}
In my case, only one error is reported through ErrorHandler:
One or more validation errors were reported
The other errors are only visible in the console (System.err) without being reported through the error handler.
Files
Updated by O'Neil Delpratt almost 9 years ago
- Status changed from New to In Progress
- Assignee set to O'Neil Delpratt
- Found in version deleted (
9.7.0.2) - Applies to branch 9.7 added
Updated by O'Neil Delpratt almost 9 years ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
- Fix Committed on Branch 9.7 added
With the changes in Saxon 9.7 where we now report validation error via a InvalidityHandler we had not probably handled wrapping a ErrorHandler supplied by the user via JAXP API.
Bug fix applied in the ValidatorImpl class. The fix was to create a InvalidityHandler wrapper class for the ErrorHandler and set this on the PipelineConfiguration.
Updated by O'Neil Delpratt almost 9 years ago
- Status changed from Resolved to Closed
- Fixed in Maintenance Release 9.7.0.3 added
Bug fix applied in the Saxon 9.7.0.3 maintenance release.
Please register to edit this issue