[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: transforming multiple xml sources into a single st

Subject: RE: transforming multiple xml sources into a single stream
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 17 Oct 2003 12:04:53 +0100
multiple xml sources
> Hi,
> 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. Hope there is a way!
> 

There are two possible approaches. Both rely on the fact that you can
create a StreamSource or SAXSource object that wraps a stream of bytes
or characters in memory.

One is to supply the second document source as the value of a stylesheet
parameter. JAXP doesn't say what kinds of objects are acceptable as
parameters, so this approach may depend on which XSLT processor you are
using; but recent versions of Saxon, for example, will allow any kind of
Source object to be supplied as the parameter value in the
addParameter() method.

The other approach, which should work with any processor that implements
the JAXP API, is to write a URIResolver. You can then load the second
document from your stylesheet using a URI such as "memory://doc2.xml",
and your URIResolver can intercept this and return the Source object
that wraps the in-memory document.

Either way, take care to use setSystemId() on the Source object to
allocate some kind of base URI to the document.

Michael Kay


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.