Created
December 17, 2013 02:26
-
-
Save neilang/7998970 to your computer and use it in GitHub Desktop.
This file contains 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:exslt="http://exslt.org/common" | |
xmlns:date="http://exslt.org/dates-and-times"> | |
<xsl:output method="html" encoding="utf-8" indent="no" media-type="text/html" /> | |
<xsl:template match="/"> | |
<ul> | |
<xsl:apply-templates select="//api-v1-entities-event-item" /> | |
</ul> | |
</xsl:template> | |
<xsl:template match="api-v1-entities-event-item"> | |
<li> | |
<xsl:element name="a"> | |
<xsl:attribute name="href"> | |
<xsl:value-of select="link" /> | |
</xsl:attribute> | |
<xsl:value-of select="title" /> | |
</xsl:element> | |
<xsl:text> - </xsl:text> | |
<xsl:apply-templates select="start-time" /> | |
</li> | |
</xsl:template> | |
<xsl:template match="start-time|end-time"> | |
<xsl:param name="date" select="date:date(.)" /> | |
<xsl:param name="time" select="date:time(.)" /> | |
<xsl:element name="time"> | |
<xsl:attribute name="datetime"><xsl:value-of select="." /></xsl:attribute> | |
<xsl:call-template name="FormatTime"> | |
<xsl:with-param name="hour" select="date:hour-in-day($time)" /> | |
<xsl:with-param name="minute" select="date:minute-in-hour($time)" /> | |
</xsl:call-template> | |
<xsl:text>, </xsl:text> | |
<xsl:value-of select="date:day-of-week-in-month($date)" /> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="date:month-name($date)" /> | |
<xsl:text> </xsl:text> | |
<xsl:value-of select="date:year($date)" /> | |
</xsl:element> | |
</xsl:template> | |
<xsl:template name="FormatTime"> | |
<xsl:param name="hour">0</xsl:param> | |
<xsl:param name="minute">0</xsl:param> | |
<xsl:variable name="paddedMinute"> | |
<xsl:if test="string-length($minute) = 1"> | |
<xsl:text>0</xsl:text> | |
</xsl:if> | |
<xsl:value-of select="$minute" /> | |
</xsl:variable> | |
<xsl:value-of select="$hour" />:<xsl:value-of select="$paddedMinute" /> | |
</xsl:template> | |
</xsl:stylesheet> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment