Validating XML against multiple XSD

heat02

New Member
I have to validate a XML file against a schema. The problem is that the schema consists of 89 small .xsd files and is constructed using xsd:import (the size of the files is around 1kb). When I run my validator method the validation takes 30+ seconds. Is there any way to speed up the process?Here's the code I use for validation:\[code\]public boolean checkXML(String XMLFileName, String XSDFileName) { Source xmlFile = new StreamSource(new File(XMLFileName)); Source schemaFile = new StreamSource(new File(XSDFileName)); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); try { Schema schema = schemaFactory.newSchema(schemaFile); javax.xml.validation.Validator validator = schema.newValidator(); validator.validate(xmlFile); return true; } catch (SAXException e) { // Validation failed return false; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false;}\[/code\]
 
Back
Top