Do I have to use Threads for pipedstreams?
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Eelco_Cramer
Posted On:   Friday, October 26, 2001 08:23 AM

I'm having difficulties with the following code (I'm probably doing something wrong): String xml1 = "xml2.xml"; String xml2 = "xml2.xsl"; String xsl = "xsl.xsl"; TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(xslt1)); PipedOutputStream pos = new PipedOutputStream(); PipedInputStream pis = new PipedInputStream(pos); transformer.transform(new StreamSource(xml1), new StreamResult(pos)); transformer = tFactory.newTransformer(new StreamSource(pis)); transformer.transform(new StreamSource(xml2),ne   More>>

I'm having difficulties with the following code (I'm probably doing something wrong):

			
String xml1 = "xml2.xml";
String xml2 = "xml2.xsl";
String xsl = "xsl.xsl";


TransformerFactory tFactory = TransformerFactory.newInstance();


Transformer transformer = tFactory.newTransformer(new StreamSource(xslt1));
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream(pos);


transformer.transform(new StreamSource(xml1), new StreamResult(pos));
transformer = tFactory.newTransformer(new StreamSource(pis));


transformer.transform(new StreamSource(xml2),new StreamResult(out));



Okay, what am I trying to do here :)


I'm using a XSL to transform xml1 to a new XSL which I want to use to transform xml2. Because the transformer has a StreamResult and the second transformer uses a StreamSource I have to pipe the two. I'm using PipeStreams to do that, but I'm using them wrong :-). I reckon I have to use some sort of Thread but I'm not really into Threads, does anyone have a suggestion?

   <<Less

Re: Do I have to use Threads for pipedstreams?

Posted By:   Alex_Chaffee  
Posted On:   Tuesday, October 30, 2001 09:55 AM

Re: Do I have to use Threads for pipedstreams?

Posted By:   Eelco_Cramer  
Posted On:   Saturday, October 27, 2001 08:18 AM

I was thinking to difficult here. I can use either a DOMResult instead of a StreamResult, or use a StringWriter as an argument for the StreamResult.


Problem solved.


Still, I am curious how the PipeStreams work and if they you need Threads to run this example?

Re: Do I have to use Threads for pipedstreams?

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, October 26, 2001 10:35 AM

all this executes in the same thread.
About | Sitemap | Contact