use of org.openforis.collect.manager.exception.SurveyValidationException in project collect by openforis.
the class SurveyValidator method validateAgainstSchema.
public void validateAgainstSchema(InputStream is, Version version) throws SurveyValidationException {
try {
SchemaFactory factory = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
String[] schemaFileNames = getSchemaFileNames(version);
Source[] schemas = getSourcesFromClassPath(schemaFileNames);
javax.xml.validation.Schema schema = factory.newSchema(schemas);
Validator validator = schema.newValidator();
validator.validate(new StreamSource(is));
} catch (SAXException e) {
throw new SurveyValidationException(e);
} catch (IOException e) {
throw new SurveyValidationException(e.getMessage(), e);
}
}
Aggregations