[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl]
Dung, Ming-tzung wrote:
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl]
Subject: Re: [xsl] <xsl:for-each> From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Fri, 19 Apr 2002 22:44:47 +0200 |
Dung, Ming-tzung wrote:
Hi, I wonder whether the XSLT has the instruction like the "break" statement in C/Java language inside the loop. If no such instruction, any design idiom can solve this problem? Thanks in advance!!
You have to get rid of the habit of viewing xsl:for-each as being a loop. It is not a loop. Think of it as a statement which applies a function to each element of a list (or an array), in parallel. Because it's not a loop, you can't break out of it. Instead you have to construct the correct list of nodes you want to apply the for-each body to right at the beginning.
Instead of for( d in data) { if( d.total > max ) { break; } do-stuff; }
you have to select the right node set (which is not trivial in this case): <xsl:for-each select="data[total > $max][1]/preceding-sibling::data"> <stuff/> </xsl:for-each> In most cases, selecting the correct set of nodes is much easier.
HTH J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] <xsl:for-each>, Michael Earls | Thread | [xsl] making html output for applic, Bernie Bernstein |
Re: [xsl] question with xalan, java, J.Pietschmann | Date | [xsl] making html output for applic, Bernie Bernstein |
Month |
Keywords