Subject: Re: [xsl] transforming multiple xml sources into a single stream|
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Thu, 16 Oct 2003 23:02:17 +0200
I am using Java1.4.1's API for Transformation. I have 2 different xml streams (not files on disk) in memory and have to use transformation to merge them into a single xml stream. Is this possible?
I know there is way to merge 2 xml files into a single if the files are on the disk, but I am wondering if we can do this when streams are in memory.
There are several methods. The most geeky one is of course to write a custom URIResolver and use it with a custom URI scheme in order to pull in an in-memory stream via document(). There is sample code for this in the list archive, or have a look at the Cocoon project (http://cocoon.apache.org).
Less innovative methods include building two DOMs and merge them (memory intensive), merge via a SAX filter or merging the streams directly, perhaps using a custom FilterStream subclass (may be brittle).