Eliot Kimber
2015-07-19 14:33:16 UTC
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
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk
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
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk