Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2012 08:04
Show Gist options
  • Save anonymous/3121455 to your computer and use it in GitHub Desktop.
Save anonymous/3121455 to your computer and use it in GitHub Desktop.
<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>
</products>
<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" />
</ul>
</xsl:template>
<xsl:template match="entry" mode="li">
<li>
<div class="row">
<xsl:apply-templates select=". | following-sibling::entry[1]" />
</div>
<xsl:if test="following-sibling::entry[2]"> <!-- don't display empty rows -->
<div class="row">
<xsl:apply-templates select="following-sibling::entry[2] | following-sibling::entry[3]" />
</div>
</xsl:if>
</li>
<xsl:apply-templates select="following-sibling::entry[4]" mode="li" />
</xsl:template>
<xsl:template match="entry">
<div>
<xsl:value-of select="name" />
</div>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment