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

RE: [xsl] Using a StreamResult as a StreamSource


Subject: RE: [xsl] Using a StreamResult as a StreamSource
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 12 Aug 2003 08:44:07 +0100

> How can I use a StreamResult for a StreamSource. I am 
> transforming an xml document twice. The result of the first 
> transform is used to generate the transformer object for the 
> second transform. What is the best way to accomplish this 
> task. Please include examples with your suggestions.

We're talking JAXP here, for those who are mystified...

The best way to pipeline the output of one transformation as the input
of another is not using StreamResult/StreamSource, but using SAX. There
are various mechanisms in JAXP to allow such pipelining. You can compile
a transformation as a SAXFilter, in which case it can be inserted into a
SAX pipeline along with other SAXFilters (which may or may not be XSLT
transformations). You can also wrap a Transformer into a SAX
ContentHandler, which you can then use as the SAXResult of another
transformation.

But if you must use StreamResult/StreamSource, then you can always
create a StreamResult for the first transformation based on a
StringWriter, and the use a StringReader over the same String as the
basis for the StreamSource for the next transformation.

Michael Kay


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



Current Thread
Keywords