You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Dave Herman <DH...@oppenheimerfunds.com> on 2001/01/17 21:33:01 UTC
Reading a transformation in from an InputStream (ie, lazy
transformation)?
Hello,
A basic way to do a transformation seems to be to write it to an OutputStream, e.g.,
transformer.transform(new StreamSource(in), new StreamResult(out));
This forces me to do something like write to a ByteArrayOutputStream and then read those bytes back in. Is there a way to perform lazy transformation, that is, to read in a transformed document from an InputStream, thereby only performing the transformation piecmeal as I read in from the InputStream? I guess I could run the transformation in a separate thread and use piped streams, but that's not the same thing.
Thanks,
Dave Herman
dherman@oppenheimerfunds.com
------------------------------------------------------------------------------
This electronic mail transmission may contain confidential information and is intended only for the person(s) named. Any use, copying or disclosure by any other person is strictly prohibited. If you have received this transmission in error, please notify the sender via e-mail.
=======================================
Re: Reading a transformation in from an InputStream (ie,
lazytransformation)?
Posted by Gary L Peskin <ga...@firstech.com>.
Dave Herman wrote:
>
> Hello,
>
> A basic way to do a transformation seems to be to write it to an OutputStream, e.g.,
>
> transformer.transform(new StreamSource(in), new StreamResult(out));
>
> This forces me to do something like write to a ByteArrayOutputStream and then read those bytes back in. Is there a way to perform lazy transformation, that is, to read in a transformed document from an InputStream, thereby only performing the transformation piecmeal as I read in from the InputStream? I guess I could run the transformation in a separate thread and use piped streams, but that's not the same thing.
>
> Thanks,
> Dave Herman
> dherman@oppenheimerfunds.com
Dave --
AFAIK, the transformation is driven from the input source. If you are
providing your input in the form of a stream, this will be the driver
for the transformation. I think that you can accomplish what you want
by using a SAXResult that targets a SAX2 ContentHandler. This
ContentHandler will be called by the transformation as it occurs. Your
ContentHandler can accumulate the results or discard them or pass them
on or whatever you want.
For further info, see
http://xml.apache.org/xalan-j/usagepatterns.html#sax
Is this what you are looking for?
Gary