Example usage for javax.xml.parsers ParserConfigurationException getMessage

List of usage examples for javax.xml.parsers ParserConfigurationException getMessage

Introduction

In this page you can find the example usage for javax.xml.parsers ParserConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.kuali.kra.s2s.validator.OpportunitySchemaParser.java

/**
 * This method fetches all the forms required from a given schema of opportunity
 * // w  w  w. j  a v  a2  s. c o m
 * @param schema {@link String}
 * @return {@link HashMap} containing all form information
 */
public ArrayList<S2sOppForms> getForms(String schema) throws S2SException {
    boolean mandatory;
    boolean available;
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    domFactory.setNamespaceAware(true);
    DocumentBuilder builder = null;
    ArrayList<S2sOppForms> schemaList = new ArrayList<S2sOppForms>();
    Document document;
    try {
        builder = domFactory.newDocumentBuilder();
        InputStream is = (InputStream) new URL(schema).getContent();
        document = builder.parse(is);
    } catch (ParserConfigurationException e) {
        LOG.error(S2SConstants.ERROR_MESSAGE, e);
        throw new S2SException(KeyConstants.ERROR_GRANTSGOV_FORM_PARSING, e.getMessage(), schema);
    } catch (SAXException e) {
        LOG.error(S2SConstants.ERROR_MESSAGE, e);
        throw new S2SException(KeyConstants.ERROR_GRANTSGOV_FORM_PARSING_SAXEXCEPTION, e.getMessage(), schema);
    } catch (IOException e) {
        LOG.error(S2SConstants.ERROR_MESSAGE, e);
        throw new S2SException(KeyConstants.ERROR_GRANTSGOV_FORM_SCHEMA_NOT_FOUND, e.getMessage(), schema);
    }

    Element schemaElement = document.getDocumentElement();
    NodeList importList = document.getElementsByTagNameNS(XSD_NS, IMPORT);
    Node allForms = document.getElementsByTagNameNS(XSD_NS, ALL).item(0);
    NodeList formsList = ((Element) allForms).getElementsByTagNameNS(XSD_NS, ELEMENT);
    String[] formNames = new String[formsList.getLength()];

    for (int formIndex = 0; formIndex < formsList.getLength(); formIndex++) {
        Node form = formsList.item(formIndex);
        String fullFormName = ((Element) form).getAttribute(REF);
        String formName = fullFormName.substring(0, fullFormName.indexOf(CH_COLON));
        String minOccurs = ((Element) form).getAttribute(MIN_OCCURS);
        String nameSpace = schemaElement.getAttribute(XMLNS + formName);
        FormMappingInfo info = null;
        try {
            info = new FormMappingLoader().getFormInfo(nameSpace);
        } catch (S2SGeneratorNotFoundException e) {
        }
        String displayFormName = info == null ? formName : info.getFormName();
        formNames[formIndex] = nameSpace;
        for (int impIndex = 0; impIndex < importList.getLength(); impIndex++) {
            Node importNode = importList.item(impIndex);
            if (((Element) importNode).getAttribute(NAMESPACE).equalsIgnoreCase(nameSpace)) {
                String schemaUrl = ((Element) importNode).getAttribute(SCHEMA_LOCATION);
                S2sOppForms oppForm = new S2sOppForms();
                oppForm.setFormName(displayFormName);
                oppForm.setOppNameSpace(nameSpace);
                oppForm.setSchemaUrl(schemaUrl);
                mandatory = (minOccurs == null || minOccurs.trim().equals("")
                        || Integer.parseInt(minOccurs) > 0);
                oppForm.setMandatory(mandatory);
                available = info != null;//isAvailable(nameSpace);
                oppForm.setAvailable(available);
                oppForm.setInclude(mandatory && available);
                schemaList.add(oppForm);
            }
        }
    }
    return schemaList;
}

From source file:org.kuali.ole.module.purap.service.impl.ElectronicInvoiceHelperServiceImpl.java

