In that case, I'll need to see your java code where you set up the
DOMResult and invoke the transform.  Are you using a Node in your
DOMResult constructor?  If so, is it a Document Node?  If so, does it
already have a child Element?  If so, that is your problem because your
DOM structure already has a document element so when XalanJ tries to add
another you get the "Can't have more than one root on a DOM!" message.

In any event, I'll be able to tell more when I see your Java code.

Thanks,
Gary

"Shustef, Eugene" wrote:
> 
> 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