xsl-list
[Top] [All Lists]

Re: Break the For-each loop

2005-09-09 02:51:13

So how do I break the loop after I have
found the first apple?

You never break out of a for loop in xslt. It is best to assume that you
are using a massively parallel machine and all items in the loop are
executed _in parallel_ and assembled into the final output in a
specified order which might be totally unrelated to the order in which
they are evaluated. (Even if in fact you are on a sequential machine an
XSLT compiler may (and some do) execute the items in orders which don't
correspond to the natural order that you might expect.

So don't break the loop: just select the items that you want to process,
for example if you want to process all the children up to and including
the first apple do

<xsl:for-each select="apple[1]/preceding-sibling::*|apple[1]">

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>