W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2001

setting document root element

From: Garret Wilson <garret@globalmentor.com>
Date: Wed, 19 Sep 2001 09:46:31 -0700
Message-ID: <00c701c1412a$b1768150$7245a640@odysseus2001>
To: "www-dom list" <www-dom@w3.org>
DOM 2 allowed the creation of a document root element only at the time the
element it created. However, there are *many* instances when one wants to
construct the root element in the same manner as the other elements. (After
all, the root element is only different from the other elements in its
location in the tree.)

Take, for instance, serializing a Java object to some XML representation by
using the DOM:

  Object object; //object to serialize
  Document doc=DOMImplementation.createDocument();
  Element root=createElement(object);

Element createElement(Document doc, Object object)
  Element element=doc.createElement(object.name);
  for each element attribute
    Element child=createElement(object.property[i]);
  return element;

Without the ability to set the document root, the elegant code above is
forced to special-case creation of the root element.

What's the status of this capability, and where can I go to find out more?


Received on Wednesday, 19 September 2001 12:49:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:09 UTC