Skip to content

Instantly share code, notes, and snippets.

@alpacaaa
Created October 18, 2012 18:32
Show Gist options
  • Save alpacaaa/3913973 to your computer and use it in GitHub Desktop.
Save alpacaaa/3913973 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<data>
<params>
<root>http://www.example.com</root>
<view />
</params>
<projectpreviews>
<section id="1" handle="projects">Projects</section>
<entry id="2">
<project-name handle="sample-project-2">Sample Project 2</project-name>
<project-description mode="formatted"><p>desc 2</p></project-description>
<project-preview mode="formatted"><p>d2</p></project-preview>
<project-button-text handle="example-link">Example Link</project-button-text>
<project-button-URL handle="http-example">http://example.com/</project-button-URL>
<project-button-icon handle="icon-example">icon-example</project-button-icon>
</entry>
<entry id="1">
<project-name handle="sample-project">Sample Project</project-name>
<project-description mode="formatted"><p>desc 1</p></project-description>
<project-preview mode="formatted"><p>d1</p></project-preview>
</entry>
<entry id="3">
<project-name handle="sample-project">Sample Project 3333</project-name>
<project-description mode="formatted"><p>desc 1</p></project-description>
<project-preview mode="formatted"><p>d1</p></project-preview>
</entry>
</projectpreviews>
</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:apply-templates select="data/projectpreviews/entry[position() mod 2 != 0 and position() != last()]" mode="two-cols" />
<xsl:apply-templates select="data/projectpreviews/entry[position() = last() and not(position() mod 2 = 0)]" mode="single-col" />
</xsl:template>
<xsl:template match="entry" mode="two-cols">
<div class="row">
<xsl:apply-templates select=". | following-sibling::entry[1]" mode="column" />
</div>
</xsl:template>
<xsl:template match="entry" mode="single-col">
<div class="full-span-row">
<xsl:apply-templates select="." mode="project" />
</div>
</xsl:template>
<xsl:template match="entry" mode="column">
<div class="col">
<xsl:apply-templates select="." mode="project" />
</div>
</xsl:template>
<xsl:template match="entry" mode="project">
<h3><xsl:value-of select="project-name" /></h3>
<xsl:if test="project-button-text">
<p>Buttons for free</p>
<a class="btn pull-right" href="{project-button-URL}">
<xsl:value-of select="project-button-text" />
</a>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment