try {
SchemaFactory schemaFactory = SchemaFactory.newInstance(W3C_XML_SCHEMA);
Schema s = schemaFactory.newSchema(new StreamSource(schema));
Validator validator = s.newValidator();
final LSResourceResolver lsr = validator.getResourceResolver();
validator.setResourceResolver(new LSResourceResolver() {
public LSInput resolveResource(String arg0, String arg1, String arg2,
String arg3, String arg4) {
log.info("resolveResource(" + arg0 + "," + arg1 + "," + arg2 + ","
+ arg3 + "," + arg4 + ")");
return lsr.resolveResource(arg0, arg1, arg2, arg3, arg4);
}
});
validator.validate(new StreamSource(xml));