I don't even know how to explain it.

Here's what works:

Two documents, a and b:

a.add(b.getRootElement().detach());  (leaving off casts for ease of
explanation)

Works.

Hwoever, I have created a class:

class J {
private Element _e;

public void setData(Element e) {_e=e;}
public Element getData() { return _e;};
}

When called like this:

Element e.add(J.getData());

It yells at me that the node already has a parent.

So, I changed getData above to be:

{ Document d=DocumentHelper.createDocument; d.addRootElement(_e) ; return
doc.getRootElement().detach(); }

strangely, this works. 

However, now here's the weird part:

In my code, I have a piece of code that allows you to modify what classes
are used for "J".   I have a default J implementation, but someone can
override (ala SAXParser System Property) J to be their implementation.  I
use Class.forName() to load the custom J classes.

If I load the default J class via a class.forName, it fails with the same
ode has a Parent error, even though the same code works when loaded without
Class.forName().

It is extremely strange, and I tried to boil down the test to something
small.  However, it seems the classloader, the having it in a separate
class, and the dynamic part is essential to the bug showing up.

Anyone else seen this?  Am I missing something?  No concurrent threads in
the program, so I have mostly ruled out threadsafety issues.

Jim


Jim Brain, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
"Researching tomorrow's decisions today."
(319) 369-2070 (work)
Systems Architect, Individual ITS, Life Investors Insurance Company of
America


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to