Thanks for the pointer, I think I will take a closer look at the userData hook. Nevertheless it seems that I still have to write some wrapper class (e.g., MyDocumentImpl) that transparently and automatically sets a node's identifier when it is created via setUserData(). Or may I suggest a handler (in addition to the UserDataHandler of DOM3) that is called when a Document creates a node? ;) Oh, maybe one could use the DOM 3 event module for initialization.
Thanks again! Martin |-----Original Message----- |From: Joseph Kesselman [mailto:[EMAIL PROTECTED] |Sent: Tuesday, October 28, 2003 7:27 PM |To: [EMAIL PROTECTED] |Subject: Re: Node identifier | | | | | | |On Tuesday, 10/28/2003 at 09:59 PST, "Jeff Greif" |<[EMAIL PROTECTED]> wrote: |> A completely portable, low-tech, arms-length solution would be to |construct |> the document, then traverse it to construct one or both of the Maps, |> Node->Id and Id->Node, assigning the Id as you go. | |Unfortunately, before DOM Level 3 there is no really good way |to build a complete Node-to-arbitrary-data map. The DOM API |doesn't guarantee that node identity implies object identity |(that is, there may be more than one Node object representing |the same DOM Node), nor does it support hashing. You can try |to do something with adding magic attributes to the elements |to carry this info, but non-Element nodes are still a |challenge. The most general solution is to calculate what |amounts to XPaths for every node and index the map by those... |which is fragile if you plan to edit the DOM's |contents; essentially, you wind up maintaining a parallel |tree, which gets ugly. | |Which is why DOM Level 3 -- as of the last time I checked, |anyway -- is planning to introduce both the userData() hook |and the isSameNode() test. The latter closes the oversight of |not having a way to ask whether two Node objects are the same |DOM Node; the former provides a general/encapulated way to |maintain this sort of side information without having to deal |with parallel trees or implementation-specific characteristics. | | |--------------------------------------------------------------------- |To unsubscribe, e-mail: [EMAIL PROTECTED] |For additional commands, e-mail: [EMAIL PROTECTED] | | --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
