[jdom-interest] detach() [eg]

Scott Means smeans at moonlightideas.com
Mon Apr 23 22:46:28 PDT 2001


Ok, how's this for an alternative. I think that everybody agrees that
create a new, randomly named element is a Bad Idea. How about this: in the
root element case, go ahead and detach the element from the document. Then,
clone it and put the cloned copy back in the document. I know, it's kind of
ugly, but the document still has a root. No exceptions need be thrown. Your
original element is now free to join another tree somewhere else. As a
programmer, I might think it was kind of odd to still have an extra copy of
an element that I thought I had detached, but I would probably be able to
deal with it. At least is isn't as ugly as having <randomly-named-elements>
floating around in my document. I can just see too many cases (particularly
like the one where the stack-oriented application guy was going) where
these things will find their way into the body of the document, and I would
prefer to nip the three hour debugging session in the bud if I could.

Anyway, it's another option.

=======================================
Scott Means (smeans at moonlightideas.com)





More information about the jdom-interest mailing list