I've seen on SO and other places that the following is supposed to work (this example is lifted directly from O'Reilly's XSLT Cookbook):
(: intersection :)
$set1[count(. | $set2) = count($set2)]
(: difference :)
$set1[count(. | $set2) != count($set2)]
and it looks like it should be OK, however this seems to fail when used with actual paths rather than variables. For example, given the following document
<a>
<new>
<val>1</val>
<val>2</val>
</new>
<old>
<val>2</val>
<val>3</val>
</old>
</a>
and the XPath expression /a/new/val[count(. | /a/old/val)=count(/a/old/val)]/text()
I would expect to get the node-set { 2 }
but instead am getting { 1 2 }
. Any ideas what I'm doing wrong?