Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<data>
<remote>
<data>
<preferences>
<sitename>Client - Portfolio</sitename>
<languages>
<entry id="1" handle="english" lang="en">English</entry>
<entry id="2" handle="francais" lang="fr">Francais</entry>
</languages>
<stylesheets><entry id="1"><url link="http://link-to-main.stylesheet.css"/></entry></stylesheets>
<scripts><entry id="1"><url link="http://link-to-main.stylesheet.css"/></entry></scripts>
<navlinks>
<entry>
<title lang="en" url="http://domain.co.uk/en/home">Home</title>
<title lang="fr" url="http://domain.co.uk/fr/home">Home</title>
</entry>
<entry>
<title lang="en" url="http://domain.co.uk/en/projects">Projects</title>
<title lang="fr" url="http://domain.co.uk/fr/projet">Projet</title>
</entry>
<entry>
<title lang="en" url="http://domain.co.uk/en/contact">Contact</title>
<title lang="fr" url="http://domain.co.uk/fr/contacte">Contacte</title>
</entry>
<entry>
<title lang="en" url="http://domain.co.uk/en/about">About</title>
<title lang="fr" url="http://domain.co.uk/fr/about">Vous</title>
</entry>
<entry>
<title lang="en" url="http://domain.co.uk/en/portfolio">Portfolio</title>
<title lang="fr" url="http://domain.co.uk/fr/portfolio">Folio</title>
</entry>
</navlinks>
<categories>
<entry id="9">
<cat lang="en" handle="construction">Commodity</cat>
<cat lang="fr" handle="construcion">Commodity</cat>
</entry>
<entry id="10">
<cat lang="en" handle="client">Client</cat>
<cat lang="fr" handle="cliente">Cliente</cat>
</entry>
<entry id="11">
<cat lang="en" handle="country">Country</cat>
<cat lang="fr" handle="country">Country</cat>
</entry>
<entry id="8">
<cat lang="en" handle="mandate">Mandate</cat>
<cat lang="fr" handle="mandate">Mandate</cat>
</entry>
</categories>
</preferences>
<projects>
<entry id="2" sort-order="0">
<title lang="en" handle="project-title">Project title</title>
<title lang="fr" handle="titre-du-projet">Titre du projet</title>
<description lang="en"><p>some HTML encoded with escaped entities</p></description>
<description lang="fr"><p>some HTML encoded with escaped entities Francais</p></description>
<video lang="en" id="90" url="http://player.vimeo.com/video/47100629?title=0&amp;byline=0&amp;color=c8dd63"/>
<images>
<item lang="en" featured='yes' id="78" url="http://linkto-image-url.jpg"/>
<item lang="en" id="56" url="http://linkto-image-url.jpg"/>
<item lang="fr" id="78" url="http://linkto-image-url.jpg"/>
</images>
<categories>
<cat lang="en">9,10,11</cat>
<cat lang="fr">10,6</cat>
</categories>
<published order="20120812">12-08-2012</published>
</entry>
<entry id="1" sort-order="1">
<title lang="en">Project title</title>
<title lang="fr">Titre du projet</title>
<description lang="en"><p>some HTML encoded with escaped entities</p></description>
<description lang="fr"><p>some HTML encoded with escaped entities Francais</p></description>
<video lang="en" id="90" url="http://player.vimeo.com/video/47100629?title=0&amp;byline=0&amp;color=c8dd63"/>
<images>
<item lang="en" featured='yes' id="78" url="http://linkto-image-url.jpg"/>
<item lang="en" id="56" url="http://linkto-image-url.jpg"/>
<item lang="fr" id="78" url="http://linkto-image-url.jpg"/>
</images>
<categories>
<cat lang="en">11,8</cat>
<cat lang="fr">10,9</cat>
</categories>
<published order="20120813">13-08-2012</published>
</entry>
</projects>
</data>
</remote>
</data>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:string="http://symphony-cms.com/functions"
xmlns:_string="http://symphony-cms.com/functions"
xmlns:func="http://exslt.org/functions" extension-element-prefixes="func exsl _string string xsl" exlude-element-prefixes="func exsl _string string xsl"
xmlns:exsl="http://exslt.org/common">
<xsl:import href="https://raw.github.com/gist/1415416/9d59f8ec14e6da049ac1683d5b76d2dbe184b057/String-Utilities.xsl"/>
<xsl:output method="html" omit-xml-declaration="yes" indent="yes" />
<xsl:variable name="vDoc" select="/"/>
<xsl:variable name="url-cat" select="'construction'"/>
<xsl:variable name="url-language" select="'en'"/>
<xsl:variable name="root" select="'http://localhost:8080'"/>
<xsl:variable name="current-page" select="'portfolio'"/>
<xsl:variable name="title" select="''"/>
<xsl:variable name="category">
<xsl:value-of select="//data/remote/data/preferences/categories/entry/cat[@lang = $url-language and @handle = $url-cat]/../@id"/>
</xsl:variable>
<xsl:variable name="projectID">
<xsl:value-of select="//data/remote/data/projects/entry/title[@handle = //data/params/title]/../@id"/>
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet"><xsl:attribute name="url"><xsl:value-of select="//data/remote/data/preferences/stylesheets/entry/url/@link"/></xsl:attribute></link>
</head>
<body>
<header>
<nav>
<ul>
<xsl:apply-templates select="data/remote/data/preferences/navlinks/entry">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</ul>
</nav>
</header>
<section id="main">
<xsl:apply-templates select="data/remote/data"/>
</section>
</body>
</html>
</xsl:template>
<xsl:template match="data/remote/data">
<hgroup>
<h1>
<xsl:value-of select="preferences/sitename" /> - <xsl:value-of select="$category"/>
</h1>
</hgroup>
<ul id="lang-select">
<xsl:apply-templates select="preferences/languages/entry"/>
</ul>
<aside>
<ul id="categories">
<xsl:apply-templates select="preferences/categories/entry"/>
</ul>
</aside>
<section id="content">
<xsl:choose>
<xsl:when test="$title !=''">
<xsl:apply-templates select="projects/entry[@id = $projectID]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="projects/entry">
<xsl:sort select="published/@order" data-type="number" order="ascending"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</section>
</xsl:template>
<xsl:template match="preferences/languages/entry">
<li><a><xsl:attribute name="href"><xsl:value-of select="concat($root,'/',./@lang,'/',$current-page)"/></xsl:attribute><xsl:value-of select="."/></a></li>
</xsl:template>
<xsl:template match="preferences/categories/entry">
<li><a><xsl:attribute name="href">?cat=<xsl:value-of select="cat[@lang = $url-language]/@handle"/></xsl:attribute><xsl:value-of select="cat[@lang = $url-language]/."/></a></li>
</xsl:template>
<xsl:template match="data/remote/data/preferences/categories/entry" mode="proj">
<li><xsl:value-of select="cat[@lang = $url-language]/."/></li>
</xsl:template>
<xsl:template match="projects/entry">
<article><xsl:attribute name="id"><xsl:value-of select="position()"/></xsl:attribute>
<hgroup>
<h1><xsl:value-of select="title[@lang = $url-language]/."/></h1>
<h2>ID: <xsl:value-of select="@id"/></h2>
<h3><xsl:apply-templates select="categories" mode="id"/></h3>
</hgroup>
<xsl:apply-templates select="video"/>
<xsl:copy-of select="description[@lang = $url-language]/*" />
<footer>
<ul id="proj-cat">
<xsl:apply-templates select="categories" mode="in"/>
</ul>
</footer>
</article>
</xsl:template>
<xsl:template match="video">
<iframe>
<xsl:attribute name="src"><xsl:value-of select="@url"/></xsl:attribute>
<xsl:attribute name="width">512</xsl:attribute>
<xsl:attribute name="height">288</xsl:attribute>
</iframe>
</xsl:template>
<xsl:template match="categories" mode="in">
<xsl:variable name="category" select="cat[@lang = $url-language]/."/>
<xsl:variable name="catlist" select="string:split($category,',')"/>
<xsl:variable name="catID" select="exsl:node-set($catlist)/nodeset/node"/>
<xsl:for-each select="//data/remote/data/preferences/categories/entry">
<xsl:if test="@id = $catID">
<li><xsl:value-of select="cat[@lang=$url-language]/."/></li>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="categories" mode="id">
<xsl:variable name="category" select="cat[@lang = $url-language]/."/>
<!--<xsl:variable name="catlist" select="string:split($category,',')"/>
<xsl:variable name="catID" select="exsl:node-set($catlist)/nodeset/node"/>-->
<xsl:value-of select="$category"/>
</xsl:template>
<xsl:template match="data/remote/data/preferences/navlinks/entry">
<li><a><xsl:attribute name="href"><xsl:value-of select="title[@lang = $url-language]/@url"/></xsl:attribute><xsl:value-of select="title[@lang = $url-language]/."/></a></li>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.