Created
February 18, 2013 12:38
-
-
Save anonymous/4977069 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
<data> | |
<products> | |
<entry>one</entry> | |
<entry>two</entry> | |
<entry>three</entry> | |
<entry>four</entry> | |
</products> | |
</data> |
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="/"> | |
<hi> | |
<xsl:value-of select="data/products/entry[position() mod 4 = 1]" mode="group" /> | |
</hi> | |
</xsl:template> | |
<xsl:template match="products/entry" mode="group"> | |
<xsl:variable name="group"> | |
<xsl:call-template name="num-to-word"> | |
<xsl:with-param name="num-to-word" select="position()"/> | |
</xsl:call-template> | |
</xsl:variable> | |
<div class="group {$group}"> | |
<xsl:apply-templates select=". | following-sibling::entry[position() < 4]" mode="navigation"/> | |
</div> | |
</xsl:template> | |
<xsl:template match="products/entry | products/entry" mode="product"> | |
<article class="product"></article> | |
</xsl:template> | |
<xsl:template name="num-to-word"> | |
<xsl:param name="num"/> | |
<xsl:choose> | |
<xsl:when test="$num = 1">one</xsl:when> | |
<xsl:when test="$num = 2">two</xsl:when> | |
<xsl:when test="$num = 3">three</xsl:when> | |
<xsl:when test="$num = 4">four</xsl:when> | |
... | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment