Re: critique of WD-DOM-19980416

Comment on knowledge of Document:

As written now, the DOM implies that all new objects are created using the 
Document interface. 

I agree with this, as it allows the mixing of different DOM implementations
in one program, the mixing of objects from different servers in a 
distributed environment, a convenient place to take care of persistence 
issues, and so forth. 

However this has another implication which has not been explicitly dealt 
with in the current API:

Many objects in the system are going to have to know what document they 
belong to. 

For example, it is possible to create new attributes without using 
the Document directly:

   Element elem = Document.createElement(...);
   elem.setAttribute(name, value);  
   Attribute attr = elem.getAttributeNode(name);

So somehow Element had to know how to create a new Attribute, presumably 
by calling Document.createAttribute(..) -- which means that Element has 
a way of finding out what Document it belongs to. 

Note that it would be unwise for Element to try and bypass its containing
Document when creating new Attributes, since the Document might have some 
specific values that need to be set in the Attribute for persistence 
reasons, etc., that may be different from one document to the next.

The consequence of all this is that I think there should be a 

    getContainingDocument()

method present on some of the objects. All Node objects could have this 
method, though many of them might find their containing document by 
asking their parent (to save wasting memory on many references).

Justin

Received on Saturday, 27 June 1998 21:11:41 UTC