[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] break or exit in xsl?


Subject: Re: [xsl] break or exit in xsl?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 7 Mar 2005 11:08:28 GMT

   Hi!

   I need to exit my xsl:for-each tag when I'm reaching a value. Example:

   <xsl:for-each select="Person/Age">
       <xsl:if test=".='30'>
	  ...
	  <!-- Here I need to exit xsl:for-each -->
       </xsl:if>
   </xsl:for-each>
   ...

    In Java or C++ there exists a break or exit keyword to do this. How can 
   I do this with xsl?

   Katharina


You can't. In Java or C the looping expressions that you are refering to
imply a sequential order of execution, so it makes sense to "stop" and
the languages offer that feature.  In XSLT there is no such implied
ordering, the processor may execute the branches in any order, and in
particular it may exectute them in parallel on a suitable machine
architecture.

If you just want to process every person before the first person who is
30, just select those people, don't select everyone then try to escape
later.

 <xsl:for-each select="Person[Age=30][1]/preceding-sibling::Person">

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
________________________________________________________________________


Current Thread
Keywords