use of org.xml.sax.SAXParseException in project OpenAM by OpenRock.
the class LogMessageProviderBase method getXMLDoc.
private Document getXMLDoc() throws IOException {
Document xmlDoc = null;
try {
DocumentBuilder builder = XMLUtils.getSafeDocumentBuilder(true);
builder.setErrorHandler(new ValidationErrorHandler());
InputStream is = getClass().getClassLoader().getResourceAsStream(xmlDefinitionFilename);
if (is != null) {
xmlDoc = builder.parse(is);
} else {
throw new IOException(xmlDefinitionFilename + " cannot be found.");
}
} catch (SAXParseException e) {
Debug.error("LogMessageProviderBase.getXMLDoc", e);
} catch (SAXException e) {
Debug.error("LogMessageProviderBase.getXMLDoc", e);
} catch (ParserConfigurationException e) {
Debug.error("LogMessageProviderBase.getXMLDoc", e);
}
return xmlDoc;
}
use of org.xml.sax.SAXParseException in project OpenAM by OpenRock.
the class ValidationErrorHandler method getXMLDocument.
public static Document getXMLDocument(InputStream in) throws Exception {
try {
DocumentBuilder builder = getSafeDocumentBuilder(validating);
Document doc = builder.parse(in);
return doc;
} catch (SAXParseException pe) {
String msg = "\n" + pe.getMessage() + "\n";
Object[] params = { new Integer(pe.getLineNumber()) };
throw new Exception(msg + "XMLUtils.parser_error" + params);
} catch (SAXException sax) {
Object[] params = { sax.getMessage() };
throw new Exception("XMLUtils.exception_message" + params);
} catch (ParserConfigurationException pc) {
Object[] params = { pc.getMessage() };
throw new Exception("XMLUtils.invalid_xml_document" + params);
} catch (IOException ioe) {
Object[] params = { ioe.getMessage() };
throw new Exception("XMLUtils.invalid_input_stream" + params);
}
}
use of org.xml.sax.SAXParseException in project OpenAM by OpenRock.
the class ErrorHandlerAdaptor method propagateEvent.
private void propagateEvent(int severity, SAXParseException saxException) throws SAXException {
// get location info:
// sax locators simply use the location info embedded in the
// sax exception, dom locators keep a reference to their DOMScanner
// and call back to figure out where the error occurred.
ValidationEventLocator vel = locator.getLocation(saxException);
ValidationEventImpl ve = new ValidationEventImpl(severity, saxException.getMessage(), vel);
Exception e = saxException.getException();
if (e != null) {
ve.setLinkedException(e);
} else {
ve.setLinkedException(saxException);
}
// call the client's event handler.
host.handleEvent(ve, severity != ValidationEvent.FATAL_ERROR);
}
use of org.xml.sax.SAXParseException in project OpenAM by OpenRock.
the class ErrorHandlerAdaptor method propagateEvent.
private void propagateEvent(int severity, SAXParseException saxException) throws SAXException {
// get location info:
// sax locators simply use the location info embedded in the
// sax exception, dom locators keep a reference to their DOMScanner
// and call back to figure out where the error occurred.
ValidationEventLocator vel = locator.getLocation(saxException);
ValidationEventImpl ve = new ValidationEventImpl(severity, saxException.getMessage(), vel);
Exception e = saxException.getException();
if (e != null) {
ve.setLinkedException(e);
} else {
ve.setLinkedException(saxException);
}
// call the client's event handler.
host.handleEvent(ve, severity != ValidationEvent.FATAL_ERROR);
}
use of org.xml.sax.SAXParseException in project tdi-studio-se by Talend.
the class AutoConvertTypesUtils method load.
public static List<AutoConversionType> load(File file) {
beanList = new ArrayList<>();
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder analyseur = documentBuilderFactory.newDocumentBuilder();
analyseur.setErrorHandler(new ErrorHandler() {
@Override
public void error(final SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void fatalError(final SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void warning(final SAXParseException exception) throws SAXException {
throw exception;
}
});
Document document = analyseur.parse(file);
//$NON-NLS-1$
NodeList typeNodes = document.getElementsByTagName("conversionType");
for (int i = 0; i < typeNodes.getLength(); i++) {
Node typeNode = typeNodes.item(i);
NamedNodeMap typeAttributes = typeNode.getAttributes();
AutoConversionType typeObj = new AutoConversionType();
//$NON-NLS-1$
typeObj.setSourceDataType(typeAttributes.getNamedItem("source").getNodeValue());
//$NON-NLS-1$
typeObj.setTargetDataType(typeAttributes.getNamedItem("target").getNodeValue());
//$NON-NLS-1$
typeObj.setConversionFunction(typeAttributes.getNamedItem("function").getNodeValue());
beanList.add(typeObj);
}
} catch (Exception e) {
return beanList;
}
return beanList;
}
Aggregations