Gary, 
        You can use the sample xml/xsl files that come with any Xalan
distribution
and you'll get the same errors.

-----Original Message-----
From: Gary L Peskin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 1:31 PM
To: [EMAIL PROTECTED]
Subject: Re: Exception using DOMResult


Your input DOM is fine.  The problem is with the output.  DOM only
allows one Element below the Document Node.  This is called the Document
Element.  It looks like you're trying to ask Xalan to create a DOM with
more than one Document Element (or possibly a text Node) below the
Document.

If you're having problems diagnosing the error after this explanation,
please attach the XML produced by your StreamResult and we'll have a
look.

Gary

> David Frankson wrote:
> 
> I'm having problems getting an xml Document as the result of a
> transformation.  I get a sax exception - Can't have more than one root
> on a DOM!
> 
> If I use any other result type, Xalan works fine and I get the output
> I expect.  I double-checked both input files and the output, and
> everything is well formed.  I think it has to do with how I'm building
> the xml source.
> 
> I have business logic that returns an xml Document, and then I use
> Xalan and a xsl page to transform it.  I want to keep it as a Document
> so that I can pass it on to FOP.  When the business logic builds the
> dom, I use the DOM Level III command adoptNode implemented by Xerces
> 1.4.2.  Is it possible that this method returns the dom in a slightly
> different format than xalan expects?  When I use this method and use a
> StreamResult everything works fine, but a DOMResult throws an
> exception.
> 
> Does anyone know more about how the DOMResult is built and why this
> exception would occur?  Or could you suggest a work-around -- Is there
> a better way to combine two Document objects than use adoptNode?
> 
> Thanks,
> 
> Dave Frankson
> 
> 
> 
> org.xml.sax.SAXException: Can't have more than one root on a DOM!
> at org.apache.xml.utils.DOMBuilder.append(DOMBuilder.java:203)
> at org.apache.xml.utils.DOMBuilder.startElement(DOMBuilder.java:308)
> at
>
org.apache.xalan.transformer.ResultTreeHandler.flushElem(ResultTreeHandler.j
ava:843)
> at
>
org.apache.xalan.transformer.ResultTreeHandler.flushPending(ResultTreeHandle
r.java:914)
> at
>
org.apache.xalan.transformer.ResultTreeHandler.endElement(ResultTreeHandler.
java:298)
> at
>
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:
668)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApp
lyTemplates.java:423)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
a:226)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApp
lyTemplates.java:423)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
a:226)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApp
lyTemplates.java:423)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
a:226)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApp
lyTemplates.java:423)
> at
>
org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.jav
a:226)
> at
>
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Transform
erImpl.java:2096)
> at
>
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Transformer
Impl.java:1927)
> at
>
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.j
ava:1120)
> at
>
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
590)
> at
>
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1037)
> at
>
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1015)

Reply via email to