Code example for XMLReader

Methods: parse, setContentHandler, setDTDHandler, setErrorHandler, setProperty

0
            final SAXParser saxParser = factory.newSAXParser();
            final XMLReader reader = saxParser.getXMLReader();
 
            final SAXModelHandler handler = new SAXModelHandler(resource, isInclude);
            try { 
                reader.setProperty
                    ("http://xml.org/sax/properties/lexical-handler", 
                        getCommentHandler()); 
            } 
            catch (SAXException se) {
                Log.debug("Comments are not supported by this SAX implementation."); 
            } 
            reader.setContentHandler(handler);
            reader.setDTDHandler(handler);
            reader.setErrorHandler(handler);
            reader.parse(new InputSource(in));
            in.close();
        } 
        catch (Exception e) {
            // unable to init 
            Log.warn("Unable to load factory specifications", e);