- From: Keith W. Boone <kboone@ebt.com>
- Date: Tue, 2 Jan 2001 09:59:45 -0500 (EST)
- To: "Robin Green" <r.d.green@lancaster.ac.uk>, <www-dom@w3.org>
If you are simply talking about serializing objects, one way to handle cycles in the graph is to record an ID for each object that has not yet been serialized, and when you encounter it again instead of recording the entire object, simply generate an IDREF to the matching ID. Keith -----Original Message----- Sent: Monday, January 01, 2001 9:34 PM To: www-dom@w3.org Subject: Proposal: Lazy evaluation I'm investigating possibilities for converting objects from an object database into DOM fragments (for use in the XML publishing framework, Cocoon). I would like to do a sort of "deep convert" so that an object, all its fields, all _its_ fields, etc. would be converted recursively. I did think of actually _implementing_ a DOM myself so I wouldn't have to convert the objects, but this will generate WRONG_DOCUMENT errors on at least some DOM implementations. First problem - the DOM generated may be excessively large, generating more data than is actually needed by the presentation layer, which is inefficient. Secondly, there may be cycles in the object graph, which means that a naive conversion algorithm would go into an infinite loop! Both of these issues could be addressed by specifying a maximum recursion depth. However, it is conceivable that the optimum recursion depth may not be easy to determine at conversion time. Thus, I would like to suggest a facility in the DOM for lazy evaluation. It would be a proxy node which you would pass a callback function, and the callback function would only actually be called, to create the real node, if and when the node was referenced (i.e. when getChildNode or whatever was called). In other words, the very act of requesting the node would create it (this modification might have to be specifically excluded in the specification from the definition of a non-modifiable document). Issues: * Language-independent callbacks?? * Exceptions could happen at unexpected times (but, in my experience, this problem crops up almost everywhere!) * This would allow infinitely deep DOMs, and there would be no obvious way for DOM clients to detect the problem of an infinitely deep DOM. However, it would be useful from an efficiency point of view. Comments?
Received on Tuesday, 2 January 2001 10:35:15 UTC