Hi there
I've been redeveloping our school website as a "front-end," pulling Atom feeds from a variety of sources and transforming them via XSLT to keep the site looking consistent. Most of my XSLT has been learnt "on-the-fly" by examples on the web, and it's all going fine ...
... except for the Atom feed from Google Calendar. I've embedded the calendar in one of the pages using their IFRAME code, which works (tho' I don't really
like IFRAMEs ... but I digress). On the front page, however, I grab a feed of the next three weeks' events, and use XSLT to produce the HTML. This is working -- however, I'd like to group events on the same day into a bulleted list, and this is where I'm having difficulty. I can grab each <event> and thus find the <title> and <gd:when> ... but how then do I group each event with a corresponding "when" entry?
Here is the code I'm using at the moment -- any comments/suggestions would be much appreciated.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gd="http://schemas.google.com/g/2005"
>
<!--<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>-->
<xsl:output method="html" />
<xsl:template match="/atom:feed">
<xsl:apply-templates select="atom:entry" />
</xsl:template>
<xsl:template match="atom:entry" name="feed">
<xsl:variable name="myYear">
<xsl:value-of select="substring(gd:when/@startTime,1,4)" />
</xsl:variable>
<xsl:variable name="myMonth">
<xsl:value-of select="substring(gd:when/@startTime, 6,2)" />
</xsl:variable>
<xsl:variable name="myDay">
<xsl:value-of select="substring(gd:when/@startTime, 9,2)" />
</xsl:variable>
<h2><xsl:value-of select="$myDay" />/<xsl:value-of select="$myMonth" />/<xsl:value-of select="$myYear" /></h2>
<ul>
<li><a href="{atom:link[@rel='alternate']/@href}"><xsl:value-of select="atom:title" /></a></li>
</ul>
</xsl:template>
</xsl:stylesheet>
Message was edited by: dave.hartley