Fixed event atom feed so it validates
[mspang/www.git] / xsl / atom.xsl
1 <?xml version='1.0'?>
2
3 <xsl:stylesheet version="2.0"
4     xmlns="http://www.w3.org/1999/xhtml"
5     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6     xmlns:xs="http://www.w3.org/2001/XMLSchema"
7     xmlns:fn="http://www.w3.org/2005/xpath-functions"
8     xmlns:csc="http://csclub.uwaterloo.ca/xslt">
9
10 <xsl:param name="g_datetime" required="yes" />
11
12 <xsl:template match="//eventdefs">
13     <xsl:call-template name="atom">
14         <xsl:with-param name="title">Events</xsl:with-param>
15         <xsl:with-param name="feedfile">events.atom</xsl:with-param>
16         <xsl:with-param name="uuid">006f667f-ecae-483a-8cbc-f0c5084dccb1</xsl:with-param>
17     </xsl:call-template>
18 </xsl:template>
19
20 <xsl:template match="//newsdefs">
21     <xsl:call-template name="atom">
22         <xsl:with-param name="title">News</xsl:with-param>
23         <xsl:with-param name="feedfile">news.atom</xsl:with-param>
24         <xsl:with-param name="uuid">bdae3752-0cb7-4932-b176-019076389b54</xsl:with-param>
25     </xsl:call-template>
26 </xsl:template>
27
28 <xsl:template name="atom">
29     <xsl:param name="title"/>
30     <xsl:param name="feedfile"/>
31     <xsl:param name="uuid"/>
32     <feed xmlns="http://www.w3.org/2005/Atom">
33         <title>UW Computer Science Club <xsl:value-of select="$title"/></title>
34         <link href="http://csclub.uwaterloo.ca/{$feedfile}" rel="self"/>
35         <link href="http://csclub.uwaterloo.ca/"/>
36         <updated><xsl:value-of select="translate($g_datetime,' ','T')"/></updated>
37         <id>urn:uuid:<xsl:value-of select="$uuid"/></id>
38         <author>
39         <name>University of Waterloo Computer Science Club</name>
40         </author>
41         <xsl:for-each select="newsitem">
42             <entry>
43                 <link href="http://csclub.uwaterloo.ca"/>
44                 <summary><xsl:value-of select="."/></summary>
45                 <author><name><xsl:value-of select="@author"/></name></author>
46             </entry>
47         </xsl:for-each>
48         <xsl:for-each select="eventitem">
49             <entry>
50                 <title><xsl:value-of select="@title"/></title>
51                 <!-- we do a hack here with the translate to get whitespace replacement -->
52                 <link href="{concat('http://csclub.uwaterloo.ca/events/',translate(@room,' ','_'),'-',translate(@date,' ','_'),'-',translate(@time,' ','_'),'.html')}"/>
53                 <author><name><xsl:value-of select="short"/></name></author>
54                 <summary><xsl:value-of select="abstract"/></summary>
55                 <updated><xsl:value-of select="translate($g_datetime,' ','T')"/></updated>
56                 <id><xsl:value-of select="concat('http://csclub.uwaterloo.ca/events/',translate(@room,' ','_'),'-',translate(@date,' ','_'),'-',translate(@time,' ','_'),'.html')"/></id>
57             </entry>
58         </xsl:for-each>
59     </feed>
60 </xsl:template>
61
62 </xsl:stylesheet>