xsl-list
[Top] [All Lists]

RE: Break the For-each loop

2005-09-09 04:21:53
xsl:for-each is a mapping, not a loop: it maps an input sequence to a result
sequence. It doesn't process the input elements in any particular order,
therefore the concept of "breaking out" doesn't make sense.

If you only want to process the elements up to the first apple, you first
need to select those elements. For example:

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

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

-----Original Message-----
From: Khorasani, Houman [mailto:houman_khorasani(_at_)csgsystems(_dot_)com] 
Sent: 09 September 2005 10:36
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Break the For-each loop

Hello,

I would like to look after a specific XML tag (e.g. apple), which can
occur several times.  I was thinking using a for-each loop and output
the first found apple. But I would get in this case all the apples
because of the for-each loop. So how do I break the loop after I have
found the first apple?

Thanks
Houman

--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>