Code example for XMLReader

Methods: setFeature, setProperty

0
  protected void configureReader(final XMLReader reader,
                                 final RootXmlReadHandler handler)
  { 
    try 
    { 
      reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler.getCommentHandler());
    } 
    catch (final SAXException se)
    { 
      // ignore .. 
      logger.debug("Comments are not supported by this SAX implementation.");
    } 
 
    try 
    { 
      reader.setFeature("http://xml.org/sax/features/xmlns-uris", true);
    } 
    catch (final SAXException e)
    { 
      // ignore 
      handler.setXmlnsUrisNotAvailable(true);
    } 
    try 
    { 
      // disable validation, as our parsers should handle that already. And we do not want to read 
      // external DTDs that may not exist at all. 
      reader.setFeature("http://xml.org/sax/features/validation", false);
      reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
      reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
    } 
    catch (final SAXException e)
    { 
      // ignore 
      if (logger.isDebugEnabled())
      { 
        logger.debug("Disabling external validation failed. Parsing may or may not fail with a parse error later.");
      } 
    } 
 
    try 
    { 
      reader.setFeature("http://xml.org/sax/features/namespaces", true);
      reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
    } 
    catch (final SAXException e)
    { 
      if (logger.isDebugEnabled())
      {