Skip to content

Instantly share code, notes, and snippets.

Created February 22, 2012 01:14
Show Gist options
  • Save anonymous/1880386 to your computer and use it in GitHub Desktop.
Save anonymous/1880386 to your computer and use it in GitHub Desktop.
<data>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
<entry>Text</entry>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:for-each select="data/entry">
<div>
<xsl:if test="position() mod 4 = 0">
<xsl:attribute name="class">last</xsl:attribute>
</xsl:if>
<xsl:if test="position() = 1 or (position() - 5) mod 4 = 0">
<xsl:attribute name="class">first</xsl:attribute>
</xsl:if>
<xsl:call-template name="content"/>
</div>
</xsl:for-each>
</xsl:template>
<xsl:template name="content">
<p><xsl:value-of select="." /></p>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment