- From: Garret Wilson <garret@globalmentor.com>
- Date: Wed, 19 Sep 2001 09:46:31 -0700
- 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: main { Object object; //object to serialize Document doc=DOMImplementation.createDocument(); Element root=createElement(object); doc.setRoot(root); } Element createElement(Document doc, Object object) { Element element=doc.createElement(object.name); for each element attribute { Element child=createElement(object.property[i]); element.appendChild(child); } 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? Thanks, Garret
Received on Wednesday, 19 September 2001 12:49:08 UTC