Search in sources :

Example 1 with DomDocumentImpl

use of org.camunda.bpm.model.xml.impl.instance.DomDocumentImpl in project camunda-xml-model by camunda.

the class DomUtil method parseInputStream.

/**
 * Create a new DOM document from the input stream
 *
 * @param documentBuilderFactory the factory to build to DOM document
 * @param inputStream the input stream to parse
 * @return the new DOM document
 * @throws ModelParseException if a parsing or IO error is triggered
 */
public static DomDocument parseInputStream(DocumentBuilderFactory documentBuilderFactory, InputStream inputStream) {
    try {
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        documentBuilder.setErrorHandler(new DomErrorHandler());
        return new DomDocumentImpl(documentBuilder.parse(inputStream));
    } catch (ParserConfigurationException e) {
        throw new ModelParseException("ParserConfigurationException while parsing input stream", e);
    } catch (SAXException e) {
        throw new ModelParseException("SAXException while parsing input stream", e);
    } catch (IOException e) {
        throw new ModelParseException("IOException while parsing input stream", e);
    }
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) ModelParseException(org.camunda.bpm.model.xml.ModelParseException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) DomDocumentImpl(org.camunda.bpm.model.xml.impl.instance.DomDocumentImpl) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ModelParseException (org.camunda.bpm.model.xml.ModelParseException)1 DomDocumentImpl (org.camunda.bpm.model.xml.impl.instance.DomDocumentImpl)1 SAXException (org.xml.sax.SAXException)1