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