protected byte[] addNamespaceDefinition(ElectronicInvoiceLoad eInvoiceLoad, File invoiceFile) {

    boolean result = true;

    if (LOG.isInfoEnabled()) {
        LOG.info("Adding namespace definition");
    }// w  w w .  j  ava2  s.  c  o  m

    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setValidating(false); // It's not needed to validate here
    builderFactory.setIgnoringElementContentWhitespace(true);

    DocumentBuilder builder = null;
    try {
        builder = builderFactory.newDocumentBuilder(); // Create the parser
    } catch (ParserConfigurationException e) {
        LOG.error("Error getting document builder - " + e.getMessage());
        throw new RuntimeException(e);
    }

    Document xmlDoc = null;

    try {
        xmlDoc = builder.parse(invoiceFile);
    } catch (Exception e) {
        if (LOG.isInfoEnabled()) {
            LOG.info("Error parsing the file - " + e.getMessage());
        }
        rejectElectronicInvoiceFile(eInvoiceLoad, UNKNOWN_DUNS_IDENTIFIER, invoiceFile, e.getMessage(),
                PurapConstants.ElectronicInvoice.FILE_FORMAT_INVALID);
        return null;
    }

    Node node = xmlDoc.getDocumentElement();
    Element element = (Element) node;

    String xmlnsValue = element.getAttribute("xmlns");
    String xmlnsXsiValue = element.getAttribute("xmlns:xsi");

    File namespaceAddedFile = getInvoiceFile(invoiceFile.getName());

    if (StringUtils.equals(xmlnsValue, "http://www.kuali.org/ole/purap/electronicInvoice")
            && StringUtils.equals(xmlnsXsiValue, "http://www.w3.org/2001/XMLSchema-instance")) {
        if (LOG.isInfoEnabled()) {
            LOG.info("xmlns and xmlns:xsi attributes already exists in the invoice xml");
        }
    } else {
        element.setAttribute("xmlns", "http://www.kuali.org/ole/purap/electronicInvoice");
        element.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    }

    OutputFormat outputFormat = new OutputFormat(xmlDoc);
    outputFormat.setOmitDocumentType(true);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    XMLSerializer serializer = new XMLSerializer(out, outputFormat);
    try {
        serializer.asDOMSerializer();
        serializer.serialize(xmlDoc.getDocumentElement());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    if (LOG.isInfoEnabled()) {
        LOG.info("Namespace validation completed");
    }

    return out.toByteArray();

}

From source file:org.limy.common.xml.XmlUtils.java

private static DocumentBuilder createBuilder() {
    try {/*from   w  w w .  ja va 2s.co m*/
        return FACTORY.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        LOG.error(e.getMessage(), e);
    }
    return null;
}

From source file:org.methodize.nntprss.admin.AdminServlet.java

private void cmdImportNntpRssChannelConfig(HttpServletResponse response, MultiPartRequest mpRequest)
        throws ServletException, IOException {

    Writer writer = response.getWriter();
    writeHeader(writer, TAB_CONFIG);/*from  ww  w  .ja  v a2  s  .  co m*/

    ChannelManager channelManager = (ChannelManager) getServletContext()
            .getAttribute(AdminServer.SERVLET_CTX_RSS_MANAGER);

    writer.write("<b>Import status</b><p>");

    List errors = new ArrayList();
    int channelsAdded = 0;

    // Parse XML
    try {
        DocumentBuilder db = AppConstants.newDocumentBuilder();
        Document doc = db.parse(mpRequest.getInputStream("file"));
        Element docElm = doc.getDocumentElement();
        NodeList channels = docElm.getElementsByTagName("channel");

        for (int channelCount = 0; channelCount < channels.getLength(); channelCount++) {
            Element chanElm = (Element) channels.item(channelCount);

            String name = chanElm.getAttribute("name");
            String urlString = chanElm.getAttribute("url");
            boolean historical = false;
            Node historicalNode = chanElm.getAttributeNode("historical");
            if (historicalNode != null) {
                historical = historicalNode.getNodeValue().equalsIgnoreCase("true");
            }

            long expiration = Channel.EXPIRATION_KEEP;
            Node expirationNode = chanElm.getAttributeNode("expiration");
            if (expirationNode != null) {
                expiration = Long.parseLong(expirationNode.getNodeValue());
            } else {
                expiration = historical ? Channel.EXPIRATION_KEEP : 0;
            }

            String categoryName = chanElm.getAttribute("category");

            // Check name...
            List currentErrors = new ArrayList();
            Channel existingChannel = channelManager.channelByName(name);

            if (name.length() == 0) {
                currentErrors.add("Channel with empty name - URL=" + urlString);
            } else if (name.indexOf(' ') > -1) {
                currentErrors.add("Channel name cannot contain spaces - name=" + name);
            } else if (existingChannel != null) {
                currentErrors.add("Channel name " + name + " is already is use");
            }

            if (urlString.length() == 0) {
                currentErrors.add("URL cannot be empty, channel name=" + name);
            } else if (urlString.equals("http://") || urlString.equals("https://")) {
                currentErrors.add("You must specify a URL, channel name=" + name);
            } else if (!urlString.startsWith("http://") && !urlString.startsWith("https://")) {
                currentErrors.add("Only URLs starting http:// or https:// are supported, channel name=" + name
                        + ", url=" + urlString);
            }

            if (existingChannel == null) {

                Channel newChannel = null;
                if (currentErrors.size() == 0) {
                    try {
                        newChannel = new Channel(name, urlString);
                        //                     newChannel.setHistorical(historical);
                        newChannel.setExpiration(expiration);
                        channelManager.addChannel(newChannel);
                        channelsAdded++;
                    } catch (MalformedURLException me) {
                        errors.add("Channel " + name + " - URL (" + urlString + ") is malformed");
                    }
                }

                if (categoryName.length() > 0) {
                    //Handle category...
                    Category category = channelManager.categoryByName(categoryName);
                    if (category == null) {
                        // Need to create category...
                        category = new Category();
                        category.setName(categoryName);
                        channelManager.addCategory(category);
                    }
                    category.addChannel(newChannel);
                    newChannel.setCategory(category);
                    newChannel.save();
                }

                // Removed channel validation... channels will be validated
                // on next iteration of channel poller - will be highlighted
                // in channel list if invalid
                // Validate channel...
                //               if(Channel.isValid(new URL(urlString))) {
                //// Add channel...
                //                  Channel newChannel = null;
                //                  if(currentErrors.size() == 0) {
                //                     try {
                //                        newChannel = new Channel(name, urlString);
                //                        newChannel.setHistorical(historical);
                //                        channelManager.addChannel(newChannel);
                //                        channelsAdded++;
                //                     } catch(MalformedURLException me) {
                //                        errors.add("Channel " + name + " - URL (" 
                //                           + urlString + ") is malformed");
                //                     }
                //                  }            
                //                  
                //               } else {
                //// URL points to invalid document
                //                  errors.add("Channel " + name + "'s URL (" + urlString + ") "
                //                     + "points to an invalid document");
                //               }
            }

            errors.addAll(currentErrors);

        }
    } catch (SAXException se) {
        errors.add("There was an error parsing your channel file:<br>" + se.getMessage());
    } catch (ParserConfigurationException pce) {
        errors.add("There was a problem reading your channelf file:<br>" + pce.getMessage());
    }

    // Display any errors encountered during parsing...
    if (errors.size() > 0) {
        writer.write("Problems were encountered while adding channels.<p>");
        writeErrors(writer, errors);

        if (channelsAdded > 0) {
            writer.write("<p>" + channelsAdded + " channel(s) were successfully imported.");
        }
    } else {
        if (channelsAdded > 0) {
            writer.write("<p>" + channelsAdded + " channel(s) were successfully imported.");
        } else {
            writer.write("The configuration file did not contain any channels!");
        }
    }

    writeFooter(writer);
    writer.flush();

}

From source file:org.methodize.nntprss.admin.AdminServlet.java

private void cmdImportOpmlChannelConfigValidate(HttpServletResponse response, MultiPartRequest mpRequest)
        throws ServletException, IOException {

    Writer writer = response.getWriter();
    writeHeader(writer, TAB_CONFIG);/*  w w  w . j  av a2s.  c  o  m*/

    writeCheckboxSelector(writer, "checkAllImport", "import", "channels");

    writer.write("<b>mySubscriptions.opml validation</b><p>");

    List errors = new ArrayList();

    // Parse XML
    try {
        DocumentBuilder db = AppConstants.newDocumentBuilder();
        Document doc = db.parse(mpRequest.getInputStream("file"));
        Element docElm = doc.getDocumentElement();

        NodeList channels = docElm.getElementsByTagName("outline");
        if (channels.getLength() > 0) {

            writer.write("<form name='channels' action='?action=importopml' method='POST'>");
            writer.write("<table class='tableBorder'><tr><th>Import<br>"
                    + "<input type='checkbox' name='changeImport' onClick='checkAllImport(this);' checked>"
                    + "</th><th>Channel Name</th><th>Expiration" + "</th><th>URL</th></tr>");

            int channelCount = 0;
            for (int chlLoopCounter = 0; chlLoopCounter < channels.getLength(); chlLoopCounter++) {
                Element chanElm = (Element) channels.item(chlLoopCounter);

                String name = fixChannelName(chanElm.getAttribute("title"));
                String urlString = chanElm.getAttribute("xmlUrl");
                if (urlString == null || urlString.length() == 0) {
                    urlString = chanElm.getAttribute("xmlurl");
                }

                if (urlString == null || urlString.length() == 0) {
                    continue;
                }

                if (name.length() == 0) {
                    name = createChannelName(urlString);
                }

                String rowClass = (((channelCount % 2) == 1) ? "row1" : "row2");

                writer.write("<tr>" + "<td class='" + rowClass
                        + "' align='center'><input type='checkbox' name='import" + channelCount
                        + "' checked></td>" + "<td class='" + rowClass
                        + "'><input type='value' size='50' name='name" + channelCount + "' value='"
                        + HTMLHelper.escapeString(name) + "'></td>" + "<td class='" + rowClass
                        + "' align='center'>" + "<select name='expiration" + channelCount + "'>");

                long expiration = Channel.EXPIRATION_KEEP;

                writeOption(writer, "Keep all items", Channel.EXPIRATION_KEEP, expiration);
                writeOption(writer, "Keep only current items", 0, expiration);
                writeOption(writer, "Keep items for 1 day", (1000 * 60 * 60 * 24 * 1), expiration);
                writeOption(writer, "Keep items for 2 days", (1000 * 60 * 60 * 24 * 2), expiration);
                writeOption(writer, "Keep items for 4 days", (1000 * 60 * 60 * 24 * 4), expiration);
                writeOption(writer, "Keep items for 1 week", (1000 * 60 * 60 * 24 * 7), expiration);
                writeOption(writer, "Keep items for 2 weeks", (1000 * 60 * 60 * 24 * 14), expiration);
                writeOption(writer, "Keep items for 4 weeks", (1000 * 60 * 60 * 24 * 28), expiration);

                writer.write("</select></td>" + "<td class='" + rowClass + "' ><input type='hidden' name='url"
                        + channelCount + "' value='" + HTMLHelper.escapeString(urlString) + "'>"
                        + HTMLHelper.escapeString(urlString) + "</td></tr>\n");

                channelCount++;
            }

            writer.write(
                    "<tr><td align='center' class='row2' colspan='4'><input type='submit' value='Import Channels'></td></tr>");
            writer.write("</table></form>");
        } else {
            writer.write(
                    "Your mySubscriptions.opml file did not contain any channels, or was in an invalid format.<p>");
        }

    } catch (SAXException se) {
        errors.add("There was an error parsing your channel file:<br>" + se.getMessage());
    } catch (ParserConfigurationException pce) {
        errors.add("There was a problem reading your channelf file:<br>" + pce.getMessage());
    }

    // Display any errors encountered during parsing...
    if (errors.size() > 0) {
        writer.write("Problems were encountered while adding channels.<p>");
        writeErrors(writer, errors);
    }

    writeFooter(writer);
    writer.flush();

}

From source file:org.mule.devkit.maven.MashapeGeneratorMojo.java

private void generateMashapeClient(File inputFile) throws MojoExecutionException {
    if (mashapeName == null) {
        throw new MojoExecutionException("You must specify a mashapeName");
    }// w w w  .j av  a  2 s.c  om
    if (mashapeVersion == null) {
        throw new MojoExecutionException("You must specify a mashapeVersion");
    }
    if (mashapeProxyHost == null) {
        throw new MojoExecutionException("You must specify a mashapeProxyHost");
    }

    getLog().info("Generating POJO for " + inputFile.getAbsolutePath());

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    DocumentBuilder db = null;
    try {
        db = factory.newDocumentBuilder();
        Document dom = db.parse(inputFile);

        DefinedClass clazz = codeModel._class(Modifier.ABSTRACT | Modifier.PUBLIC,
                "org.mule.modules.tinypayme.TinyPayMeConnector", ClassType.CLASS);
        clazz.javadoc()
                .add("Unkown\n\nAutomatically generated from Mashape XML file\n\n@author MuleSoft, Inc.");
        AnnotationUse moduleAnnotation = clazz.annotate(Module.class);
        moduleAnnotation.param("name", mashapeName);
        moduleAnnotation.param("schemaVersion", mashapeVersion);

        FieldVariable mashapePrivateKey = generateMashapePrivateKey(clazz);
        FieldVariable mashapePublicKey = generateMashapePublicKeyField(clazz);
        FieldVariable mashapeAuthorization = generateMashapeAuthorizationField(clazz);

        generateInit(clazz, mashapePrivateKey, mashapePublicKey, mashapeAuthorization);

        Node api = dom.getElementsByTagName("api").item(0);
        NodeList methods = api.getChildNodes();
        for (int i = 0; i < methods.getLength(); i++) {
            Node method = methods.item(i);

            if (!"method".equals(method.getNodeName())) {
                continue;
            }

            Method restCallMethod = clazz.method(Modifier.PUBLIC | Modifier.ABSTRACT, ref(String.class),
                    method.getAttributes().getNamedItem("name").getNodeValue());
            restCallMethod._throws(ref(IOException.class));
            restCallMethod.annotate(Processor.class);
            AnnotationUse restCall = restCallMethod.annotate(RestCall.class);

            Node url = null;
            for (int j = 0; j < method.getChildNodes().getLength(); j++) {
                if (!"url".equals(method.getChildNodes().item(j).getNodeName())) {
                    continue;
                }

                url = method.getChildNodes().item(j);
                break;
            }

            String uri = url.getTextContent();
            if (uri.contains("?")) {
                uri = uri.split("\\?")[0];
            }
            restCall.param("uri", "https://" + mashapeProxyHost + uri);

            if ("GET".equals(method.getAttributes().getNamedItem("http").getNodeValue())) {
                restCall.param("method", ref(HttpMethod.class).staticRef("GET"));
            } else if ("PUT".equals(method.getAttributes().getNamedItem("http").getNodeValue())) {
                restCall.param("method", ref(HttpMethod.class).staticRef("PUT"));
            } else if ("POST".equals(method.getAttributes().getNamedItem("http").getNodeValue())) {
                restCall.param("method", ref(HttpMethod.class).staticRef("POST"));
            }

            Node parameters = null;
            for (int j = 0; j < method.getChildNodes().getLength(); j++) {
                if (!"parameters".equals(method.getChildNodes().item(j).getNodeName())) {
                    continue;
                }

                parameters = method.getChildNodes().item(j);
                break;
            }

            for (int j = 0; j < parameters.getChildNodes().getLength(); j++) {
                if (!"parameter".equals(parameters.getChildNodes().item(j).getNodeName())) {
                    continue;
                }

                Node parameter = parameters.getChildNodes().item(j);

                Variable restCallParameter = restCallMethod.param(ref(String.class),
                        StringUtils.uncapitalize(camel(parameter.getTextContent())));

                if (uri.contains("{" + parameter.getTextContent() + "}")) {
                    AnnotationUse restUriParam = restCallParameter.annotate(ref(RestUriParam.class));
                    restUriParam.param("value", parameter.getTextContent());
                } else {
                    AnnotationUse restQueryParam = restCallParameter.annotate(ref(RestQueryParam.class));
                    restQueryParam.param("value", parameter.getTextContent());
                }

                if (parameter.getAttributes().getNamedItem("optional") != null
                        && "true".equals(parameter.getAttributes().getNamedItem("optional").getNodeValue())) {
                    restCallParameter.annotate(ref(Optional.class));
                }
            }

        }

        codeModel.build();
    } catch (ParserConfigurationException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (SAXException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (IOException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (ClassAlreadyExistsException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}

From source file:org.opencastproject.scheduler.impl.CalendarGenerator.java

/**
 * Returns provided Dublin Core as String or null of serialization fails.
 * //from   ww w .  jav a 2 s  .  c  o m
 * @param catalog
 *          {@link DublinCoreCatalog} to be serialized
 * @return string representation of DC
 */
private String getDublinCoreAsString(DublinCoreCatalog catalog) {
    try {
        Document doc = catalog.toXml();

        Source source = new DOMSource(doc);
        StringWriter stringWriter = new StringWriter();
        Result result = new StreamResult(stringWriter);
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
        transformer.transform(source, result);

        return stringWriter.getBuffer().toString().trim();
    } catch (ParserConfigurationException e) {
        logger.error("Could not parse DublinCoreCatalog for Series: {}", e.getMessage());
    } catch (IOException e) {
        logger.error("Could not open DublinCoreCatalog for Series to parse it: {}", e.getMessage());
    } catch (TransformerException e) {
        logger.error("Could not transform DublinCoreCatalog for Series: {}", e.getMessage());
    }
    return null;
}

From source file:org.openhab.binding.owserver.internal.OWServerBinding.java

String getVariable(String response, String romId, String name) {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

    // Get the DOM Builder
    DocumentBuilder builder = null;
    try {//from   w w w . j a  v  a 2  s .  c o m
        builder = factory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        logger.error("Error parsing OWServer XML response " + e.getMessage());
    }

    // Load and Parse the XML document
    // document contains the complete XML as a Tree.
    Document document = null;
    try {
        InputSource is = new InputSource(new StringReader(response));
        document = builder.parse(is);
    } catch (SAXException e) {
        logger.error("Error reading OWServer XML response " + e.getMessage());
    } catch (IOException e) {
        logger.error("Error reading OWServer XML response " + e.getMessage());
    }

    // Iterating through the nodes and extracting the data.
    NodeList nodeList = document.getDocumentElement().getChildNodes();

    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeName().startsWith("owd_")) {
            boolean romMatch = false;
            NodeList childNodes = node.getChildNodes();
            for (int j = 0; j < childNodes.getLength(); j++) {
                Node cNode = childNodes.item(j);

                // Identifying the child tag of employee encountered.
                if (cNode instanceof Element) {
                    String content = cNode.getLastChild().getTextContent().trim();
                    if (cNode.getNodeName().equals("ROMId") & content.equals(romId)) {
                        romMatch = true;
                    }

                    String nname = cNode.getNodeName();
                    if (nname.equals(name) & romMatch == true) {
                        return content;
                    }
                }
            }
        }
    }

    return null;
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetListActivity.java

private List<OpenHABSitemap> parseSitemapList(String xmlContent) {
    List<OpenHABSitemap> sitemapList = new ArrayList<OpenHABSitemap>();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder;//from ww w . j av a 2 s .  c o  m
    Crittercism.leaveBreadcrumb("parseSitemapList");
    try {
        builder = factory.newDocumentBuilder();
        Document document;
        document = builder.parse(new ByteArrayInputStream(xmlContent.getBytes("UTF-8")));
        NodeList sitemapNodes = document.getElementsByTagName("sitemap");
        if (sitemapNodes.getLength() > 0) {
            for (int i = 0; i < sitemapNodes.getLength(); i++) {
                Node sitemapNode = sitemapNodes.item(i);
                OpenHABSitemap openhabSitemap = new OpenHABSitemap(sitemapNode);
                sitemapList.add(openhabSitemap);
            }
        }
    } catch (ParserConfigurationException e) {
        Log.e(TAG, e.getMessage());
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, e.getMessage());
    } catch (SAXException e) {
        Log.e(TAG, e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, e.getMessage());
    }
    return sitemapList;
}

From source file:org.openhealthtools.openatna.jaxb21.JaxbIOFactory.java

private Document newDocument(InputStream stream) throws IOException {
    Document doc = null;/*  w  ww  .  j a va 2s  .c o  m*/
    try {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        doc = db.parse(stream);
    } catch (ParserConfigurationException e) {
        throw new IOException(e.getMessage());
    } catch (SAXException e) {
        throw new IOException(e.getMessage());
    }
    return doc;
}