[jdom-interest] Default document constructor

Kevin Jones kevinj at develop.com
Tue Jan 8 00:57:12 PST 2002


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 




More information about the jdom-interest mailing list