Re: Standard XPath expression for the intersection of two node se ts (Was: RE: How can I test if an node included in a nodeset)

Subject: Re: Standard XPath expression for the intersection of two node se ts (Was: RE: How can I test if an node included in a nodeset)From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>Date: Fri, 04 Aug 2000 21:27:41 -0400

At 00/08/04 14:23 -0600, Mike Brown wrote:

For those of us who can't wait for the 8th edition,

Ninth. :{)}

and who somehow missed
the original post, could someone recap what the Kaysian Method is? I'd go
look it up in the archives, but they're hosed.

Sometimes it is necessary to determine the intersection or difference of
two node-sets selected from the source tree. The following expression,
colloquially referred to as the "Kaysian Method" after Mike Kay who first
proposed this use of XPath, will select only those nodes that are in both
of two node-set variables named set1 and set2:

· $set1[count(.|$set2)=count($set2)]

The above expression takes advantage of the XPath union operator to
determine that a given node doesn't impact on the count of nodes of the
union of the node and the second node-set. The predicate returns true when
the count isn't affected, thus including the member being tested. It is
not necessary to test the members of the second set because the
intersection would have to include members of the first set, all of which
are being tested in the above expression.

The symmetric difference requires an expression involving the union of the
determination of those nodes in each set that are not in the other set:

The following script illustrates the assignment of two node-set variables
from a common area of the source tree (in this case the stylesheet is also
the source tree) and the intersection and symmetric difference of those two
variables: