Make website XHTML 1.1 compliant
[mspang/www.git] / xsl / news.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:csc="http://csclub.uwaterloo.ca/xslt">
8
9 <xsl:template match="newsdefs">
10   <xsl:apply-templates select="newsitem[csc:term(@date) = csc:term($g_date)]">
11     <xsl:sort select="translate(@date, '-', '')"
12         order="descending" data-type="number" />
13   </xsl:apply-templates>
14 </xsl:template>
15
16 <xsl:template match="newsitem">
17   <tr>
18     <td class="newsdate"><xsl:value-of select="@date" /></td>
19     <td rowspan="2" valign="top" class="newsitem"><xsl:apply-templates/></td>
20   </tr>
21   <tr>
22     <td class="newsauthor"><xsl:value-of select="@author" /></td>
23   </tr>
24 </xsl:template>
25
26 <xsl:template match="news" name="news">
27   <tr>
28     <th colspan="2" class="news">News</th>
29   </tr>
30   <xsl:apply-templates select="document(concat($g_root, '/news.xml'))/newsdefs" />
31   <tr>
32     <td class="newsitem" colspan="2">
33       <a href="news/">Older news items</a> are available. Make sure you check
34       out the <a href="/newsgroup/thread.php?group=uw.csc">uw.csc</a>
35       newsgroup and our announcement boards on the second and third floor of
36       MC for more updates. You can also
37       <a href="events.ics">download an ICS</a> of our events.
38     </td>
39   </tr>
40 </xsl:template>
41
42 <xsl:template name="news-by-term">
43   <xsl:param name="date" />
44   <p>The news for <xsl:value-of select="csc:term($date)" /> is listed here.</p>
45   <xsl:for-each select="document(concat($g_root, '/news.xml'))/newsdefs/newsitem">
46     <xsl:sort select="translate(@date, '-', '')"
47         order="descending" data-type="number" />
48     <xsl:if test="csc:term(@date) = csc:term($date)">
49       <p>
50         <strong>
51           <xsl:value-of select="@date" />,
52           <xsl:value-of select="@author" />:
53         </strong>
54         <xsl:apply-templates/>
55       </p>
56     </xsl:if>
57   </xsl:for-each>
58 </xsl:template>
59
60 <xsl:template match="old-news">
61   <xsl:for-each select="document(concat($g_root, '/news.xml'))/newsdefs/newsitem">
62     <xsl:sort select="translate(@date, '-', '')"
63         order="descending" data-type="number" />
64     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
65       <p><a href="{translate(concat('old-', csc:term(@date), '.html'), ' ', '_')}">
66         <xsl:value-of select="csc:term(@date)" />
67       </a></p>
68       <xsl:result-document method="xml" encoding="ISO-8859-1"
69           doctype-public="-//W3C//DTD XHTML 1.1//EN"
70           doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
71           href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
72         <html>
73           <head>
74             <title>News for <xsl:value-of select="csc:term(@date)" /></title>
75             <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
76           </head>
77           <body><div>
78             <xsl:call-template name="header" />
79             <xsl:call-template name="news-by-term">
80               <xsl:with-param name="date" select="@date" />
81             </xsl:call-template>
82             <xsl:call-template name="footer" />
83           </div></body>
84         </html>
85       </xsl:result-document>
86     </xsl:if>
87   </xsl:for-each>
88 </xsl:template>
89
90 </xsl:stylesheet>