[jdom-interest] detach() [eg]

Jason Hunter jhunter at collab.net
Mon Apr 23 23:31:44 PDT 2001

Scott Means wrote:
> 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.

Problem is, if the doc is non-trivial in size that little clone() call
is going to be quite a resource drain.


More information about the jdom-interest mailing list