xsl-list
[Top] [All Lists]

Re: Splitting data into smaller groups for HTML output.

2005-10-31 13:44:31
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.

--~------------------------------------------------------------------
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>