/** * Instantiates a new xml dom. * * @param is Raw XML. * @throws SAXException the SAX exception */ public XmlDom(InputStream is) throws SAXException{ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); Document doc = builder.parse(is); this.root = (Element) doc.getDocumentElement(); }catch(ParserConfigurationException e) { }catch(IOException e){ throw new SAXException(e); } }
public AtmosphereConfig parse(AtmosphereConfig config, String filename) throws FileNotFoundException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { return parse(config, factory.newDocumentBuilder().parse(filename)); } catch (SAXException e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } catch (IOException e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } catch (ParserConfigurationException e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } }
Document document = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(f); if (sxe.getException() != null) x = sxe.getException(); x.printStackTrace(); throw sxe; } catch (ParserConfigurationException pce) { pce.printStackTrace(); throw pce; } catch (IOException ioe) {
protected final void addEnd(final String name) { try { h.endElement("", name, name); } catch (SAXException ex) { throw new RuntimeException(ex.getMessage(), ex.getException()); } }
protected void initialize() { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setNamespaceAware(true); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); _docResponse = docBuilder.parse(new InputSource(new StringReader(_xmlResponse))); if (_docResponse != null) { parse(_docResponse.getDocumentElement()); } } catch (ParserConfigurationException e) { s_logger.error("Error parsing the response : " + e.toString()); } catch (SAXException e) { s_logger.error("Error parsing the response : " + e.toString()); } catch (IOException e) { s_logger.error("Error parsing the response : " + e.toString()); } }
DocumentBuilderFactory.newInstance(); dfactory.setNamespaceAware(true); dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = dfactory.newDocumentBuilder(); Node xslDOM = docBuilder.parse(new InputSource(xslFileName)); docBuilder.setEntityResolver(entityResolver); throw new org.xml.sax.SAXException(ex); throw new org.xml.sax.SAXException(ex1.toString()); reader.setErrorHandler((org.xml.sax.ErrorHandler)th); reader.parse(new InputSource(inFileName)); throw new org.xml.sax.SAXException(ex); throw new org.xml.sax.SAXException(ex1.toString()); new StringReader("<?xml version=\"1.0\"?> <doc/>"); if (writer != null) writer.close();
private DOMSource readDOMSource(InputStream body, HttpInputMessage inputMessage) throws IOException { try { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setFeature( "http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd()); documentBuilderFactory.setFeature( DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); if (!isProcessExternalEntities()) { documentBuilder.setEntityResolver(NO_OP_ENTITY_RESOLVER); Document document = documentBuilder.parse(body); return new DOMSource(document); "Could not set feature: " + ex.getMessage(), ex, inputMessage); "Could not parse document: " + ex.getMessage(), ex, inputMessage);
Document dom; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); dom = db.parse(xml); Element doc = dom.getDocumentElement(); System.out.println(pce.getMessage()); } catch (SAXException se) { System.out.println(se.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage());
InputStream is = layer.openInputStream(); try { doc = XMLUtil.parse(new InputSource(is), true, true, ERROR_HANDLER, ENTITY_RESOLVER); } finally { is.close(); processingEnv.getMessager().printMessage(Kind.ERROR, "Failed to read generated-layer.xml: " + x.toString()); } catch (SAXException x) { processingEnv.getMessager().printMessage(Kind.ERROR, "Failed to parse generated-layer.xml: " + x.toString());
String fileName = it.next(); try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(new File(fileName)); System.out.println("Retrieving Metric List from xml file: " + fileName); doc.getDocumentElement().normalize(); NodeList metrics = doc.getElementsByTagName("Metric"); System.out.println(" " + err.getMessage()); } catch (SAXException e) { Exception x = e.getException(); ((x == null) ? e : x).printStackTrace(); } catch (Throwable t) {
throw new XmlException(e.getMessage(), e); Document doc2; try { InputSource is2 = new InputSource(new StringReader(obj.xmlText())); doc2 = DocumentHelper.readDocument(is2); } catch (SAXException e) { throw new XmlException(e.getMessage(), e);
/** * Handle reading of the input (object) from the kettle repository by getting the job-xml from the repository step * attribute string and then re-hydrate the job entry (object) with our already existing read method. * * @param object * @param rep * @param id_step * @param databases * @throws KettleException */ public static void readJobRep( Object object, Repository rep, ObjectId id_step, List<DatabaseMeta> databases ) throws KettleException { try { String jobXML = rep.getJobEntryAttributeString( id_step, "job-xml" ); ByteArrayInputStream bais = new ByteArrayInputStream( jobXML.getBytes() ); Document doc = XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder().parse( bais ); read( object, doc.getDocumentElement() ); } catch ( ParserConfigurationException ex ) { throw new KettleException( ex.getMessage(), ex ); } catch ( SAXException ex ) { throw new KettleException( ex.getMessage(), ex ); } catch ( IOException ex ) { throw new KettleException( ex.getMessage(), ex ); } }
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId.equals(PREFS_DTD_NAME)) { InputSource result = new InputSource(new StringReader( PREFS_DTD)); result.setSystemId(PREFS_DTD_NAME); return result; } throw new SAXException("Invalid DOCTYPE declaration " + systemId); } });
public void characters(char[] text, int start, int length) throws SAXException { try { out.write(text, start, length); } catch (IOException e) { throw new SAXException(e); } }
private static InputSource createInputSource(String publicId, Template raw) throws IOException, SAXException { StringWriter sw = new StringWriter(); try { raw.process(Collections.EMPTY_MAP, sw); } catch (TemplateException e) { throw new SAXException(e); } InputSource is = new InputSource(); is.setPublicId(publicId); is.setSystemId(raw.getName()); is.setCharacterStream(new StringReader(sw.toString())); return is; }
createDTDParser(out).parse( new InputSource(new StringReader(dtdDoc))); throw new SAXException("DTD parsing error", e);
@Override public Danmakus parse() { if (mDataSource != null) { AndroidFileSource source = (AndroidFileSource) mDataSource; try { XMLReader xmlReader = XMLReaderFactory.createXMLReader(); XmlContentHandler contentHandler = new XmlContentHandler(); xmlReader.setContentHandler(contentHandler); xmlReader.parse(new InputSource(source.data())); return contentHandler.getResult(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return null; }
Document xmlDocument = parser.parse(stream); Element root = xmlDocument.getDocumentElement(); NodeList sentences = root.getElementsByTagName(SENTENCE); for(int i = 0; i < sentences.getLength(); i++) { e.printStackTrace(); return false;
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (localName.equals("factory")) { String className = attributes.getValue("class"); try { addClass(className); } catch (ClassNotFoundException e) { throw new SAXException("Cannot find Matcher class : " + className); } } } });
final SAXParser saxParser = XmlUtils.buildSecureSaxParser(schemaStream12, schemaStream11, schemaStream10); final XMLReader xmlReader = saxParser.getXMLReader(); xmlReader.setErrorHandler(new SuppressionErrorHandler()); xmlReader.setContentHandler(handler); try (Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { final InputSource in = new InputSource(reader); xmlReader.parse(in); return handler.getSuppressionRules(); throw new SuppressionParseException(ex); } catch (SAXException ex) { if (ex.getMessage().contains("Cannot find the declaration of element 'suppressions'.")) { throw ex; } else {