[jdom-interest] SAXBuilder and custom JDOMFactory

Sebastien Pierre Sebastien.Pierre at isb-sib.ch
Mon Sep 17 01:14:27 PDT 2001


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?

Cheers,

 -- Sebastien.



More information about the jdom-interest mailing list