Subject: Re: [xsl] Q: Kaysian set difference in pure XPath statement From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 24 Mar 2011 17:24:18 -0400 |
Cheers, Wendell
--
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
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Q: Kaysian set difference, Hermann Stamm-Wilbra | Thread | [xsl] Convert a node-set to a strin, David Frey |
Re: [xsl] Q: Kaysian set difference, Michael Kay | Date | Re: [xsl] Q: Kaysian set difference, Hermann Stamm-Wilbra |
Month |