Skip to content

Instantly share code, notes, and snippets.

@nickdunn
Created April 16, 2009 08:01
Show Gist options
  • Save nickdunn/96305 to your computer and use it in GitHub Desktop.
Save nickdunn/96305 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://exslt.org/math" extension-element-prefixes="math">
<xsl:template match="data">
<xsl:call-template name="tag-cloud">
<xsl:with-param name="range" select="'5'"/>
<xsl:with-param name="tags" select="section-schema[@handle='articles']/*[name()='tags']//option"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="tag-cloud">
<xsl:param name="range" select="'1'"/>
<xsl:param name="tags"/>
<xsl:variable name="constant" select="(math:max($tags/@count) div $range)" />
<ul>
<xsl:for-each select="$tags">
<li class="size-{ceiling(@count div $constant)}">
<a href="/tags/{@handle}/">
<xsl:value-of select="." />
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment