Last change 25/04/2014

Take a xml with loads items, and you want to display it - 4 in a row - in a table. This neat snippet does exactly that.
This template takes the problem of having 4 cells in a row even one step further. Beause it makes sure that each cell can contain loads of logic if needed and still keep it simple:...
    <xsl:apply-templates select="/root/folder" mode="RowOf4"/>

<xsl:template match="*" mode="RowOf4">
    <xsl:if test="count(preceding-sibling::*[name() = 'folder']) mod 4 = 0">
            <td width="25%">
                <xsl:apply-templates select="."/><span/>
            <td width="25%">
                <xsl:apply-templates select="following-sibling::*[(position()=1) and (name() = 'folder') ]"/><span/>
            <td width="25%">
                <xsl:apply-templates select="following-sibling::*[(position()=2) and (name() = 'folder')]"/><span/>
            <td width="25%">
                <xsl:apply-templates select="following-sibling::*[(position()=3) and (name() = 'folder')]"/><span/>

Site created with Corinis CCM