List of utility methods to do XML SAX Parser
XMLReader | createXmlReader() Creates an XMLReader with default feature set. SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser saxParser = spf.newSAXParser(); XMLReader reader = saxParser.getXMLReader(); reader.setFeature("http://xml.org/sax/features/namespaces", true); return reader; |
SAXParserFactory | createXmlReader() create Xml Reader SAXParserFactory spf = SAXParserFactory.newInstance(); try { spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return spf; } catch (Throwable e) { throw new RuntimeException(e); |
XMLReader | createXmlReader() create Xml Reader try { Class<?> clazz = Class.forName("org.apache.xerces.parsers.SAXParser"); return (XMLReader) clazz.newInstance(); } catch (Throwable e) { SAXParser saxParser; try { SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); saxParserFactory.setNamespaceAware(true); ... |
Collection | extractClasses(String xmlContent) extract Classes final Set<String> classList = new LinkedHashSet<String>(); try { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (attributes != null) { ... |
SAXParserFactory | getFactory() get Factory return factory;
|
SAXParser | getSAXParser() get SAX Parser try { return SAXParserFactory.newInstance().newSAXParser(); } catch (Exception e) { throw new RuntimeException(e); |
SAXParser | getSAXParser() get SAX Parser if (!stack.empty()) return (SAXParser) stack.pop(); try { SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setProperty("http://apache.org/xml/properties/input-buffer-size", new Integer(8192)); return parser; } catch (Exception exc) { ... |
SAXParser | getSAXParser() Creates a new SAXParser. SAXParserFactory factory = SAXParserFactory.newInstance();
return factory.newSAXParser();
|
SAXParserFactory | getSAXParserFactory() Get a SAX Parser Factory. SAXParserFactory threadLocalSAXParserFactory = SAX_FACTORY.get(); if (null == threadLocalSAXParserFactory) { threadLocalSAXParserFactory = SAXParserFactory.newInstance(); SAX_FACTORY.set(threadLocalSAXParserFactory); return threadLocalSAXParserFactory; |
String | getSAXSDDriver() get SAXSD Driver String parser = JAVA_15_SAX_DRIVER; try { parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader().getClass().getName(); @SuppressWarnings("unused") XMLReader r = XMLReaderFactory.createXMLReader(parser); } catch (SAXException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { ... |