[jdom-interest] SAXBuilder and custom JDOMFactory

Brett McLaughlin brett at newInstance.com
Mon Sep 17 11:59:42 PDT 2001


on 9/17/01 3:14 AM, Sebastien Pierre at Sebastien.Pierre at isb-sib.ch wrote:

> Hi all,
> 
> I am quite new to JDOM, and am trying to subclass Element and Document
> classes, which is almost done. The problem is when I want to create my
> custom Document (XMLDocument) using SAXBuilder and my custom factory,
> which redefines Element and Document creation to return my subclasses
> instances.
> 
> When using SAXBuilder with my customized classes I get the following
> error:
> 
> [java] New root elem is:[Element: <Configuration/>]
> [java]  of type:class net.sourceforge.spedit.core.XMLElement
> [java] org.jdom.IllegalAddException: The element "Configuration"
> could not be added as the root of the document: The element already has
> an existing parent (the document root)
> [java] org.jdom.IllegalAddException: The element "Configuration"
> could not be added as the root of the document: The element already has
> an existing parent (the document root)
> [java]     at org.jdom.Document.setRootElement(Document.java:199)
> [java]     at
> net.sourceforge.spedit.core.XMLDocument.setRootElement(XMLDocument.java:342)
> 
> Configuration is the root node of the XML file I want to load. What it
> strange is that it is added twice, and I really don't see why. What is
> also strange is that there is no problem with the default SAXBuilder,
> but the only difference is my custom JDOMFactory, which is so simple...
> I'm kind of lost.
> 
> Any ideas on why this happens?

Post your XML and your JDOMFactory implementation, and we'll get it figured
out.
-- 
Brett Mclaughlin       <http://www.newInstance.com>
Lutris Technologies    <http://www.lutris.com>
Author, "Java and XML" <http://www.oreilly.com/catalog/javaxml2>





More information about the jdom-interest mailing list