[jdom-interest] Question about JDOMResult and usage with XMLReader

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Jul 30 00:59:39 PDT 2002


The SAXException "Ill-formed XML document (multiple root elements detected)" 
is thrown whenever SAXHandler (used by JDOMResult and SAXHandler) is 
processing data that should be added to the current element but no current 
element exists.

This usually signals a bug in an XSLT stylesheet which leads the XSLT 
processor to generate documents with several root elements or with text or 
CDATA sections directly at document level.

Laurent

Mario Felarca wrote:
> Hello all,
> 
> I have searched the archives, and have also compiled my own jar from the 
> latest tree, but I am experiencing some weird behavior and I was hoping 
> someone else may know what is causing this problem.
> 
> I have some code that is transforming data. I have an XMLReader that is 
> setting an ContentHandler from a templates object as its content 
> handler. The handler to that is being set as one of two things (since I 
> was testing both).
> 
> The first case, which doesn't work, is when I do the following.
> 
> JDOMResult jdr = new JDOMResult();
> current.setResult(jdr);
> 
> reader.parse(jds.getInputSource());
> 
> Where current is the content handler for a templates object and reader 
> is the XMLReader.
> 
> This throws me the following exception on the reader.parse line.
> 
> java.lang.RuntimeException: org.xml.sax.SAXException: Ill-formed XML 
> document (multiple root elements detected)
>     at 
> org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3392)





More information about the jdom-interest mailing list