Re: [xsl] () eq () vs () = ()

Subject: Re: [xsl] () eq () vs () = ()
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 30 Sep 2011 16:36:51 +0100
>If () = () is false, then it's intuitive (to me) that deep-equal((), ()) is also false. The one liner saying that it should be true just seems like it could easily say false.

A = B means (some $a in A, $b in B satisfies $a eq $b). Therefore () = () is false.

deep-equal(A, B) means (count(A) eq count(B) and every $i in 1 to count(A) satisfies A[$i] eq B[$i]). Therefore deep-equal((), ()) is true.

So it's perfectly consistent. It's also absolutely necessary. Given that for two elements to be equal, their sequences of children have to be deep-equal, it would be very odd if two elements were not deep-equal simply because neither has any children. Indeed, it would be very odd if an element were not deep-equal to itself.

(Note, the above expansions are approximate. They don't quite handle NaN, but that's another can of worms.)

Michael Kay
Saxonica

Current Thread