Java Utililty Methods XML SAX Parser

List of utility methods to do XML SAX Parser

Description

The list of methods to do XML SAX Parser are organized into topic(s).

Method

XMLReadercreateXmlReader()
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;
SAXParserFactorycreateXmlReader()
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);
XMLReadercreateXmlReader()
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);
...
CollectionextractClasses(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) {
...
SAXParserFactorygetFactory()
get Factory
return factory;
SAXParsergetSAXParser()
get SAX Parser
try {
    return SAXParserFactory.newInstance().newSAXParser();
} catch (Exception e) {
    throw new RuntimeException(e);
SAXParsergetSAXParser()
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) {
...
SAXParsergetSAXParser()
Creates a new SAXParser.
SAXParserFactory factory = SAXParserFactory.newInstance();
return factory.newSAXParser();
SAXParserFactorygetSAXParserFactory()
Get a SAX Parser Factory.
SAXParserFactory threadLocalSAXParserFactory = SAX_FACTORY.get();
if (null == threadLocalSAXParserFactory) {
    threadLocalSAXParserFactory = SAXParserFactory.newInstance();
    SAX_FACTORY.set(threadLocalSAXParserFactory);
return threadLocalSAXParserFactory;
StringgetSAXSDDriver()
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) {
...