use of nl.nn.adapterframework.validation.RootValidations in project iaf by ibissource.
the class XmlUtils method isWellFormed.
public static boolean isWellFormed(Message input, String root) {
RootValidations rootValidations = null;
if (StringUtils.isNotEmpty(root)) {
rootValidations = new RootValidations(root);
}
XmlValidatorContentHandler xmlHandler = new XmlValidatorContentHandler(null, rootValidations, null, true);
XmlValidatorErrorHandler xmlValidatorErrorHandler = new XmlValidatorErrorHandler(xmlHandler, "Is not well formed");
xmlHandler.setXmlValidatorErrorHandler(xmlValidatorErrorHandler);
try {
// set ErrorHandler to prevent message in System.err: [Fatal Error] :-1:-1: Premature end of file.
parseXml(input.asInputSource(), xmlHandler, xmlValidatorErrorHandler);
} catch (Exception e) {
return false;
}
return true;
}
Aggregations