Пример #1
0
    public InputSource resolveEntity(String publicId, String systemId)
        throws SAXException, IOException {
      final InputSource is = new InputSource();
      is.setSystemId(systemId);
      is.setPublicId(publicId);
      final URL url = URLFactory.createURL(systemId);

      // Would be nice to support XML Catalogs or similar here. See:
      // http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
      if (url.getProtocol().equals("http")) {
        logger.warn(
            "XML entity resolver for public id: "
                + publicId
                + " is accessing external entity via HTTP: "
                + url.toExternalForm());
      }

      is.setByteStream(url.openConnection().getInputStream());
      return is;
    }