- From: Michael Champion <mike.champion@sagus.com>
- Date: Tue, 5 Oct 1999 15:05:59 -0400 (EDT)
- To: <www-dom@w3.org>
This is a semi-official Software AG response to the "Last Call" for comments on DOM Level 2: [I apologize to the WG for not raising this before the Last Call draft, but we agreed at the August meeting to take this to e-mail to figure out a solution for for Level 2; that discussion never happened, and since I was travelling for most of the rest of August I did not notice.] We believe that it is important to have a method in DOM Level 2 to get an element by the value of its ID attribute. There is a getElementById() method for HTML in DOM Level 1, and this is also needed by XML developers. Several DOM implementations, including Microsoft's widely used one, have such a method, and its lack in DOM Level 1 is often noted. The DOM Working Group has considered this issue on several occasions; the general feeling has always been that a) this could only work for XML documents that have a DTD, and the DOM (like XML) does not require a DTD ; so b) a more general mechanism that could be used to look up elements by ID as a special case is preferred. Unfortunately, no such general mechanism has been agreed upon. Therefore, we strongly urge the WG to simply adopt the getElementById() method in the HTML DOM as an XML method in Level 2 rather than waiting until Level 3 for a "better" solution. As for what to do when there is no DTD, or a DTD that does not define an ID attribute, I suggest that it simply return null, just like the HTML DOM. I could imagine that a DOMException could be thrown, but in the interest of simplicity I would suggest making it identical to the HTML method. So, I'm suggesting that to the Document interface, add the method Element getElementById(in DOMString elementId) "Returns the Element whose ID is given by elementId. If no such element exists, return null. Behavior is not defined if more than one element has the id." So, do people on this list support this idea? Is returning null the right solution for the situation where there is no ID defined *or* no element matches the specified ID? Does it make *practical* sense to distinguish these two situations? Is this an excessive burden on DOM implementors? ( I really don't think so, especially in Java, since this is easily done with java.util.Hashtable ....or am I missing something?). Thanks, Mike Champion
Received on Tuesday, 5 October 1999 16:36:01 UTC