Java XML SAX Parser getSAXParser()

Here you can find the source of getSAXParser()

Description

get SAX Parser

License

Open Source License

Declaration

public static synchronized SAXParser getSAXParser() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 UCLA Medical Imaging Informatics Group
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 ******************************************************************************/

import java.util.Stack;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.XMLReader;

public class Main {
    private static SAXParserFactory factory = null;
    private static Stack stack = null;

    public static synchronized SAXParser getSAXParser() {

        if (!stack.empty())
            return (SAXParser) stack.pop();
        try {//from   www . ja v a 2s .com
            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) {
            System.err.println("Error attempting to initialize SAXParserFactory: " + exc);
            exc.printStackTrace();
            return null;
        }
    }
}

Related

  1. createXmlReader()
  2. createXmlReader()
  3. extractClasses(String xmlContent)
  4. getFactory()
  5. getSAXParser()
  6. getSAXParser()
  7. getSAXParserFactory()
  8. getSAXSDDriver()
  9. getSchema(File xsd, ErrorHandler errorHandler)