[jdom-interest] detach() [eg]

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Apr 25 11:57:45 PDT 2001


At 11:00 AM -0700 4/25/01, Jason Hunter wrote:
>Brett McLaughlin wrote:
>>
>>  I'm with Elliotte that detach should not be on the Element, but on the
>>  Element's parent.
>
>We already have Element.removeContent().  If you're suggesting a new
>method Document.detach(Element) or Document.removeContent(Element) then
>it's no better than status quo because that call would still allow
>non-well-formed documents.
>
>Or is your argument that detach() should go away, that
>Element.removeContent() should remain, and that Document should thus
>have no way to detach its root short of the programmer substituting a
>new root in place of the old with setRootElement()?  Ugh.
>

That is what I'm suggesting, though perhaps detach() should be the 
preferred name instead of removeContent(), but I'm not picky about 
that. I don't find it at all ugly. It seems to me to follow directly 
from the basic premises of JDOM, one of which is that all documents 
are well-formed. If Java had a way to delete an object so that noone 
could use it, then I might feel differently but since Java does let 
the Document object live, I think we need to ensure it is well-formed.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list