cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jasha Joachimsthal" <j.joachimst...@hippo.nl>
Subject RE: Urgent :break statement in xsl
Date Wed, 28 Jun 2006 07:59:52 GMT
 

-----Original Message-----
From: deepakkumar.sahoo@tcs.com [mailto:deepakkumar.sahoo@tcs.com]
Sent: woensdag 28 juni 2006 9:31
To: users@cocoon.apache.org
Subject: Urgent :break statement in xsl





Hi All, 

        I am facing a problem in xsl.I am not sure whether it is possible in xsl or not. 


        I have a <xsl:for-each> loop .I have a check condition in it.I want it to do
something for the first time check condition is satisfied.After that it should not do anything.As
i have a check condition in the loop i could not put [position=1] in the <xsl:for-each>
loop.I tried with declaring a variable 
and decreamenting its value if the check condition is satisfied.But it is not happening. 

        Basically i want to break the <xsl:for-each>loop if one condition is satisfied.
 Below is the code. 


<xsl:variable name="daslcatagorypath" select="'/nos'"/> 
 <xsl:for-each select="details/dasl:query-result/dasl:resource"> 
                                                                                
        <xsl:if test="d:resourcetype=''"> 
        <xsl:variable name="daslfolderpath"><xsl:value-of select="@dasl:path"/></xsl:variable>

        <xsl:variable name="check" select="substring-after($daslfolderpath,$daslcatagorypath)"/>

        <xsl:if test="$check!='' and $counter='1'"> 
                <xsl:variable name="size" select="d:getcontentlength"/> 
                <xsl:variable name="kb-size" select="($size div 1000) - ($size mod 1000
div 1000)"/> 
                <xsl:value-of select="$kb-size"/><xsl:text> </xsl:text>KB

                <xsl:variable name="counter" select="'0'"/> 
        </xsl:if> 
        </xsl:if> 
</xsl:for-each> 


Can anyone suggest me the solution for it. 


[Jasha Joachimsthal] 


Hi Deepak,
 
a break in a for-each is not possible, but you could try to write a recursive (call-)template
that stops calling itself when a certain value has been reached.
 

Jasha Joachimsthal 

--------- 

Hippo 
Oosteinde 11 
1017 WT Amsterdam 
The Netherlands 
+31 (0)20 5224466 

jasha@hippo.nl 
www.hippo.nl  


Mime
View raw message