[jdom-interest] Default document constructor

Jason Hunter jhunter at acm.org
Tue Jan 8 09:45:45 PST 2002

You explained the issue quite nicely.  It's a nice-to-have feature but
on the other hand you're creating a non-well-formed document.  Right now
we're in a compromise state with passing null as a power-user feature. 
Any push to the other direction hits resistance.


Kevin Jones wrote:
> Why is the default Document constructor protected?
> I can understand logically that a Document should contain some content
> (and according to the XML specs must contain a root element) but it
> would often make my programming logic more logical if I could create an
> empty document and then add content to it, rather than creating content
> first and constructing the document with that content.
> I can create an empty document (in at least two ways I think)
> e.g.
> new Document((org.jdom.Element)null);
> where the cast could also be to java.util.List.
> or
> elem = new Element("foo");
> doc = new Dcoument(elem);
> elem.detach();
> And this is sometimes necessary (especially the second case), so 'naked'
> Documents are possible. This would seem a nice-to-have feature,
> Kevin Jones
> Developmentor
> www.develop.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list