- From: Joseph Kesselman/Watson/IBM <keshlam@us.ibm.com>
- Date: Wed, 11 Oct 2000 12:41:40 -0400
- To: "Kevin Jones" <kevinjz@hotmail.com>
- Cc: www-dom@w3.org
> How does one subclass DOM Nodes? Is the DOMImplementation class used somehow > to get at a Node factory? The Document node is the factory for all nodes contained in that document. You could subclass Document to provide special handling of specific Elements. Note that this is inherently nonportable. First off, the actual construct-and-configure sequence for the nodes is implementation dependent; you need to know exactly how your DOM implementation handles this before you can rewrite the createElement method appropriately. Secondly, and just as important: When you subclass, you're always subclassing a specific parent class; to move a subclassing to another DOM, you'd have to edit the code to change that parent even if all else was the same (which is unlikely). Another possible approach,less elegant but more portable, would be a "lightweight subclassing" scheme. Here, you would annotate "standard" nodes rather than subclassing them -- eg, by providing one or more tables indexed by node identity which can be used to retrieve whatever additional information and/or code you want to associate with it. The challenge here is that "node identity" is not necessarily the same as the address of the Node object (eg if your DOM is a proxy for some other data structure, you might have several objects proxying the same datum and thus representing "the same node), so it isn't clear what could be used as an index for those tables. DOM Level 3 is investigating this. ______________________________________ Joe Kesselman / IBM Research
Received on Wednesday, 11 October 2000 12:42:30 UTC