Re: [xsl] how to limit number of items shown

Subject: Re: [xsl] how to limit number of items shown
From: Dmitri Snytkine <d.snytkine@xxxxxxxxx>
Date: Sun, 31 May 2009 09:45:10 -0400
Thanks I'll try that.
I was going to try the for-each loop looping over all items
and then inside the loop have the <xsl:if test="(position() &lt < 11)">

But I just was not sure if that is the best way to implement the limit of
items.

> From the point of view of XSLT, xsl:for-each loop is real :)

Yes, the for-each is real foreach loop, I mean the XSL does not have a
real 'for' loop like this:

 for(i = 0; i<=10; i++){

}

And, as I mentioned before, I need this to be done with XSL 1.0




On Sun, May 31, 2009 at 1:04 AM, Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote:
> On Sun, May 31, 2009 at 6:31 AM, Dmitri Snytkine <d.snytkine@xxxxxxxxx>
wrote:
>> What I need is a way to make sure I show no more than 10 items, even
>> if XML has 25 items.
>
> I think, you can do:
>
> <xsl:for-each select="item[position() &lt; 11]">
>  ..
> </xsl:for-each>
>
> you only iterate the items you are interested in.
>
>> I know XSL 1 does not have a real "for loop", only foreach
>
> From the point of view of XSLT, xsl:for-each loop is real :)
>
> btw, with XSLT 2.0 one can do (not possible in 1.0):
>
> <xsl:for-each select="1 to 10">
>   ..
> </xsl:for-each>
>
>
> --
> Regards,
> Mukul Gandhi

Current Thread