Created
July 17, 2012 16:46
-
-
Save anonymous/3130526 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<products> | |
<section id="1" handle="products">Products</section> | |
<entry id="1"> | |
<name handle="batman-bar">Batman Bar</name> | |
</entry> | |
<entry id="13"> | |
<name handle="birthday-party-ice-cream-sandwich">Birthday Party Ice Cream Sandwich</name> | |
</entry> | |
<entry id="15"> | |
<name handle="bubblegum-bar">Bubblegum Bar</name> | |
</entry> | |
<entry id="8"> | |
<name handle="bubblegum-snow-cone">Bubblegum Snow Cone</name> | |
</entry> | |
<entry id="17"> | |
<name handle="champ-king-size-bunny-tracks-cone">Champ! King Size Bunny Tracks Cone</name> | |
</entry> | |
<entry id="31"> | |
<name handle="chill-double-lemon-cup">Chill Double Lemon Cup</name> | |
</entry> | |
<entry id="19"> | |
<name handle="chips-galore">Chips Galore!</name> | |
</entry> | |
<entry id="11"> | |
<name handle="chips-galore">Chocolate Lover's Big Dipper</name> | |
</entry> | |
<entry id="19"> | |
<name handle="chips-galore">Chips Galore! 22222</name> | |
</entry> | |
<entry id="11"> | |
<name handle="chips-galore">Chocolate Lover's Big Dipper 3333333</name> | |
</entry> | |
<entry id="11"> | |
<name handle="chips-galore">Chocolate Lover's Big Dipper 44444444</name> | |
</entry> | |
</products> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" indent="yes" /> | |
<xsl:template match="/"> | |
<ul> | |
<xsl:apply-templates select="products/entry[1]" mode="li"> | |
<xsl:with-param name="items-per-row" select="3" /> | |
<xsl:with-param name="rows-per-li" select="2" /> | |
</xsl:apply-templates> | |
</ul> | |
</xsl:template> | |
<xsl:template match="entry" mode="li"> | |
<xsl:param name="items-per-row" /> | |
<xsl:param name="rows-per-li" /> | |
<li> | |
<xsl:apply-templates select="." mode="row"> | |
<xsl:with-param name="rows-per-li" select="$rows-per-li" /> | |
<xsl:with-param name="items-per-row" select="$items-per-row" /> | |
<xsl:with-param name="current" select="1" /> | |
</xsl:apply-templates> | |
</li> | |
<xsl:apply-templates select="following-sibling::entry[position() = ($items-per-row * $rows-per-li)]" mode="li"> | |
<xsl:with-param name="rows-per-li" select="$rows-per-li" /> | |
<xsl:with-param name="items-per-row" select="$items-per-row" /> | |
</xsl:apply-templates> | |
</xsl:template> | |
<xsl:template match="entry" mode="row"> | |
<xsl:param name="items-per-row" /> | |
<xsl:param name="rows-per-li" /> | |
<xsl:param name="current" /> | |
<div class="row"> | |
<xsl:apply-templates select="."> | |
<xsl:with-param name="items-per-row" select="$items-per-row" /> | |
<xsl:with-param name="current" select="1" /> | |
</xsl:apply-templates> | |
</div> | |
<xsl:if test="$current +1 <= $rows-per-li"> | |
<xsl:apply-templates select="following-sibling::entry[position() = $items-per-row]" mode="row"> | |
<xsl:with-param name="items-per-row" select="$items-per-row" /> | |
<xsl:with-param name="rows-per-li" select="$rows-per-li" /> | |
<xsl:with-param name="current" select="$current +1" /> | |
</xsl:apply-templates> | |
</xsl:if> | |
</xsl:template> | |
<xsl:template match="entry"> | |
<xsl:param name="items-per-row" /> | |
<xsl:param name="current" /> | |
<div> | |
<xsl:value-of select="name" /> | |
</div> | |
<xsl:if test="$current +1 <= $items-per-row"> | |
<xsl:apply-templates select="following-sibling::entry[1]"> | |
<xsl:with-param name="items-per-row" select="$items-per-row" /> | |
<xsl:with-param name="current" select="$current +1" /> | |
</xsl:apply-templates> | |
</xsl:if> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment