[jdom-interest] detach() [eg]
Ken Rune Helland
kenh at csc.no
Fri Apr 20 02:01:12 PDT 2001
At 01:04 AM 4/20/2001 -0700, Jason Hunter wrote:
>Joseph Bowbeer wrote:
> >
> > 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?
>
>Under the current design, what a developer can trust is: Any JDOM
>Document is a well-formed document, and any JDOM Element is a
>well-formed document fragment. So if you're writing an outputter or doc
>manipulator, you know you don't have to check any well-formedness.
>It'll be checked for you.
>
>Note you can't really have a root element with no associated document.
>If there's no doc, it's not a root element, it's just an element.
>
>Yes, it's ugly to have a root replacement added. It's also ugly to
>break the well-formedness contract. Which one's less ugly?
>
>-jh-
I think this was suggjested before; how about
allowing the Document to have null as root but have it
throw IllegalStateException on all metods except
setRootElement.
This will allow you to detach the root of a document
and throw the document away (which I guess is the most
usual ting to do with the Document after you detach the
root) and if you actually plan to use the Document object
it makes it quite clear if the programer somehow forgot
to set a new root element.
KenR
More information about the jdom-interest
mailing list