[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Q: Kaysian set difference in pure XPath statement
Subject: Re: Q: Kaysian set difference in pure XPath statement
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 24 Mar 2011 21:18:34 +0000
|
On 24/03/2011 20:33, Hermann Stamm-Wilbrandt wrote:
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?
You're using "pure XPath" to mean "XPath 1.0", which seems a bit odd to
my ears....
The problem is to jump out of the scope of "//*[. ...]".
What (apart from efficiency) is wrong with
//*[count(. | //*/*) != count(//*/*)]
(Though it's not clear why you can't just write /*)
Michael Kay
Saxonica
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|