The Document Class
JDOM's Document class, summarized in Example 15.1, represents a complete well-formed XML document. As a node, it is the root of the document tree. It enforces most of the rules XML imposes on documents. For example, it is not possible to assign two DocType objects to a single Document object because an XML document cannot have two document type declarations. The single exception to this rule is that it is possible for a Document to be temporarily rootless if it's built by the no-args constructor. In that case, however, almost anything you do with the document other than setting a root element will throw an IllegalStateException. In effect, then, this is just a temporary convenience, not a loophole that allows you to break the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access