Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Created March 13, 2012 23:11
Show Gist options
  • Save andrewminton/2032510 to your computer and use it in GitHub Desktop.
Save andrewminton/2032510 to your computer and use it in GitHub Desktop.
<data>
<workthumbimages>
<section id="6" handle="work-images">work images</section>
<entry id="126">
<description>cartier-bresson</description>
<image size="114 KB" path="/images" type="image/jpeg">
<filename>hcb2.jpg</filename>
<meta creation="2012-03-13T14:37:02+00:00" width="715" height="440" />
</image>
<project>
<item id="8" handle="the-first-project" section-handle="work" section-name="work">the first project</item>
</project>
</entry>
<entry id="29">
<description>Sparrow Mail for iPhone</description>
<image size="unknown" path="/images" type="image/png">
<filename>sparra.png</filename>
<meta creation="2012-02-18T18:44:29+00:00" width="150" height="150" />
</image>
<project>
<item id="27" handle="will-it-grid" section-handle="work" section-name="work">will it grid?</item>
</project>
</entry>
<entry id="14">
<description>Reeder app</description>
<image size="unknown" path="/images" type="image/png">
<filename>reeder.png</filename>
<meta creation="2012-02-18T18:57:01+00:00" width="150" height="150" />
</image>
<project>
<item id="13" handle="second-project" section-handle="work" section-name="work">second project</item>
</project>
</entry>
<entry id="12">
<description>pixels</description>
<image size="27 KB" path="/images" type="image/png">
<filename>flight.png</filename>
<meta creation="2012-03-13T14:33:04+00:00" width="150" height="150" />
</image>
<project>
<item id="8" handle="the-first-project" section-handle="work" section-name="work">the first project</item>
</project>
</entry>
<entry id="11">
<description>this is the first thumbnail</description>
<image size="unknown" path="/images" type="image/png">
<filename>welcome.png</filename>
<meta creation="2012-02-18T18:42:12+00:00" width="150" height="150" />
</image>
<project>
<item id="8" handle="the-first-project" section-handle="work" section-name="work">the first project</item>
</project>
</entry>
</workthumbimages>
</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:for-each select="data/workthumbimages/entry">
<div>
<xsl:choose>
<xsl:when test="position() mod 2 = 1">
<xsl:attribute name="class"><xsl:text>span-4 first grid-image</xsl:text></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class"><xsl:text>span-4 last grid-image</xsl:text></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<!-- {$root} omitted for testing -->
<img src="/image/2/150/150/1/images/{image/filename}" alt="" />
<a href="project/{project/item/@handle}">
<div class="thumbteaser">
<xsl:copy-of select="description/node()"/>
</div>
</a>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment