xsl-list
[Top] [All Lists]

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

2009-05-31 12:09:44
On Sun, May 31, 2009 at 7:15 PM, Dmitri Snytkine 
<d(_dot_)snytkine(_at_)gmail(_dot_)com> wrote:
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.

you can do like this. xsl:for-each select="item[position() ...] and
xsl:if as you have mentioned would produce the same result.

I would prefer item[position() ...] as it looks more cleaner, and
perhaps more efficient (am not sure..?)

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++){

}

XSLT doesn't have notion of variables changing the states. So
something like above will not work with XSLT.

you can use patterns like tem[position() ...] or perhaps use recursion
sometimes, to iterate specific number of times.


-- 
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>