Created
August 9, 2012 09:26
-
-
Save andrewminton/3302641 to your computer and use it in GitHub Desktop.
Remote Datasource test
This file contains hidden or 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> | |
<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 url="http://domain.co.uk/home"><title lang="en">Home</title></entry> | |
<entry url="http://domain.co.uk/projects"><title lang="en">Projects</title></entry> | |
<entry url="http://domain.co.uk/contact"><title lang="en">Contact</title></entry> | |
<entry url="http://domain.co.uk/about"><title lang="en">About</title></entry> | |
<entry url="http://domain.co.uk/portfolio"><title lang="en">Portfolio</title></entry> | |
</navlinks> | |
<categories> | |
<entry id="9"> | |
<cat lang="en" handle="construction">Construction</cat> | |
<cat lang="fr" handle="construcion">Construcion</cat> | |
</entry> | |
<entry id="10"> | |
<cat lang="en" handle="forestry">Water Management</cat> | |
<cat lang="fr" handle="gestion-de-leau">Gestion de leau</cat> | |
</entry> | |
<entry id="11"> | |
<cat lang="en" handle="geochemistry">Geochemistry</cat> | |
<cat lang="fr" handle="geochimie">Geochimie</cat> | |
</entry> | |
<entry id="8"> | |
<cat lang="en" handle="geochemistry">Poop</cat> | |
<cat lang="fr" handle="geochimie">poopie</cat> | |
</entry> | |
</categories> | |
</preferences> | |
<projects> | |
<entry id="2" sort-order="0"> | |
<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&byline=0&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&byline=0&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> |
This file contains hidden or 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 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" 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="xml" omit-xml-declaration="yes" indent="yes" /> | |
<xsl:variable name="lang" select="'en'"/> | |
<xsl:variable name="vDoc" select="/"/> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<link rel="stylesheet"><xsl:attribute name="url"><xsl:value-of select="//data/preferences/stylesheets/entry/url/@link"/></xsl:attribute></link> | |
</head> | |
<body> | |
<header> | |
<nav> | |
<ul> | |
<xsl:apply-templates select="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"/> | |
</section> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="data"> | |
<hgroup><h1> | |
<xsl:value-of select="preferences/sitename" /> | |
</h1> | |
</hgroup> | |
<ul id="lang-select"> | |
<xsl:apply-templates select="preferences/languages/entry"/> | |
</ul> | |
<ul id="categories"> | |
<xsl:apply-templates select="preferences/categories/entry"/> | |
</ul> | |
<section id="content"> | |
<xsl:apply-templates select="projects/entry"> | |
<xsl:sort select="published/@order" data-type="number" order="ascending"/> | |
</xsl:apply-templates> | |
</section> | |
</xsl:template> | |
<xsl:template match="preferences/languages/entry"> | |
<li><a><xsl:attribute name="href">?lang=<xsl:value-of select="./@lang"/></xsl:attribute><xsl:value-of select="."/></a></li> | |
</xsl:template> | |
<xsl:template match="preferences/categories/entry"> | |
<li><xsl:value-of select="cat[@lang = $lang]/."/></li> | |
</xsl:template> | |
<xsl:template match="data/preferences/categories/entry" mode="proj"> | |
<li><xsl:value-of select="cat[@lang = $lang]/."/></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 = $lang]/."/></h1> | |
<h2>ID: <xsl:value-of select="@id"/></h2> | |
</hgroup> | |
<xsl:apply-templates select="video"/> | |
<xsl:copy-of select="description[@lang = $lang]/*" /> | |
<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 = $lang]/."/> | |
<xsl:variable name="catlist" select="string:split($category,',')"/> | |
<xsl:variable name="catID" select="exsl:node-set($catlist)/nodeset/node"/> | |
<xsl:for-each select="//data/preferences/categories/entry"> | |
<xsl:if test="@id = $catID"> | |
<li><xsl:value-of select="cat[@lang=$lang]/."/></li> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:template> | |
<xsl:template match="data/preferences/navlinks/entry"> | |
<li><a><xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute><xsl:value-of select="title[@lang = $lang]/."/></a></li> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment