コード例 #1
0
ファイル: XMLUtils.java プロジェクト: ghys/orbeon-forms
 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
ファイル: XMLUtils.java プロジェクト: ghys/orbeon-forms
 /**
  * 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
ファイル: XMLUtils.java プロジェクト: ghys/orbeon-forms
    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;
    }