[XML-SIG] Re: Equality tests on DOM nodes
Richard L. Lavallee
rll@eps.inso.com
Fri, 11 Dec 1998 16:47:39 -0500
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