You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Dang Minh Phuong <mp...@ncs.com.sg> on 2003/10/21 10:18:06 UTC

stop a for-each looping ???

Hi all,

I use for-each to loop through all nodes and test the value. If the
condition is true, I'd like to stop the loop. How can I do that. Could you
help me to suggest ideas??? Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: stop a for-each looping ???

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Dang Minh Phuong wrote:
> I use for-each to loop through all nodes and test the value. If the
> condition is true, I'd like to stop the loop.

A xsl:for-each is *not* a loop in the sense this stuff is handled in
JavaScript or other procedural languages. It is best thought as executing
the body in parallel for each of the selected nodes, therefore, there is
no way the processing of one node of the selected node set can influence
the processing of another node.

You have to select the right nodes from the beginning, like
  <xsl:for-each select="some-node[position()<5]">
or, more probably, you have a grouping problem. Look into the XSLT
FAQ reachable from
  http://www.mulberrytech.com/xsl/xsl-list/
or ask on the XSL list (state your *original* problem, not the "break
out of a loop" stuff, it's a VFAQ and people may be tired of it).

J.Pietschmann



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: stop a for-each looping ???

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Glen Mazza [mailto:grm7793@yahoo.com]
>
> Let's be careful to move XSLT questions to the
> Mulberry list and archives--we have a link to it on
> the Resources page, also a Google search will find it.
>

Yer right, laddy :)
That's why I decided to keep it concise for the list (perhaps I shouldn't
have answered on the list at all, I admit) and later added a more detailed
answer directly to the poster in which I explicitly mentioned it being
somewhat off-topic.

I'll try to refrain myself in the future ;)

Sorry.

Greetz,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: stop a for-each looping ???

Posted by Glen Mazza <gr...@yahoo.com>.
Let's be careful to move XSLT questions to the
Mulberry list and archives--we have a link to it on
the Resources page, also a Google search will find it.

This ML will become overwhelmed--like Mulberry!--
should we start answering XSLT questions here.

Glen


--- "Andreas L. Delmelle" <a_...@pandora.be>
wrote:
> > -----Original Message-----
> > From: Dang Minh Phuong [mailto:mpdang@ncs.com.sg]
> >
> > I use for-each to loop through all nodes and test
> the value. If the
> > condition is true, I'd like to stop the loop. How
> can I do that. Could you
> > help me to suggest ideas??? Thanks
> >
> 
> A break-statement like in Java? I think not. An
> <xsl:for-each> is
> unconditionally completed for all nodes in the
> source document that match
> the given expression...
> 
> What you *can* do is use <xsl:if> or <xsl:choose>
> inside the <xsl:for-each>
> to put a filter on the nodes to be processed... (
> only process the nodes
> that satisfy a certain condition ).
> 
> 
> Greetz,
> 
> Andreas
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> fop-user-help@xml.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: stop a for-each looping ???

Posted by "Andreas L. Delmelle" <a_...@pandora.be>.
> -----Original Message-----
> From: Dang Minh Phuong [mailto:mpdang@ncs.com.sg]
>
> I use for-each to loop through all nodes and test the value. If the
> condition is true, I'd like to stop the loop. How can I do that. Could you
> help me to suggest ideas??? Thanks
>

A break-statement like in Java? I think not. An <xsl:for-each> is
unconditionally completed for all nodes in the source document that match
the given expression...

What you *can* do is use <xsl:if> or <xsl:choose> inside the <xsl:for-each>
to put a filter on the nodes to be processed... ( only process the nodes
that satisfy a certain condition ).


Greetz,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org