W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: Equality tests on DOM nodes

From: Richard L. Lavallee <rll@eps.inso.com>
Date: Fri, 11 Dec 1998 16:47:39 -0500
Message-Id: <199812112147.QAA11011@chineseballs.eps.inso.com>
To: akuchlin@cnri.reston.va.us
CC: www-dom@w3.org, xml-sig@python.org

Regarding the problem of comparing DOM nodes,
one implementation solution is to assign a "DOM node identifier" (DNI)
to each DOM node, and use these as the basis for comparison.

A DNI is an integer, base 1, which monotonically increases up to the
maximum number of nodes in a particular DOM.
The root node DNI is assigned "1", and the remainder are assigned
in pre-order.

When nodes persist their DNI's persist with them, for any given
version of the particular DOM instance.

So:  how may any two DOM nodes be compared?

Just examine their respective DNI's numerically.

E.g.. a DOM node with DNI 42 is "==" to a DOM node with DNI 42.

DNI_42 > DNI_5

DNI_9 < DNI_12

Of course, this works best for read-only DOM's;
because arbitrary node insertion would disrupt the DNI sequencing.
But I would argue that node insertion results in a new document version
which necessarily has its own uniques set of DNI's anyway.

How's that?

-rll
Received on Friday, 11 December 1998 16:49:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:46 GMT