[xquery-talk] Selecting Descendants
Brian Maso
brian at blumenfeld-maso.com
Mon Jun 13 11:38:19 PDT 2005
Using ancestor:: axis (assuming processor supports it) makes it pretty easy:
//B[fn:empty(ancestor::B)]
Without using ancestor axis, I can't think of a way that wouldn't involve
recursive descent:
declare function ns:descend($n as element) as element*
{
(
$n/B,
for $e in $n/*[fn:node-name() != "B"] return ns:descend($e)
)
}
(: assume context node is an element...:)
if(fn:node-name() == "B")
then .
else ns:descend(.)
Brian Maso
At 08:13 AM 6/13/2005, EXTERNAL Kruse Peter (Praktikant; wrote:
>content-class: urn:content-classes:message
>Content-Type: multipart/alternative;
> boundary="=_reb-r4665A816-t42ADA2EA"
>
>Hi folks
>
>I'm seeking a way to select only those descandants in a tree which fit a
>criterion but not their descandants (even if those fit the critirion as well).
>
>I know, you can select with //node-name, but that will give back children
>of node-name with name node-name as well and i don't want them (got it?)
>
>I have a tree like this
>
><A>
> <B name="b1">
> <B name="b2">
> </B>
> </B>
> <B name="b3">
> </B>
> <B name="b4">
> </B>
> <A>
> <B name="b5">
> <B name="b6">
> </B>
> </B>
> </A>
></A>
>
>And i want to select b1, b3, b4, b5 (but not b2 and b6, because their
>parents (or one of there ancestors) is already selected).
>
>Any hints?
>
>Kind Regards
> Peter
>_______________________________________________
>talk at xquery.com
>http://xquery.com/mailman/listinfo/talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20050613/b4130d16/attachment.htm
More information about the talk
mailing list