Code example for XMLReader

Methods: getFeature, setContentHandler, setErrorHandler

0
    private void setParser(XMLReader parser) {
        m_parser = parser;
 
        m_handler = getHandler();
 
        m_parser.setContentHandler(m_handler);
        m_parser.setErrorHandler(m_handler);
    } 
 
    /** 
     * Get a SAXConfigurationHandler for your configuration reading. 
     * 
     * @return a <code>SAXConfigurationHandler</code> 
     */ 
    protected SAXConfigurationHandler getHandler() { 
        try { 
            if (m_parser.getFeature("http://xml.org/sax/features/namespaces")) {
                return new NamespacedSAXConfigurationHandler(); 
            } 
        } catch (Exception e) {
            // ignore error and fall through to the non-namespaced version 
        }