EntityResolver currentEntityResolver = reader.getEntityResolver(); if (null != currentEntityResolver) { m_lastEntityResolver = currentEntityResolver; } else if (null != m_lastEntityResolver) { reader.setEntityResolver(m_lastEntityResolver); }
  public XMLReader getXMLReader(Source inputSource)  {    try    {      XMLReader reader = (inputSource instanceof SAXSource)                         ? ((SAXSource) inputSource).getXMLReader() : null;      if (null == reader)      {        try        {          javax.xml.parsers.SAXParserFactory factory =            javax.xml.parsers.SAXParserFactory.newInstance();          factory.setNamespaceAware(true);          javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();          reader = jaxpParser.getXMLReader();        }        catch (javax.xml.parsers.ParserConfigurationException ex)        {          throw new org.xml.sax.SAXException(ex);        }        catch (javax.xml.parsers.FactoryConfigurationError ex1)        {          throw new org.xml.sax.SAXException(ex1.toString());        }        catch (NoSuchMethodError ex2){}        catch (AbstractMethodError ame){}        if (null == reader)          reader = XMLReaderFactory.createXMLReader();      }      try      {        reader.setFeature("http://xml.org/sax/features/namespace-prefixes",                          true);      }      catch (org.xml.sax.SAXException se)      {        // What can we do?        // TODO: User diagnostics.      }      try      {        reader.setFeature("http://apache.org/xml/features/validation/dynamic",                          true);      }      catch (org.xml.sax.SAXException se)      {        // What can we do?        // TODO: User diagnostics.      }      EntityResolver currentEntityResolver = reader.getEntityResolver();      if (null != currentEntityResolver)      {        m_lastEntityResolver = currentEntityResolver;      }      else if (null != m_lastEntityResolver)      {        reader.setEntityResolver(m_lastEntityResolver);      }      return reader;    }    catch (org.xml.sax.SAXException se)    {      throw new DTMException(se.getMessage(), se);    }  }