Re: [xsl] Splitting data into smaller groups for HTML output.

Subject: Re: [xsl] Splitting data into smaller groups for HTML output.
From: Mike Rumble <mike.rumble@xxxxxxxxx>
Date: Mon, 31 Oct 2005 20:44:31 +0000
After a bit of playing around with the code, I've used your code to
come up with this...

<xsl:template match="sources">
	<xsl:variable name="all-items" select="source"/>
	<xsl:variable name="num-groups" select="floor(((count($all-items)-1)
div 5)+ 1)"/>
	<xsl:for-each select="$all-items[position() &lt;= $num-groups]">
		<xsl:variable name="p" select="position()"/>
 		<ul>
    		<xsl:variable name="items" select="$all-items[position() &gt;=
($p - 1)*5 + 1 and position() &lt;= $p*5]"/>
    		<xsl:for-each select="$items">
    			<xsl:variable name="j" select="position()"/>
	    		<li><a href=""><xsl:attribute name="href"><xsl:value-of
select="$items[$j]/url" /></xsl:attribute><xsl:value-of
select="$items[$j]/title"/></a></li>
	    	</xsl:for-each>
 		</ul>
	</xsl:for-each>
</xsl:template>

It works perfectly, giving the intended output just as I intended, so
thanks for your help and code.

Cheers,
Mike.

Current Thread