List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:com.wooki.services.ImportServiceImpl.java
public Book importDocbook(InputStream generatedXhtml) { HTMLParser handler = new HTMLParser(); SAXParserFactory factory = SAXParserFactory.newInstance(); // cration d'un parseur SAX SAXParser parser;//from www. j a va 2s .c o m try { parser = factory.newSAXParser(); parser.parse(new InputSource(generatedXhtml), handler); } catch (ParserConfigurationException e) { e.printStackTrace(); logger.error(e.getLocalizedMessage()); return null; } catch (SAXException e) { e.printStackTrace(); logger.error(e.getLocalizedMessage()); return null; } catch (IOException e) { e.printStackTrace(); logger.error(e.getLocalizedMessage()); return null; } Book book = handler.getBook(); Book toReturn = getBookManager().create(book.getTitle()); return toReturn; }
From source file:marytts.tools.perceptiontest.PerceptionRequestHandler.java
private String getCaseOneInfoResponse(Map<String, String> queryItems) { String eMailID = queryItems.get("EMAIL").trim(); int presentSampleNumber = 0; try {/*from w ww .j a v a 2s .com*/ presentSampleNumber = this.userRatingRH.ratingsDoneSoFar(eMailID); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String infoResponse = queryItems.get("EMAIL") + "\n"; infoResponse += this.infoRH.getNumberOfSamples() + "\n"; infoResponse += presentSampleNumber + "\n"; if (presentSampleNumber < this.infoRH.getNumberOfSamples()) { infoResponse += this.infoRH.getSampleBaseName(presentSampleNumber) + "\n"; } else infoResponse += "DummyBaseName\n"; infoResponse += this.infoRH.getOptions() + "\n"; infoResponse += this.infoRH.getQueryStatement() + "\n"; return infoResponse; }
From source file:com.michael.feng.utils.YahooWeather4a.WOEIDUtils.java
private Document convertStringToDocument(Context context, String src) { Log.d("tag", "convertStringToDocument"); Document dest = null;/*from www.j a v a2 s. c o m*/ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser; try { parser = dbFactory.newDocumentBuilder(); dest = parser.parse(new ByteArrayInputStream(src.getBytes())); } catch (ParserConfigurationException e1) { e1.printStackTrace(); Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG).show(); } catch (SAXException e) { e.printStackTrace(); Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show(); } return dest; }
From source file:marytts.tools.perceptiontest.DataRequestHandler.java
public DataRequestHandler(String testXmlName) { super();/* w w w . ja v a 2 s . c o m*/ try { System.out.println("Loading file : " + testXmlName); testData = new TestDataLoader(testXmlName); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.joliciel.frenchTreebank.upload.TreebankSAXParser.java
public void parseDocument(String filePath) { //get or create the treebank file treebankFile = this.getTreebankService().loadOrCreateTreebankFile(filePath); //get a factory SAXParserFactory spf = SAXParserFactory.newInstance(); try {// w w w . j a va2 s. c o m //get a new instance of parser SAXParser sp = spf.newSAXParser(); //parse the file and also register this class for call backs sp.parse(filePath, this); } catch (SAXException se) { se.printStackTrace(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (IOException ie) { ie.printStackTrace(); } }
From source file:no.dusken.aranea.admin.control.ImportStvMediaController.java
private Document parseXmlFile(File file) { Document dom = null;//from w w w . j a v a2 s. c o m // get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { // Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder(); // parse using builder to get DOM representation of the XML file dom = db.parse(file); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } return dom; }
From source file:com.musala.core.RssProcessorImpl.java
private void readData() { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = null;// w w w .j av a2s . c o m try { parser = factory.newSAXParser(); parser.parse(new InputSource(new URL(site.getRssLink()).openStream()), this); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:at.sti2.spark.handler.ImpactoriumHandler.java
public String extractInfoObjectIdentifier(String infoObjectResponse) { String reportId = null;/* w ww . j ava 2 s.c o m*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); //dbf.setNamespaceAware(true); try { DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(infoObjectResponse.getBytes("UTF-8"))); XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); XPathExpression expr = xpath.compile("//info-object"); Object result = expr.evaluate(doc, XPathConstants.NODESET); NodeList nodes = (NodeList) result; Node item = nodes.item(0); if (item != null) { NamedNodeMap attributesMap = item.getAttributes(); Node idAttribute = attributesMap.getNamedItem("id"); reportId = idAttribute.getNodeValue(); } } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XPathExpressionException e) { e.printStackTrace(); } return reportId; }
From source file:com.intel.hadoop.graphbuilder.demoapps.wikipedia.docwordgraph.WordCountGraphTokenizer.java
public void parse(String s) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);// www.j av a 2s .com DocumentBuilder builder; counts = new HashMap<String, Integer>(); try { builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(s))); XPathFactory xfactory = XPathFactory.newInstance(); XPath xpath = xfactory.newXPath(); title = xpath.evaluate("//page/title/text()", doc); title = title.replaceAll("\\s", "_"); // title = title.replaceAll("^[^a-zA-Z0-9]", "#"); // title = title.replaceAll("[^a-zA-Z0-9.]", "_"); id = xpath.evaluate("//page/id/text()", doc); String text = xpath.evaluate("//page/revision/text/text()", doc); if (!text.isEmpty()) { Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30); TokenStream stream = analyzer.tokenStream(null, new StringReader(text)); while (stream.incrementToken()) { String token = stream.getAttribute(TermAttribute.class).term(); if (dictionary != null && !dictionary.contains(token)) continue; if (counts.containsKey(token)) counts.put(token, counts.get(token) + 1); else counts.put(token, 1); } } } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (XPathExpressionException e) { e.printStackTrace(); } }
From source file:it.openyoureyes.test.OpenCellId.java
private String parseImage(HttpEntity entity, DefaultHandler dd) throws IOException { String result = ""; String line;/* www. j a va 2s.c o m*/ try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); xr.setContentHandler(dd); /* Parse the xml-data from our URL. */ xr.parse(new InputSource(entity.getContent())); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { entity.consumeContent(); } return result; }