Hi Peter,

I suspect your output XML is not actually valid.

This is not a valid xml document
  <foo/>
  <foo/>
because there is more than one element at the "top level".

Neither is this (text nodes must be nested within an element).
  <foo/>
  some text

However when using a StreamResult, this requirement isn't enforced
as the output doesn't have to be XML.

When using a DOMResult, the result *must* be well-formed XML (which the
above example is not).

However all this DOMResult stuff is not really addressing your problem;
I believe you want to really specify "no destination" for your
transform, because the output isn't actually relevant as you are using
the <redirect> extension to specify that from within the stylesheet. 

I'm not familiar with the <redirect> extension, but one possible
solution is to simply use the StreamResult constructor that takes a
ByteArrayOutputStram as the target, rather than a file. Or (more
efficiently), you could write your own trivial Result class which just
discards everything passed to it.


Regards,

Simon

PS: this "Can't have more than one root on a DOM" appears to be a
replacement for the old "DOM_HIERARCHY" error message. A vast
improvement :-)


On Tue, 2003-06-17 at 14:13, peter peter wrote:
> I am using xalan2.2.1
> I am using <redirect> extension to create multiple output files. I
> don't want to specify any outputfile name(Result) in the transform
> method, as i want <redirect> to create multiple output files.
>  
> I am getting following problems.
> 1. if I use this,
>  transformer.transform(new DOMSource(doc),new DOMResult() );
>  
>  I am getting this exception:
>  javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Can't have more than one root on a DOM!
> 2.  If i use this,
>  transformerImpl.transform(new DOMSource(doc),new StreamResult() );
>  
>  I got this exception:
>  javax.xml.transform.TransformerException: No output specified
>  
> 3.  If i use this,
>  transformerImpl.transform(new DOMSource(doc),new
> StreamResult("dummy.txt") );
>  
>  then I got the correct results, But I don't want to use this option
> as it is creating one dummy.txt file which I don't want.
>  
> I am ready to send my XSL file if anyone is interested.
> Any help or pointers in this regard, will be appreciated.
> Regards,
> Peter
> 
> 
> ______________________________________________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.

Reply via email to