Merge branch 'master' of disk:/users/www/www/
[www/www.git] / xsl / functions.xsl
1 <?xml version='1.0'?>
2
3 <xsl:stylesheet version="2.0"
4     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5     xmlns:xs="http://www.w3.org/2001/XMLSchema"
6     xmlns:csc="http://www.csclub.uwaterloo.ca/xslt">
7
8 <xsl:function name="csc:term" as="xs:string">
9   <xsl:param name="date" />
10   <xsl:variable name="date_year" as="xs:integer">
11     <xsl:analyze-string select="$date" regex="([0-9]+)-[0-9]+-[0-9]+">
12       <xsl:matching-substring>
13         <xsl:value-of select="regex-group(1)" />
14       </xsl:matching-substring>
15     </xsl:analyze-string>
16   </xsl:variable>
17   <xsl:variable name="date_month" as="xs:integer">
18     <xsl:analyze-string select="$date" regex="[0-9]+-([0-9]+)-[0-9]+">
19       <xsl:matching-substring>
20         <xsl:value-of select="regex-group(1)" />
21       </xsl:matching-substring>
22     </xsl:analyze-string>
23   </xsl:variable>
24   <xsl:variable name="term_text">
25     <xsl:choose>
26       <xsl:when test="$date_month ge 1 and $date_month le 4">Winter </xsl:when>
27       <xsl:when test="$date_month ge 5 and $date_month le 8">Spring </xsl:when>
28       <xsl:when test="$date_month ge 9 and $date_month le 12">Fall </xsl:when>
29     </xsl:choose>
30   </xsl:variable>
31   <xsl:value-of select="concat($term_text, $date_year)" />
32 </xsl:function>
33
34 </xsl:stylesheet>