public
anonymous / master.xml
Created

  • Download Gist
master.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12
<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>
master.xsl
XSLT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
<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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.