Hi,
I won't give a complete answer, just a few hints...
Todd Gochenour a écrit :
> I'm asking the eXist forum
This is not a forum (where the users go by themselves to read your mail)
; it's a maling-list (where your mail goes by itself to the users).
Never mind :-)
> declare function local:findRoots($s as xs:string)
>
> {
>
> ((collection('amm')/descendant::element()[. &= $s]) except
> (collection('amm')/descendant::element()[. &=
> $s]/ancestor::element()))/ancestor::*[name(.) = ('CHAPTER', 'PGBLK',
> 'TASK')][1]
>
> };
Why not factorize :
(collection('amm')/descendant::element()[. &= $s])
... bind it to a variable, say $i, reference it, an thus avoid double
evaluation, i.e. :
let $i := ((collection('amm')/descendant::element()[. &= $s])
return $i except $i/ancestor::element()))/ancestor::*[name(.) =
('CHAPTER', 'PGBLK', 'TASK')][1]
From there, you might prefer working with :
$i/ancestor::element()))/ancestor::CHAPTER |
$i/ancestor::element()))/ancestor::PGBLK |
$i/ancestor::element()))/ancestor::'TASK'
...rather than iterating over each context item (aka ".").
(factorization is also possible here, of course)
and then :
collection('amm')/descendant::element()[. &= $s] [empty(
./ancestor::element()))/ancestor::CHAPTER |
./ancestor::element()))/ancestor::PGBLK |
./ancestor::element()))/ancestor::'TASK'
)]
Swapping the 2 filtering expressions might also be considered, depending
of your selectivity. We hope such a choice can be done automatically in
the future.
My (untested) 2 cents,
p.b.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open