Search in sources :

Example 1 with SaxException

use of nl.nn.adapterframework.xml.SaxException in project iaf by ibissource.

the class ConfigurationDigester method getDigester.

private Digester getDigester(Configuration configuration) throws ConfigurationException, ParserConfigurationException, SAXException {
    XMLReader reader = XmlUtils.getXMLReader(configuration);
    Digester digester = new Digester(reader) {

        // override Digester.createSAXException() implementations to obtain a clear unduplicated message and a properly nested stacktrace on IBM JDK
        @Override
        public SAXException createSAXException(String message, Exception e) {
            return SaxException.createSaxException(message, getDocumentLocator(), e);
        }

        @Override
        public SAXException createSAXException(Exception e) {
            return SaxException.createSaxException(null, getDocumentLocator(), e);
        }
    };
    digester.setUseContextClassLoader(true);
    digester.push(configuration);
    Resource digesterRulesResource = Resource.getResource(configuration, getDigesterRules());
    loadDigesterRules(digester, digesterRulesResource);
    if (validation) {
        digester.setValidating(true);
        digester.setNamespaceAware(true);
        digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
        URL xsdUrl = ClassUtils.getResourceURL(CONFIGURATION_VALIDATION_SCHEMA);
        if (xsdUrl == null) {
            throw new ConfigurationException("cannot get URL from [" + CONFIGURATION_VALIDATION_SCHEMA + "]");
        }
        digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdUrl.toExternalForm());
        XmlErrorHandler xeh = new XmlErrorHandler(CONFIGURATION_VALIDATION_SCHEMA);
        digester.setErrorHandler(xeh);
    }
    return digester;
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Digester(org.apache.commons.digester3.Digester) Resource(nl.nn.adapterframework.core.Resource) XMLReader(org.xml.sax.XMLReader) SaxException(nl.nn.adapterframework.xml.SaxException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) SAXParseException(org.xml.sax.SAXParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) URL(java.net.URL)

Example 2 with SaxException

use of nl.nn.adapterframework.xml.SaxException in project iaf by ibissource.

the class JsonWriter method startObject.

@Override
public void startObject() throws SAXException {
    try {
        writeSeparatingComma(false);
        stateStack.push(new NodeState(false));
        writer.write("{");
    } catch (IOException e) {
        throw new SaxException(e);
    }
}
Also used : SaxException(nl.nn.adapterframework.xml.SaxException) IOException(java.io.IOException)

Example 3 with SaxException

use of nl.nn.adapterframework.xml.SaxException in project iaf by ibissource.

the class JsonWriter method startObjectEntry.

@Override
public void startObjectEntry(String key) throws SAXException {
    try {
        writeSeparatingComma(true);
        writer.write("\"" + key + "\":");
    } catch (IOException e) {
        throw new SaxException(e);
    }
}
Also used : SaxException(nl.nn.adapterframework.xml.SaxException) IOException(java.io.IOException)

Example 4 with SaxException

use of nl.nn.adapterframework.xml.SaxException in project iaf by ibissource.

the class JsonWriter method startArray.

@Override
public void startArray() throws SAXException {
    try {
        writeSeparatingComma(false);
        stateStack.push(new NodeState(true));
        writer.write("[");
    } catch (IOException e) {
        throw new SaxException(e);
    }
}
Also used : SaxException(nl.nn.adapterframework.xml.SaxException) IOException(java.io.IOException)

Example 5 with SaxException

use of nl.nn.adapterframework.xml.SaxException in project iaf by ibissource.

the class XmlUtils method parseXml.

public static void parseXml(Resource resource, ContentHandler handler) throws IOException, SAXException {
    try {
        XMLReader reader = getXMLReader(resource, handler);
        reader.parse(resource.asInputSource());
    } catch (ParserConfigurationException e) {
        throw new SaxException("Cannot configure parser", e);
    }
}
Also used : SaxException(nl.nn.adapterframework.xml.SaxException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) XMLReader(org.xml.sax.XMLReader)

Aggregations

SaxException (nl.nn.adapterframework.xml.SaxException)12 IOException (java.io.IOException)8 SAXException (org.xml.sax.SAXException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 XMLReader (org.xml.sax.XMLReader)3 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 SenderException (nl.nn.adapterframework.core.SenderException)2 TimeoutException (nl.nn.adapterframework.core.TimeoutException)2 TransformerFilter (nl.nn.adapterframework.xml.TransformerFilter)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 TransformerException (javax.xml.transform.TransformerException)1 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)1 PipeStartException (nl.nn.adapterframework.core.PipeStartException)1 Resource (nl.nn.adapterframework.core.Resource)1