Java XML SAX Parser createSAXParser(DefaultHandler dh)

Here you can find the source of createSAXParser(DefaultHandler dh)

Description

create SAX Parser

License

Open Source License

Declaration

private static SAXParser createSAXParser(DefaultHandler dh) throws SAXException 

Method Source Code

//package com.java2s;
/*//from w  w w.  ja  v  a2 s . co  m
 * dbXML - Native XML Database
 * Copyright (c) 1999-2006 The dbXML Group, L.L.C.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * $Id: SAXHelper.java,v 1.4 2006/02/02 19:04:46 bradford Exp $
 */

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;

public class Main {
    private static SAXParserFactory spf;

    private static SAXParser createSAXParser(DefaultHandler dh) throws SAXException {
        try {
            SAXParser sp = spf.newSAXParser();
            if (dh instanceof LexicalHandler)
                sp.setProperty("http://xml.org/sax/properties/lexical-handler", dh);

            return sp;
        } catch (ParserConfigurationException e) {
            throw new SAXException(e);
        }
    }
}

Related

  1. canDisableExternalDtds(SAXParserFactory parserFactory)
  2. createNamespaceAwareSAXParserFactory()
  3. createSafeSaxReader(SAXParserFactory saxParserFactory, ContentHandler contentHandler)
  4. createSaxParser()
  5. createSAXParser()
  6. createSaxParserFactory()
  7. createSchema(String url)
  8. createXMLReader()
  9. createXmlReader()