示例#1
0
 public static void readerToSAX(
     Reader reader,
     String systemId,
     XMLReceiver xmlReceiver,
     XMLUtils.ParserConfiguration parserConfiguration,
     boolean handleLexical) {
   final InputSource inputSource = new InputSource(reader);
   inputSource.setSystemId(systemId);
   inputSourceToSAX(inputSource, xmlReceiver, parserConfiguration, handleLexical);
 }
示例#2
0
 /**
  * Read a URL into SAX events.
  *
  * @param systemId system id of the document
  * @param xmlReceiver receiver to output to
  * @param parserConfiguration parser configuration
  * @param handleLexical whether the XML parser must output SAX LexicalHandler events, including
  *     comments
  */
 public static void urlToSAX(
     String systemId,
     XMLReceiver xmlReceiver,
     XMLUtils.ParserConfiguration parserConfiguration,
     boolean handleLexical) {
   try {
     final URL url = URLFactory.createURL(systemId);
     final InputStream is = url.openStream();
     final InputSource inputSource = new InputSource(is);
     inputSource.setSystemId(systemId);
     try {
       inputSourceToSAX(inputSource, xmlReceiver, parserConfiguration, handleLexical);
     } finally {
       is.close();
     }
   } catch (IOException e) {
     throw new OXFException(e);
   }
 }
示例#3
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;
    }