[xquery-talk] Find All Nodes Between Root Node and Descendant Nodes of Some Type

G. Ken Holman gkholman at CraneSoftwrights.com
Sun Jul 19 08:09:37 PDT 2015


How about:

   $a1//b except $a1//a//b

. . . . . .  Ken

At 2015-07-19 06:33 -0500, Eliot Kimber wrote:
>Given this starting document:
>
>Let $doc :=
><root>
><a id="a1">
>   <b>b1</b>
>   <b>b2</b>
>   <c>
>     <b>b6</b>
>   </c>
>   <a id="a2">
>     <b>b3</b>
>     <b>b4</b>
>     <a id="a3">
>       <b>b5</b>
>     </a>
>   </a>
>  </a>
>  </root>
>
>I want to find all the <b> elements descending from <a id="a1"> but not
>within nested <a> elements:
>
><b>b1</b>
>     <b>b2</b>
>     <b>b6</b>
>
>
>This gives me the correct answer:
>
>
>let $a1 := $doc/a
>let $bsInA1 := $a1//b[not(./ancestor::a = ($a1//a))]
>
>
>My question: With Xpath 3.1, is there a better way to express this query?
>I looked at the new outermost() and innermost() operators but I didn't see
>a way to apply them to this problem.
>
>Thanks,
>
>Eliot
>
>----
>Eliot Kimber, Owner
>Contrext, LLC
>http://contrext.com
>
>
>
>_______________________________________________
>talk at x-query.com
>http://x-query.com/mailman/listinfo/talk


--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Free 5-hour lecture:  http://www.CraneSoftwrights.com/links/video.htm |
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/q/ |
G. Ken Holman                    mailto:gkholman at CraneSoftwrights.com |
Google+ profile:       http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:     http://www.CraneSoftwrights.com/legal |


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the talk mailing list