web analytics

How-to break a for-each loop in XSLT?

Options

codeling 1602 - 6666
@2016-11-06 20:11:35

XSLT is written in a very functional style, and in this style there is no equivalent of a break statement. What you can do is something like this:

<xsl:for-each select="...nodes...">

   <xsl:if test="...some condition...">

       ...body of loop...

   </xsl:if>

</xsl:for-each>

That way the for-each will still iterate through all the nodes, but the body of the loop will only be executed if the condition is true.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com