I am validating an xml instance against multiple XSD schemas. If validation fails, I want to determine which schema the xml instance failed against. The SAXParseException
does not contain enough information to determine this.
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Source[] sources = getXsdSources();
Schema schema = factory.newSchema(sources);
Validator validator = schema.newValidator();
try {
validator.validate(input);
} catch (SAXParseException e) {
// Error handling.
}