[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] All Streams are being closed by Xalan


Subject: [xsl] All Streams are being closed by Xalan
From: "Mercieca, Michael" <Michael.Mercieca@xxxxxxxxxxxx>
Date: Mon, 21 Oct 2002 10:56:26 -0600

Hello. I saw that the post at
http://sources.redhat.com/ml/xsl-list/2001-08/msg00632.html was similar to a
problem that I am having. 

I am writing a servlet. What I want to do is take the XML request posted to
it and run a transformation on it. The result of that transformation goes to
another servlet which does some work and returns some XML. I then need to
run a second transformation (with the initial XML request being the source)
that takes combines data from both the initial XML request and the response
from the servlet that I posted to. (Hope that's not too confusing). 

I was initially letting Xalan create the StreamSource using the following
code: 

int x = 999999999; 
BufferedInputStream isInitial = new
BufferedInputStream(request.getInputStream()); 
isInitial.mark(x); 

TransformerFactory tf = TransformerFactory.newInstance(); 
Transformer trans1 = tf.newTransformer(new StreamSource(eQuote2RS_xslt)); 
trans1.transform(new StreamSource(isInitial),new
StreamResult(outToServlet2)); 

//this part worked fine, but when tried to reset the BufferedInputStream, I
got an IOException saying that it was closed. 
isInitial.reset(); //threw the IOException. 

I then read the aforementioned post on xsl-list, and saw that Xalan would
close the stream unless it was created manually. So I then tried to do that
using the following code. 

BufferedInputStream bisInitial = new
BufferedInputStream(req.getInputStream()); 
StreamSource ssInitial= new StreamSource (bisInitial);
bisInitial.mark(x); 

TransformerFactory tf = TransformerFactory.newInstance(); 
Transformer trans1 = tf.newTransformer(new StreamSource(eQuote2RS_xslt)); 
trans1.transform(isInitial,new StreamResult(outToServlet2)); 

bisInitial.reset(); //still throws the IOException. 

It seems that Xalan is closing my stream no matter how I create it. I guess
I could write it out to a file and open it twice, but that really seems like
a waste. Does anyone know what I'm doing wrong, or know of another way of
doing this??? 

Any assistance is greatly appreciated. 

Mike Mercieca 





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml