private void validateXML(DOMSource source) throws Exception {
URL schemaFile = new URL("http://www.csc.liv.ac.uk/~valli/modules.xsd");
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
Schema schema = schemaFactory.newSchema(schemaFile);
Validator validator = schema.newValidator();
DOMResult result = new DOMResult();
try {
validator.validate(source, result);
System.out.println("is valid");
} catch (SAXException e) {
System.out.println("not valid because " + e.getLocalizedMessage());
}
}
But this returns an error saying: Exception in thread "main" java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema -instance could be loaded
Is this a problem with my code or with the actual xsd file?