Hi Jim
A node or Element either has a parent or it doesn't. You can call
getParent() to find out what it is, to add some debugging tracing to your
code if it helps. I can't see how ClassLoading can change this in any way so
I'm pretty stumped on what this problem is.
James
----- Original Message -----
From: "Brain, Jim" <[EMAIL PROTECTED]>
To: "'Dane Foster'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>; "Brain, Jim" <[EMAIL PROTECTED]>
Sent: Monday, November 26, 2001 11:34 PM
Subject: RE: [dom4j-user] I have a strange issue with dom4j.
>
> Brain wrote:
> >public void setData(Element e) {_e=e;}
> try this:
> public void setData( Element e ) { _e = e.detach(); }
>
> No go. Tried that.
>
> Brian wrote:
> >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().
>
> Does you default J have a default/empty constructor that creates an empty
> Element object?
>
> No, but I have called setData() before calling getData(). setData does
what
> have above, _e=e.detach(). Sorry about not including that.
>
> Jim
>
>
> Dane Foster
> Equity Technology Group, Inc
> http://www.equitytg.com.
> 954.360.9800
> ----- Original Message -----
> From: "Brain, Jim" <[EMAIL PROTECTED]>
> To: "DOM4J Mailing List (E-mail)" <[EMAIL PROTECTED]>
> Sent: Monday, November 26, 2001 5:35 PM
> Subject: [dom4j-user] I have a strange issue with dom4j.
>
>
> 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
>
>
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user