[xsl] Q: Kaysian set difference in pure XPath statement

Subject: [xsl] Q: Kaysian set difference in pure XPath statement
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Thu, 24 Mar 2011 21:33:29 +0100
Hello,

I saw a question on what "//*/*" means.
The answer is simple, all nodes beside the root element node.

This can be easily seen by this XPath expression:
$ echo "<a><b><c/></b><b><c/><c/></b></a>" | xpath++ "count(//*)-count
(//*/*)" -
1
$

Now I wanted to use Kaysian set difference method to output the
node in "//*" which is not in "//*/*", see 1a on this page:
http://www.xml.org//sites/www.xml.org/files/xslt_efficient_programming_techniques.pdf#page=3

But here two nodesets ($ns1, $ns2) are determined first before determining
the set (asymmetric) difference as "$ns1[count(.|$ns2)!=count($ns2)]".

Is it possible to have that as pure XPath statement?
The problem is to jump out of the scope of "//*[. ...]".


This does not work correctly:
$ echo "<a><b><c/></b><b><c/><c/></b></a>" | xpath++ "//*[count(.|
ancestor-or-self::*//*/*)!=count(ancestor-or-self::*//*/*)]" -

-------------------------------------------------------------------------------
<a><b><c/></b><b><c/><c/></b></a>
-------------------------------------------------------------------------------
<b><c/></b>
-------------------------------------------------------------------------------
<b><c/><c/></b>
$


What is the correct XPath statement for "//* minus //*/*"?


[1]
https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14511881#145
11881


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

Current Thread