[jdom-interest] detach() [eg]

philip.nelson at omniresources.com philip.nelson at omniresources.com
Wed Apr 18 06:38:24 PDT 2001

> There are a thousand or more ways to produce an ill-formed document
> using JDOM.  

I don't think there are, really!  I have been trying to exercise all the set
and add methods with bad data.  I have verified in excruciating detail that
the Verifier only allows valid xml characters, names and content.  My
intention is to take the entire suite of OASIS/NIST xml tests (at least
those I can get to parse) and run them through JDOM. If you see some other
big holes, bring 'em on!  I've already got 132 tests released, more in the
works (Document is next) and each tests contains from 2 to 20 assertions.
> Hopefully, all of them are programmer errors, like
> forgetting to add a root element to the document.  I can't think of a
> good excuse for shoehorning <a-random-element /> into the root
> position, in defiance of the expectations of the programmer who just
> emptied the document out *on purpose*, and I don't agree that
> well-formedness is a sufficiently good excuse--certainly not 
> as long as
> one can add children to elements that do not belong there (JPanel,
> java.sql.Connection, java.util.HashMap).

You may not agree that it's worth it, but I don't agree that in JDOM's case
that the api is in defiance of the programmer's expectations.  Honestly, if
I did something stupid like expecting my document to ouput after I emptied
the content (naturally this would NEVER happen), I would find it far more
useful viewing the broken document had a <placeholder /> element than the
outputter throwing a NullPointerException that I would have to troubleshoot.
> In other words, if we're going to enforce well-formedness, 
> then we have
> to enforce it (and in the process, take power and flexibility 
> away from
> the programmer; it always happens that if you dull a knife to keep it
> from cutting someone's hands, it's harder to cut the bread).  We have
> to enforce it *everywhere*, and not just here, in a place where it's
> easy.

Well danged if we don't have a sharp knife AND a big hammer!

More information about the jdom-interest mailing list