In the following example, both $yo and $yo2 are obtained in the context of $all, but $yo2 is interpreted in the context of $t2b.
let $t2a := <topic><title id="yo">2.1</title></topic> let $t2b := db:open('test')/*[@id='topic'] let $all := <map><title>Map</title>{$t2a}{$t2b}</map> let $yo := $all//*[@id='yo'] let $yo2 := $all//*[@id='yo2'] return ($all, count($yo/ancestor::*), count($yo2/ancestor::*))
returns
<map> <title>Map</title> <topic> <title id="yo">2.1</title> </topic> <topic id="topic"> <title id="yo2">2.2</title> </topic> </map> 2 1
I would have expected both ancestor::* clauses to return 2. If I ask for the last ancestor of $yo2, I get <topic id="topic">, again wrong context.
The only way for me to force $yo2 to pick the node from the context of $all is to create a copy of $all, and then work from the copy.
Why would yo get into context, but not yo2?
What is stored in your test database?
On Mon, Jun 22, 2015 at 3:22 AM, France Baril france.baril@architextus.com wrote:
In the following example, both $yo and $yo2 are obtained in the context of $all, but $yo2 is interpreted in the context of $t2b.
let $t2a := <topic><title id="yo">2.1</title></topic> let $t2b := db:open('test')/*[@id='topic'] let $all := <map><title>Map</title>{$t2a}{$t2b}</map> let $yo := $all//*[@id='yo'] let $yo2 := $all//*[@id='yo2'] return ($all, count($yo/ancestor::*), count($yo2/ancestor::*))
returns
<map> <title>Map</title> <topic> <title id="yo">2.1</title> </topic> <topic id="topic"> <title id="yo2">2.2</title> </topic> </map> 2 1
I would have expected both ancestor::* clauses to return 2. If I ask for the last ancestor of $yo2, I get <topic id="topic">, again wrong context.
The only way for me to force $yo2 to pick the node from the context of $all is to create a copy of $all, and then work from the copy.
Why would yo get into context, but not yo2?
basex-talk@mailman.uni-konstanz.de