Skip to content

Instantly share code, notes, and snippets.

@nickdunn
Created April 29, 2010 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickdunn/384074 to your computer and use it in GitHub Desktop.
Save nickdunn/384074 to your computer and use it in GitHub Desktop.
<xsl:template match="data">
<xsl:variable name="number-of-entries" select="count(my-datasource/entry)"/>
<xsl:variable name="per-column" select="ceiling($number-of-entries div 3)"/>
<xsl:for-each select="my-datasource/entry[position() mod ($per-column - 1)]">
<xsl:variable name="position" select="position()"/>
<xsl:variable name="start" select="($per-column * $position) - ($per-column - 1)"/>
<xsl:variable name="end" select="($per-column * $position)"/>
<xsl:variable name="entries" select="/data/my-datasource/entry[position() &gt;= $start and position() &lt;= $end]"/>
<xsl:if test="$entries">
<ul>
<xsl:apply-templates select="$entries" mode="list-item"/>
</ul>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="entry" mode="list-item">
<li>...</li>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment