コード例 #1
0
 /** Transform an InputStream to a TinyTree. */
 public static DocumentInfo readTinyTree(
     Configuration configuration,
     InputStream inputStream,
     String systemId,
     boolean handleXInclude,
     boolean handleLexical) {
   final TinyBuilder treeBuilder = new TinyBuilder();
   {
     final TransformerXMLReceiver identityHandler = getIdentityTransformerHandler(configuration);
     identityHandler.setResult(treeBuilder);
     final XMLReceiver xmlReceiver;
     if (handleXInclude) {
       // Insert XIncludeContentHandler
       xmlReceiver =
           new XIncludeProcessor.XIncludeXMLReceiver(
               null,
               identityHandler,
               null,
               new TransformerURIResolver(XMLUtils.ParserConfiguration.PLAIN));
     } else {
       xmlReceiver = identityHandler;
     }
     XMLUtils.inputStreamToSAX(
         inputStream, systemId, xmlReceiver, XMLUtils.ParserConfiguration.PLAIN, handleLexical);
   }
   return (DocumentInfo) treeBuilder.getCurrentRoot();
 }
コード例 #2
0
 /** Transform an InputStream to a dom4j Document. */
 public static Document readDom4j(
     InputStream inputStream, String systemId, boolean handleXInclude, boolean handleLexical) {
   final LocationSAXContentHandler dom4jResult = new LocationSAXContentHandler();
   {
     final XMLReceiver xmlReceiver;
     if (handleXInclude) {
       // Insert XIncludeContentHandler
       xmlReceiver =
           new XIncludeProcessor.XIncludeXMLReceiver(
               null,
               dom4jResult,
               null,
               new TransformerURIResolver(XMLUtils.ParserConfiguration.PLAIN));
     } else {
       xmlReceiver = dom4jResult;
     }
     XMLUtils.inputStreamToSAX(
         inputStream, systemId, xmlReceiver, XMLUtils.ParserConfiguration.PLAIN, handleLexical);
   }
   return dom4jResult.getDocument();
 }