List of usage examples for javax.xml.parsers ParserConfigurationException getMessage
public String getMessage()
From source file:fr.redteam.dressyourself.plugins.weather.yahooWeather.WOEIDUtils.java
private Document convertStringToDocument(String src) { Log.d(TAG, "convertStringToDocument"); Document dest = null;// w w w .j ava2s . com DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser; try { parser = dbFactory.newDocumentBuilder(); dest = parser.parse(new ByteArrayInputStream(src.getBytes())); } catch (ParserConfigurationException e) { Log.d(TAG_ERREUR_METEO, e.getMessage()); } catch (SAXException e) { Log.d(TAG_ERREUR_METEO, e.getMessage()); } catch (IOException e) { Log.d(TAG_ERREUR_METEO, e.getMessage()); } return dest; }
From source file:net.phamngochai.beefnoodle.ui.DownloadDictionaryActivity.java
public Document stringToXMLDoc(String xml) { Document doc = null;/*w w w. j av a2 s.c om*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); doc = db.parse(is); } catch (ParserConfigurationException e) { Log.d(TAG, "XML parse error: " + e.getMessage()); return null; } catch (SAXException e) { Log.d(TAG, "Wrong XML file structure: " + e.getMessage()); return null; } catch (IOException e) { Log.d(TAG, "I/O exeption: " + e.getMessage()); return null; } return doc; }
From source file:it.unibas.spicy.persistence.xml.DAOXmlUtility.java
public org.w3c.dom.Document buildNewDOM() throws DAOException { org.w3c.dom.Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true);/*from ww w . jav a 2 s. co m*/ try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.newDocument(); } catch (ParserConfigurationException pce) { logger.error(pce); throw new DAOException(pce.getMessage()); } catch (DOMException doe) { logger.error(doe); throw new DAOException(doe.getMessage()); } return document; }
From source file:be.e_contract.mycarenet.ehealth.common.WSSecuritySOAPHandler.java
public WSSecuritySOAPHandler() { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); try {/* w w w. j av a 2 s . c o m*/ this.documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException("DOM error: " + e.getMessage(), e); } }
From source file:be.fedict.eid.applet.service.signer.odf.ODFURIDereferencer.java
private ODFURIDereferencer(URL odfUrl, byte[] odfData) { if (null == odfUrl && null == odfData) { throw new IllegalArgumentException("odfUrl and odfData are null"); }//w ww . j av a 2 s. c om if (null != odfUrl && null != odfData) { throw new IllegalArgumentException("odfUrl and odfData are both not null"); } this.odfUrl = odfUrl; this.odfData = odfData; XMLSignatureFactory xmlSignatureFactory = XMLSignatureFactory.getInstance(); this.baseUriDereferener = xmlSignatureFactory.getURIDereferencer(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); try { this.documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException("parser config error: " + e.getMessage(), e); } EntityResolver entityResolver = new ODFEntityResolver(); this.documentBuilder.setEntityResolver(entityResolver); }
From source file:com.freedomotic.helpers.HttpHelper.java
public HttpHelper() { try {/* w ww . jav a 2 s . c o m*/ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); documentBuilder = builderFactory.newDocumentBuilder(); } catch (ParserConfigurationException ex) { LOG.error(ex.getMessage()); } XPathFactory xpathFactory = XPathFactory.newInstance(); xPath = xpathFactory.newXPath(); setConnectionTimeout(DEFAULT_TIMEOUT); }
From source file:com.frank.search.solr.server.support.EmbeddedSolrServerFactory.java
protected void initSolrServer() { try {//from w w w. ja v a2 s . co m this.solrServer = createPathConfiguredSolrServer(this.solrHome); } catch (ParserConfigurationException e) { throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e); } catch (IOException e) { throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e); } catch (SAXException e) { throw new BeanInstantiationException(EmbeddedSolrServer.class, e.getMessage(), e); } }
From source file:com.krawler.esp.fileparser.wordparser.DocxParser.java
public String extractText(String filepath) { StringBuilder sb = new StringBuilder(); ZipFile docxfile = null;/*from w w w . ja va2 s . c om*/ try { docxfile = new ZipFile(filepath); } catch (Exception e) { // file corrupt or otherwise could not be found logger.warn(e.getMessage(), e); return sb.toString(); } InputStream in = null; try { ZipEntry ze = docxfile.getEntry("word/document.xml"); in = docxfile.getInputStream(ze); } catch (NullPointerException nulle) { System.err.println("Expected entry word/document.xml does not exist"); logger.warn(nulle.getMessage(), nulle); return sb.toString(); } catch (IOException ioe) { logger.warn(ioe.getMessage(), ioe); return sb.toString(); } Document document = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(in); } catch (ParserConfigurationException pce) { logger.warn(pce.getMessage(), pce); return sb.toString(); } catch (SAXException sex) { sex.printStackTrace(); return sb.toString(); } catch (IOException ioe) { logger.warn(ioe.getMessage(), ioe); return sb.toString(); } finally { try { docxfile.close(); } catch (IOException ioe) { System.err.println("Exception closing file."); logger.warn(ioe.getMessage(), ioe); } } NodeList list = document.getElementsByTagName("w:t"); List<String> content = new ArrayList<String>(); for (int i = 0; i < list.getLength(); i++) { Node aNode = list.item(i); content.add(aNode.getFirstChild().getNodeValue()); } for (String s : content) { sb.append(s); } return sb.toString(); }
From source file:com.icloud.framework.http.domain.DomainSuffixesReader.java
void read(DomainSuffixes tldEntries, InputStream input) throws IOException { try {//from w w w . j ava 2 s. c om DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(input)); Element root = document.getDocumentElement(); if (root != null && root.getTagName().equals("domains")) { Element tlds = (Element) root.getElementsByTagName("tlds").item(0); Element suffixes = (Element) root.getElementsByTagName("suffixes").item(0); //read tlds readITLDs(tldEntries, (Element) tlds.getElementsByTagName("itlds").item(0)); readGTLDs(tldEntries, (Element) tlds.getElementsByTagName("gtlds").item(0)); readCCTLDs(tldEntries, (Element) tlds.getElementsByTagName("cctlds").item(0)); readSuffixes(tldEntries, suffixes); } else { throw new IOException("xml file is not valid"); } } catch (ParserConfigurationException ex) { LOG.warn(TZUtil.stringifyException(ex)); throw new IOException(ex.getMessage()); } catch (SAXException ex) { LOG.warn(TZUtil.stringifyException(ex)); throw new IOException(ex.getMessage()); } }
From source file:be.e_contract.mycarenet.xkms.ProofOfPossessionSignatureSOAPHandler.java
@Override public boolean handleMessage(SOAPMessageContext context) { if (null == this.sessionKey) { return true; }/*from w ww. j av a 2s . c o m*/ if (null == this.prototypeKeyBindingId) { return true; } Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (false == outboundProperty) { return true; } LOG.debug("adding proof of possession signature"); SOAPMessage soapMessage = context.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); NodeList registerRequestNodeList = soapPart.getElementsByTagNameNS(XKMS_NAMESPACE, "Register"); Element registerRequestElement = (Element) registerRequestNodeList.item(0); Document xkmsDocument; try { xkmsDocument = copyDocument(registerRequestElement); } catch (ParserConfigurationException e) { LOG.error("error copying XKMS request: " + e.getMessage(), e); return false; } NodeList proofOfPossessionNodeList = xkmsDocument.getElementsByTagNameNS(XKMS_NAMESPACE, "ProofOfPossession"); Element proofOfPossessionElement = (Element) proofOfPossessionNodeList.item(0); try { prepareDocument(xkmsDocument); addSignature(proofOfPossessionElement); } catch (Exception e) { LOG.error("error adding proof signature: " + e.getMessage(), e); return false; } Node signatureNode = soapPart.importNode(proofOfPossessionElement.getFirstChild(), true); proofOfPossessionNodeList = soapPart.getElementsByTagNameNS(XKMS_NAMESPACE, "ProofOfPossession"); proofOfPossessionElement = (Element) proofOfPossessionNodeList.item(0); proofOfPossessionElement.appendChild(signatureNode); return true; }