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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations