[jdom-interest] integrating jdom with xslt

Alan Eustace alan.eustace at bigfoot.com
Fri Feb 16 10:21:15 PST 2001


hope this isn't too basic a question to post:
i'm trying to connect my XMLOutputter output to the XSLT processor,
using a piped input/ouput stream as suggested in the JDOM FAQ.
Everything goes fine until it gets down to the processor.process call,
at which point the prog. seems to get stuck in an infinite loop.
the call  PipedInputStream.in.available() shows that there is data
stored in the pipe, but somehow the XSLT processor can't read it.
i'm running the servlet in tomcat, on NT5.
here's the code- hope someone can shed some light on it.

 try{

  SAXBuilder builder = new SAXBuilder();
  Document xmldoc =builder.build("foo.xml");
  XMLOutputter fmt = new XMLOutputter();
  out.println("<br>xmlout");

  PipedInputStream in = new PipedInputStream();
  // connect the pipes
  PipedOutputStream outt = new PipedOutputStream(in);
  // print xml to console, check that it's processing okay
  fmt.output(xmldoc, System.out);
  // now output to PipedOutputStream.outt
  fmt.output(xmldoc, outt);

  // put this in just in case, makes no difference either way :)
  outt.flush();
  System.out.println("created input stream");

  // in.available()- shows if there is anything in PipedInputStream in
(gives the following "in.available() = 317")
  System.out.println("in.available() = " + in.available());

  XSLTInputSource xsldoc = new XSLTInputSource("foo.xsl");

  XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new
        org.apache.xalan.xpath.xdom.XercesLiaison());
  System.out.println("created processor");


       // Process the XSL and return the data to PrintWriter.out- the
prog runs to
here, and then hangs.
  processor.process(new XSLTInputSource(in),
                     new XSLTInputSource(xsldoc),
                     new XSLTResultTarget(out));

 }
      catch (Exception e) {
 System.out.print( e.toString());

      }
  }

}








More information about the jdom-interest mailing list