Don't output xmlns attributes except on root element
[mspang/www.git] / xsl / events.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/1999/xhtml"
7     exclude-result-prefixes="csc">
8 <xsl:output method="xml" />
9
10 <xsl:template name="events">
11   <tr>
12     <th colspan="2" class="news">Upcoming Events</th>
13   </tr>
14   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
15     <xsl:sort select="translate(@date, '-', '')"
16         order="ascending" data-type="number" />
17     <xsl:if test="translate(@date, '-', '') &gt;= translate($g_date, '-', '')">
18       <tr>
19         <td class="eventdate"><xsl:value-of select="@date" /></td>
20         <td rowspan="2" valign="top" class="eventitem">
21           <a href="{translate(concat('/events/', @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
22             <xsl:value-of select="@title" />
23           </a>.
24           <xsl:value-of select="short" />
25         </td>
26       </tr>
27       <tr>
28         <td class="eventroom">
29           <xsl:value-of select="@time" />,
30           <xsl:value-of select="@room" />
31         </td>
32       </tr>
33     </xsl:if>
34   </xsl:for-each>
35   <tr>
36     <td class="eventitem" colspan="2">
37       <a href="events/">Past events</a> are available.
38     </td>
39   </tr>
40 </xsl:template>
41
42 <xsl:template match="events-this-term">
43   <xsl:call-template name="events-by-term">
44     <xsl:with-param name="date" select="$g_date" />
45   </xsl:call-template>
46 </xsl:template>
47
48 <xsl:template name="events-by-term">
49   <xsl:param name="date" />
50   <p>The events for <xsl:value-of select="csc:term($date)" /> are listed here.
51     You can also <a href="{$g_pre}events.ics">download an ICS</a> of them.</p>
52   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
53     <xsl:sort select="translate(@date, '-', '')"
54         order="ascending" data-type="number" />
55     <xsl:if test="csc:term(@date) = csc:term($date)">
56       <h3><a href="{translate(concat($g_pre, 'events/', @room, '-', @date, '-', @time, '.html'), ' ', '_')}"><xsl:value-of select="@title" /></a></h3>
57       <p>
58         <strong>
59           <xsl:value-of select="@room" />,
60           <xsl:value-of select="@date" />,
61           <xsl:value-of select="@time" />:
62         </strong>
63         <xsl:value-of select="short" />.
64       </p>
65     </xsl:if>
66   </xsl:for-each>
67 </xsl:template>
68
69 <xsl:template match="eventdefs">
70   <xsl:apply-templates/>
71 </xsl:template>
72
73 <xsl:template match="eventitem">
74   <xsl:document method="xml" encoding="ISO-8859-1"
75       doctype-public="-//W3C//DTD XHTML 1.1//EN"
76       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
77       href="{translate(concat($g_outdir, @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
78     <html>
79       <head>
80         <title><xsl:value-of select="@title" /></title>
81         <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
82       </head>
83       <body><div class="content">
84         <xsl:call-template name="header" />
85         <h2>Information</h2>
86         <div>
87           <p><xsl:value-of select="@title" />.</p>
88           <p>
89             Held in <xsl:value-of select="@room" />, on
90             <xsl:value-of select="@date" />, at
91             <xsl:value-of select="@time" />.
92           </p>
93         </div>
94         <h2>Abstract</h2>
95         <xsl:apply-templates select="abstract/node()" />
96         <xsl:call-template name="footer" />
97       </div></body>
98     </html>
99   </xsl:document>
100 </xsl:template>
101
102 <xsl:template match="generate-event-files">
103   <xsl:apply-templates select="document(concat($g_root, '/events.xml'))/eventdefs" />
104 </xsl:template>
105
106 <xsl:template match="old-events">
107   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
108     <xsl:sort select="translate(@date, '-', '')"
109         order="descending" data-type="number" />
110     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
111       <p><a href="{translate(concat('old-',csc:term(@date), '.html'), ' ', '_')}">
112         <xsl:value-of select="csc:term(@date)" />
113       </a></p>
114       <xsl:document method="xml" encoding="ISO-8859-1"
115             doctype-public="-//W3C//DTD XHTML 1.1//EN"
116             doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
117             href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
118         <html>
119           <head>
120             <title>Events for <xsl:value-of select="csc:term(@date)" /></title>
121             <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
122           </head>
123           <body><div class="content">
124             <xsl:call-template name="header" />
125             <xsl:call-template name="events-by-term">
126                 <xsl:with-param name="date" select="@date" />
127             </xsl:call-template>
128             <xsl:call-template name="footer" />
129           </div></body>
130         </html>
131       </xsl:document>
132     </xsl:if>
133   </xsl:for-each>
134 </xsl:template>
135
136 </xsl:stylesheet>