[jdom-interest] detach() [eg]

Joseph Bowbeer jozart at csi.com
Fri Apr 20 00:40:41 PDT 2001


> Do we really want this [placeholder], or should we simply
> set the root Element to null ?

I wonder, too.

Adding a place-holder may preserve the well-formedness of the document, but
it probably doesn't preserve the validity.

If we can have root Elements with no associated Document and non-root
Elements with no parent, what's so bad about Documents without roots?


----- original message -----
From: jools at jools.org
Date: Tue, 17 Apr 2001 21:42:45 +0100

Whilst working through the source code for Element.java I became
uncomfortable
with the detach() method.

    public Element detach() {
        Element p = getParent();
        if (p != null) {
            p.removeContent(this);
        }
        else {
            Document d = getDocument();
            if (d != null) {
                d.setRootElement(new Element("placeholder"));
            }
        }
        return this;
    }

Which means that if we detach a root element from Document it ends
up being a document with one root element <placeholder/>.

Do we really want this, or should we simply set the root Element to
null ?






More information about the jdom-interest mailing list