  public Document read(InputSource in) throws DocumentException {
    try {
      XMLReader reader = getXMLReader();

      reader = installXMLFilter(reader);

      EntityResolver thatEntityResolver = this.entityResolver;

      if (thatEntityResolver == null) {
        thatEntityResolver = createDefaultEntityResolver(in
                .getSystemId());
        this.entityResolver = thatEntityResolver;
      }

      reader.setEntityResolver(thatEntityResolver);

      SAXContentHandler contentHandler = createContentHandler(reader);
      contentHandler.setEntityResolver(thatEntityResolver);
      contentHandler.setInputSource(in);

      boolean internal = isIncludeInternalDTDDeclarations();
      boolean external = isIncludeExternalDTDDeclarations();

      contentHandler.setIncludeInternalDTDDeclarations(internal);
      contentHandler.setIncludeExternalDTDDeclarations(external);
      contentHandler.setMergeAdjacentText(isMergeAdjacentText());
      contentHandler.setStripWhitespaceText(isStripWhitespaceText());
      contentHandler.setIgnoreComments(isIgnoreComments());
      reader.setContentHandler(contentHandler);

      configureReader(reader, contentHandler);

      reader.parse(in);

      return contentHandler.getDocument();
    } catch (Exception e) {
      if (e instanceof SAXParseException) {
        // e.printStackTrace();
        SAXParseException parseException = (SAXParseException) e;
        String systemId = parseException.getSystemId();

        if (systemId == null) {
          systemId = "";
        }

        String message = "Error on line "
                + parseException.getLineNumber() + " of document "
                + systemId + " : " + parseException.getMessage();

        throw new DocumentException(message, e);
      } else {
        throw new DocumentException(e.getMessage(), e);
      }
    }
  }
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.