List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:gov.tva.sparky.util.indexer.HistorianArchiveLookupTable.java
public static int RetrieveFileArchiveRowCount() { int iRowCount = 0; byte[] arCountBytes = null; try {/*from ww w.j av a2s.c om*/ arCountBytes = RestProxy.QueryHBaseForCell(HBASE_HDFSARCHIVELOOKUPTABLE_TABLE_NAME, HBASE_HDFSARCHIVELOOKUPTABLE_TRACKING_ROWCOUNT_KEY, HBASE_HDFSARCHIVELOOKUPTABLE_TRACKING_COL_NAME, HBASE_HDFSARCHIVELOOKUPTABLE_TRACKING_QUAL_NAME); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (null == arCountBytes) { } else { iRowCount = HDFSPointBlockPointer.byteArrayToInt(arCountBytes); } if (iRowCount < 0) { iRowCount = 0; } return iRowCount; }
From source file:com.grameenfoundation.ictc.controllers.SaleforceIntegrationController.java
public static Document parseXmlText(InputSource input_data) { //get the factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try {/*from w ww .ja v a 2s.c o m*/ //Using factory get an instance of document builder DocumentBuilder db = dbf.newDocumentBuilder(); //InputSource is = new InputSource(); //is.setCharacterStream(new StringReader(data)); //parse using builder to get DOM representation of the data Document doc = db.parse(input_data); // normalize text representation doc.getDocumentElement().normalize(); System.out.println("Root element of the doc is " + doc.getDocumentElement().getNodeName()); return doc; } catch (ParserConfigurationException pce) { System.out.println("Exception is " + pce.getLocalizedMessage()); pce.printStackTrace(); return null; } catch (SAXException se) { System.out.println("Exception is " + se.getLocalizedMessage()); System.out.println("line " + se.getMessage()); se.printStackTrace(); return null; } catch (IOException ioe) { System.out.println("Exception is " + ioe.getLocalizedMessage()); ioe.printStackTrace(); return null; } catch (Exception ex) { System.out.println("Exception is " + ex.getLocalizedMessage()); // ioe.printStackTrace(); return null; } }
From source file:com.comcast.cqs.test.stress.CqsStressTester.java
public static String deserialize(String serialized, String key) { javax.xml.parsers.SAXParserFactory fac = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); javax.xml.parsers.SAXParser saxParser; SaxHandler p = new SaxHandler(); try {/* w w w . ja va 2s.c o m*/ saxParser = fac.newSAXParser(); saxParser.parse(new ByteArrayInputStream(serialized.getBytes()), p); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return p.getValueByKey(key); }
From source file:com.comcast.cqs.test.stress.CqsStressTester.java
public static List<CQSMessage> deserializeMessage(String serializedMessage) { javax.xml.parsers.SAXParserFactory fac = new org.apache.xerces.jaxp.SAXParserFactoryImpl(); javax.xml.parsers.SAXParser saxParser; SaxHandler p = new SaxHandler(); try {/*from w w w . j a va 2s . c om*/ saxParser = fac.newSAXParser(); saxParser.parse(new ByteArrayInputStream(serializedMessage.getBytes()), p); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } CQSMessage cqsMessage = null; try { if (p.getValueByKey("Body") == null) { return new ArrayList<CQSMessage>(); } cqsMessage = new CQSMessage(p.getValueByKey("Body"), p.getAttributes()); cqsMessage.setMessageId(p.getValueByKey("MessageId")); cqsMessage.setReceiptHandle(p.getValueByKey("ReceiptHandle")); cqsMessage.setMD5OfBody(p.getValueByKey("MD5OfBody")); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return java.util.Arrays.asList(cqsMessage); }
From source file:pakiet.rt.DelicjaXMLParser.java
private void parse() throws SAXException, IOException, XPathExpressionException, ParserConfigurationException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document xmlDocument = builder.parse(new ByteArrayInputStream(xmlInputString.getBytes())); XPath xPath = XPathFactory.newInstance().newXPath(); String userName = xPath.evaluate("//*[1]/@user", xmlDocument); resp.setUser(userName);/*from w w w . java 2 s . c o m*/ System.out.println("test: " + userName); try { builder = builderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } }
From source file:ca.mcgill.music.ddmal.mei.MeiXmlWriter.java
/** * Create a writer for the specified document. * @param doc/*from www. j a v a 2 s . c om*/ * the document to write. */ private MeiXmlWriter(MeiDocument doc) { this.meiDocument = doc; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } document = builder.newDocument(); }
From source file:BuildXml.java
public BuildXml() { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try {/*from ww w. j a v a2 s. c o m*/ DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.newDocument(); } catch (ParserConfigurationException parserException) { parserException.printStackTrace(); } Element root = document.createElement("root"); document.appendChild(root); // add comment to XML document Comment simpleComment = document.createComment("This is a simple contact list"); root.appendChild(simpleComment); // add child element Node contactNode = createContactNode(document); root.appendChild(contactNode); // add processing instruction ProcessingInstruction pi = document.createProcessingInstruction("myInstruction", "action silent"); root.appendChild(pi); // add CDATA section CDATASection cdata = document.createCDATASection("I can add <, >, and ?"); root.appendChild(cdata); // write the XML document to disk try { // create DOMSource for source XML document Source xmlSource = new DOMSource(document); // create StreamResult for transformation result Result result = new StreamResult(new FileOutputStream("myDocument.xml")); // create TransformerFactory TransformerFactory transformerFactory = TransformerFactory.newInstance(); // create Transformer for transformation Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty("indent", "yes"); // transform and deliver content to client transformer.transform(xmlSource, result); } // handle exception creating TransformerFactory catch (TransformerFactoryConfigurationError factoryError) { System.err.println("Error creating " + "TransformerFactory"); factoryError.printStackTrace(); } catch (TransformerException transformerError) { System.err.println("Error transforming document"); transformerError.printStackTrace(); } catch (IOException ioException) { ioException.printStackTrace(); } }
From source file:cn.lambdalib.cgui.loader.xml.CGUIDocLoader.java
public CGUIDocLoader() { dbf = DocumentBuilderFactory.newInstance(); dbf.setIgnoringElementContentWhitespace(true); try {/*from w ww. j a v a 2 s . c om*/ db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } }
From source file:com.diversityarrays.dalclient.DalUtil.java
public static void writeXmlViaDocument(String xml, Writer w) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try {/*from w w w. j ava2 s .c om*/ DocumentBuilder builder = factory.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(xml)); Document xmldoc = builder.parse(is); printXmlDocument(xmldoc, w); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } }
From source file:org.epop.dataprovider.HTMLPage.java
@Override public Document getDoc() { if (super.getDoc() != null) return super.getDoc(); TagNode tagNode = new HtmlCleaner().clean(this.rawCode); try {/*from ww w. j a v a2s .c om*/ setDoc(new DomSerializer(new CleanerProperties()).createDOM(tagNode)); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); return null; } return super.getDoc(); }