You can use xdmp:set to set a variable to a certain value if you
achieve/find what you're looking for before you finish processing all
items, then 'skip' the rest of the items:

let $done := 0 
for $i in $items
return if $done = 1 then () (: do nothing for all the rest of your
$items
else (: do your processing on this item :)
        return if ($found-what-you-were-looking-for) then
xdmp:set($done, 1) else ()

But Ken's way is better (as usual), whenever possible.

~Shane

M. Shane Strawn
Software Engineer
Wolters Kluwer Health
Professional and Education Division
[email protected]


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of G. Ken
Holman
Sent: Tuesday, March 30, 2010 10:24 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Break statement in FLWOR

At 2010-03-30 18:57 +0530, you wrote:
>How to break/exit a FLWOR statement  in Marklogic?

There is no such "break" construct in XQuery.  You have two choices to
reduce the number of tuples that are acted on in the "return" clause:

  (1) - use a predicate when selecting the values creating tuples

  (2) - use a "where" clause to toss out created tuples that you don't
want

Rather than break out of the processing of everything, you need to limit
the processing to only those values you want processed.  Because
*everything* you select gets processed.

I hope this helps.

. . . . . . . . Ken

--
XSLT/XQuery training:         San Carlos, California 2010-04-26/30
Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03
XSLT/XQuery training:                 Ottawa, Canada 2010-05-10/14
XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11
Vote for your XML training:   http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to