Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Last active August 1, 2017 09:14
Show Gist options
  • Save andrewminton/2e78b533512894e136e84b5e213b735e to your computer and use it in GitHub Desktop.
Save andrewminton/2e78b533512894e136e84b5e213b735e to your computer and use it in GitHub Desktop.
<data>
<angel-for-a-day>
<section id="18" handle="angel-for-a-day">Angel For a Day</section>
<entry id="185">
<anon>Yes</anon>
<title handle="rthhfdghdf">rthhfdghdf</title>
<dates>
<date timeline="1" type="exact">
<start iso="2017-07-06T00:00:00+01:00" timestamp="1499295600" time="00:00" weekday="4" offset="+0100">2017-07-06</start>
</date>
</dates>
</entry>
<entry id="184">
<anon>No</anon>
<title handle="bob">Bob</title>
<dates>
<date timeline="3" type="exact">
<start iso="2017-07-28T00:00:00+01:00" timestamp="1501196400" time="00:00" weekday="5" offset="+0100">2017-07-28</start>
</date>
<date timeline="1" type="range">
<start iso="2017-07-05T00:00:00+01:00" timestamp="1499209200" time="00:00" weekday="3" offset="+0100">2017-07-05</start>
<end iso="2017-07-08T00:00:00+01:00" timestamp="1499468400" time="00:00" weekday="6" offset="+0100">2017-07-08</end>
</date>
<date timeline="2" type="range">
<start iso="2017-07-19T00:00:00+01:00" timestamp="1500418800" time="00:00" weekday="3" offset="+0100">2017-07-19</start>
<end iso="2017-07-20T00:00:00+01:00" timestamp="1500505200" time="00:00" weekday="4" offset="+0100">2017-07-20</end>
</date>
</dates>
</entry>
</angel-for-a-day>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="http://www.getsymphony.com/download/xslt-utilities/source-code/64195/"/>
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
[
<xsl:for-each select="//data/angel-for-a-day/entry">
<xsl:for-each select="dates/date">
{<xsl:choose>
<xsl:when test="ancestor::entry/anon='No'">title:<xsl:value-of select="ancestor::entry/title"/></xsl:when>
<xsl:otherwise>title: anon</xsl:otherwise>
</xsl:choose>,
start:<xsl:value-of select="start"/>,
<xsl:if test="@type='range'">
end:<xsl:value-of select="end"/></xsl:if>},</xsl:for-each></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