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) {
if (LOG.isLoggable(Level.INFO)) {
LOG.logp(Level.INFO, classname, "resolveResource", MessageKeys.RESOLVE_RESOURCE, new Object[] {arg0, arg1, arg2, arg3, arg4});
}
return lsr.resolveResource(arg0, arg1, arg2, arg3, arg4);
}
});
validator.validate(new StreamSource(xml));