You need to write a predicate that describes which nodes are to be processed. For example, to process the first three children:
<xsl:for-each select="*[position() < 4]">
to process all nodes provided they are followed by a BANANA node:
<xsl:for-each select="*[following-sibling::b[c='BANANA']]">
Sometimes it's not possible to do in that way, in which case you have to traverse the children using sibling recursion. (apply-templates to the first child, which it turn does apply-templates to the next child, and so, on passing any accumulated information in parameters).
Or in XSLT 2.0 you can use xsl:for-each-group.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference