Skip to content

Instantly share code, notes, and snippets.

@creativedutchmen
Forked from anonymous/master.xml
Created February 3, 2013 15:02
Show Gist options
  • Save creativedutchmen/4702108 to your computer and use it in GitHub Desktop.
Save creativedutchmen/4702108 to your computer and use it in GitHub Desktop.
<data>
<products>
<entry id="01">
<title>product 01</title>
</entry>
<entry id="02">
<title>product 02</title>
</entry>
<entry id="03">
<title>product 03</title>
</entry>
<entry id="04">
<title>product 04</title>
</entry>
<entry id="05">
<title>product 05</title>
</entry>
<entry id="06">
<title>product 06</title>
</entry>
<entry id="07">
<title>product 07</title>
</entry>
<entry id="08">
<title>product 08</title>
</entry>
<entry id="09">
<title>product 09</title>
</entry>
<entry id="10">
<title>product 10</title>
</entry>
<entry id="11">
<title>product 11</title>
</entry>
<entry id="12">
<title>product 12</title>
</entry>
</products>
</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:apply-templates select="data/products"/>
</xsl:template>
<xsl:template match="products">
<xsl:apply-templates select="entry[position() mod 3 = 1]" mode="row"/>
</xsl:template>
<xsl:template match="products/entry" mode="row">
<div class="row">
<xsl:apply-templates select=". | following-sibling::entry[position() &lt; 3]" mode="entry"/>
</div>
</xsl:template>
<xsl:template match="products/entry" mode="entry">
<div class="product">
<xsl:value-of select="title"/>
</div>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment