RE: Using a StreamResult as a StreamSource
> > 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. How can I pass parameters to a SAXFilter in the middle of a pipeline? Is that feasible? >From my reading of your last paragraph, using a StringWriter/StringReader combination isn't *that* wasteful... so its not quite the same as writing something out to read back in? I ask because I want to use XMLFilters on the way into the transform, perform a transformation with some parameters, then use more XMLFilters on the result. Currently I use a StringWriter, then convert that to an InputSource for the XMLFilters that work on the result. cheers andrew XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format