[jdom-interest] detach() [eg]

philip.nelson at omniresources.com philip.nelson at omniresources.com
Thu Apr 19 11:12:31 PDT 2001

> philip.nelson at omniresources.com wrote:
> > 
> > What if we had getRootElement() throw an 
> Illegal<something>Exception when
> > the placeholder was there?  Then it wouln't matter at all 
> how the internal
> > state was kept.  Other than to see if you have this bogus 
> Document, I can't
> > see any valid reason you would want to get the root 
> element.  If you try to
> > output the document, you would get a meaningful error.  If 
> you can't be
> > sure, you can attempt to get the root element and use a try 
> catch to do the
> > right thing.  Meanwhile, everything else works exactly the same way.
> > Element.MISSING_ROOT_ELEMENT would have the meaningful text 
> to use in the
> > exception and could be protected an it's presence gives you 
> a nice location
> > to document the behaviour.
> I like this idea.  Is it consistent though with our goal that 
> JDOM docs
> in memory are well-formed?  We'd have well-formed, or malformed but
> you'll get an exception when you try something with them.  Hmm...

I think internally we could leave the placeholder there.  This way, for
internal uses the Document is still well formed.  The net effect is that we
go from well formed but meaningless to well formed, meaningless with
notification to the user if they don't deal with it.

Mostly, from this discusion thread I was thinking about a system where a lot
of documents pass through.  Without some kind of error, I could potentially
not even know about the problem until I had erroneously saved documents that
were perfectly well formed AND totally useless :-)

More information about the jdom-interest mailing list