[xquery-talk] exiting the for

Michael Kay mhk at mhk.me.uk
Wed Mar 1 17:15:57 PST 2006


No, because a "for" is a mapping expression, not a loop. The items in the
input sequence aren't processed in any particular (temporal) order to
generate the items in the output sequence.

You can generally achieve what you want using one of two techniques:

(a) a predicate to select the items in the input sequence you want to
process, which you can write as

    for $x in input[predicate] return xxx

or if you prefer

    for $x in input where predicate return xxx

(b) recursion over the sequence (typically head-tail recursion) using a
user-written function, exiting when you have found the last element you want
to process.

Michael Kay
http://www.saxonica.com/

 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Enric Jaen
> Sent: 01 March 2006 16:26
> To: talk at xquery.com
> Subject: [xquery-talk] exiting the for 
> 
> Hello, is there any way to exit from the for clause  before 
> reaching the end of the binding sequence?
> Regards,
> -Enric
> 
> 
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list