code: public static void parse(final InputStream input, final String systemId, final OutputStream output)
              throws XIncludeFatalException, IOException
      {
          LOG.trace("parse:{}", systemId);
          final Processor processor = XIncProcEngine.CONFIGURATION.getProcessor();
          final XIncProcXIncludeFilter filter;
          try
          {
              final URI uri = new URI(systemId);
              filter = (XIncProcXIncludeFilter) XIncProcEngine.newXIncludeFilter(uri);
          }
          catch (final URISyntaxException e)
          {
              throw new XIncludeFatalException(e);
          }
          final byte[] inputBytes = ByteStreams.toByteArray(input);
          final ByteSource supplier = ByteSource.wrap(inputBytes);
          final Charset charset = EncodingUtils.getCharset(supplier.openStream());
          final InputSource inputSource = new InputSource(supplier.openStream());
          inputSource.setSystemId(systemId);
          try
          {
              final XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
              xmlReader.setFeature("http://xml.org/sax/features/resolve-dtd-uris", false);
              filter.setParent(xmlReader);
              final Source saxSource = new SAXSource(filter, inputSource);
              final XdmNode node = processor.newDocumentBuilder().build(saxSource);
  
              LOG.trace("parse result:{}", node.toString());
              serializeNode(output, processor, filter, charset, node);
          }
          catch (final SAXException | SaxonApiException | ParserConfigurationException e)
          {
              throw new XIncludeFatalException(e.getMessage());
          }
      }
docs: Statically parse an {@link InputStream}
  
  @param input {@link InputStream} to parse
  @param systemId of the input. If this is null or not an URI, method exits with XIncludeFatalException.
  @param output {@link OutputStream} will store result
  @throws XIncludeFatalException
  @throws IOException