Many thanks Shane - I totally didn't understand the metaphor at all! This gets me going in the right direction and I have my test situation working at least. Now to delve into SAXTransformerFactory...
Thanks again Mike On 6/3/02 9:13 AM, "Shane Curcuru" <[EMAIL PROTECTED]> wrote: > Um, I think you have a metaphor missing somehow - your code doesn't > 'look' right to start with, so I'm not quite sure I understand what > you're trying to do. > > It sounds like you're trying to run one stylesheet to basically get > three source documents munged together, and then run a second > stylesheet on the result of that tree. There are a number of ways to > do that, but your call to: > transformer.transform(resultSource , new StreamResult(System.out)); > is (sorry to say it) completely wrong. The first argument to > transform() must be the xml source data document you want to transform, > not a stylesheet. (you're basically transforming the stylesheet as > data, which is not what you want). > > The simplest way to do this is to do two separate transforms: first, > use the copy.xsl stylesheet (with any random xml document as a source, > since you never reference it) and put it out to temp.xml. Then run > another separate transform using transform.xsl and temp.xml to get your > output. Being simple, of course, this is somewhat inefficient. > > Other ways to do it include delving into the SAXTransformerFactory and > having one transformer just pass the sax stream to the second one, > which creates the output, and the pipeDocument sample below. > > > A useful sample to study would be: > http://xml.apache.org/xalan-j/extensionslib.html#pipedocument > Note that you don't really need to understand the inner code workings, > just that you can have one stylesheet that runs a source doc through > multiple other stylesheets. > > Minor note: if you know your documents will always be local, you can > just pass local file: URLs to the StreamSource constructors, instead of > bothering to create new URL(...).openStream() - this will be faster > than creating the extra object. But this is a maintenance decision, > depending on where you get the info for your inputs from. > > > ===== > - Shane > > <eof aka="mailto:[EMAIL PROTECTED]" > .sig="Du sublime au ridicule il n'y a qu'un pas." /> > > __________________________________________________ > Do You Yahoo!? > Yahoo! - Official partner of 2002 FIFA World Cup > http://fifaworldcup.yahoo.com >
