Search in sources :

Example 1 with RootValidations

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;
}
Also used : XmlValidatorContentHandler(nl.nn.adapterframework.validation.XmlValidatorContentHandler) RootValidations(nl.nn.adapterframework.validation.RootValidations) XmlValidatorErrorHandler(nl.nn.adapterframework.validation.XmlValidatorErrorHandler) XPathExpressionException(javax.xml.xpath.XPathExpressionException) SOAPException(javax.xml.soap.SOAPException) SaxException(nl.nn.adapterframework.xml.SaxException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SOAPException (javax.xml.soap.SOAPException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 RootValidations (nl.nn.adapterframework.validation.RootValidations)1 XmlValidatorContentHandler (nl.nn.adapterframework.validation.XmlValidatorContentHandler)1 XmlValidatorErrorHandler (nl.nn.adapterframework.validation.XmlValidatorErrorHandler)1 SaxException (nl.nn.adapterframework.xml.SaxException)1 SAXException (org.xml.sax.SAXException)1 SAXParseException (org.xml.sax.SAXParseException)1