Java XML SAX Parser load(InputStream is, DefaultHandler handler)

Here you can find the source of load(InputStream is, DefaultHandler handler)

Description

load

License

Apache License

Declaration

public static void load(InputStream is, DefaultHandler handler)
        throws IOException, SAXException, ParserConfigurationException 

Method Source Code


//package com.java2s;
/*//  w  ww  .  j a va  2 s.  c om
 * Copyright 2013 XPFriend Community.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public class Main {

    public static void load(InputStream is, DefaultHandler handler)
            throws IOException, SAXException, ParserConfigurationException {
        InputSource sheetSource = new InputSource(is);
        SAXParserFactory saxFactory = SAXParserFactory.newInstance();
        SAXParser saxParser = saxFactory.newSAXParser();
        XMLReader sheetParser = saxParser.getXMLReader();
        sheetParser.setContentHandler(handler);
        sheetParser.parse(sheetSource);
    }
}

Related

  1. getSchemaFromResource(URL schemaURL)
  2. getXIncludeXMLReader()
  3. getXmlReader()
  4. isWellFormedXml(final String string)
  5. isXML(final byte[] data)
  6. newInstance()
  7. newXMLReader()
  8. read(InputStream is, DefaultHandler h)
  9. readSchemaFromFile(File schemaFile)