]> matita.cs.unibo.it Git - helm.git/blob - helm/mowgli/home/xsl/xhtml-content.xsl
templates/menu.html moved to xml/menu.xml
[helm.git] / helm / mowgli / home / xsl / xhtml-content.xsl
1 <?xml version="1.0"?>
2
3 <xsl:stylesheet version="1.0"
4                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5                 xmlns:mowgli="http://mowgli.cs.unibo.it/website">
6
7 <xsl:import href="common.xsl"/>
8
9 <xsl:output method="html"/>
10
11 <xsl:param name="path_to_top" select="'.'"/>
12 <xsl:param name="current-date"/>
13 <xsl:param name="make_header" select="true()"/>
14 <xsl:param name="use_frames" select="'yes'"/>
15
16 <!--CSC: The following mess is due to a bug of xsltproc w.r.t. patterns
17          precedence: the less general pattern is sometimes applied ;-( -->
18 <xsl:template match="html">
19  <xsl:call-template name="html"/>
20 </xsl:template>
21
22 <xsl:template name="html">
23  <html>
24   <head>
25    <title><xsl:value-of select="head/title"/></title>
26    <link rel="stylesheet" href="{$path_to_top}/../style/mowgli.css" type="text/css"/>
27   </head>
28   <body>
29    <xsl:variable name="body">
30     <xsl:if test="$make_header">
31      <xsl:call-template name="head">
32       <xsl:with-param name="path_to_top" select="$path_to_top"/>
33      </xsl:call-template>
34     </xsl:if>
35     <xsl:apply-templates select="*[2]/node()"/>
36     <xsl:call-template name="foot">
37      <xsl:with-param name="path_to_top" select="$path_to_top"/>
38     </xsl:call-template>
39    </xsl:variable>
40    <xsl:choose>
41     <xsl:when test="$use_frames = 'yes'">
42      <xsl:copy-of select="$body"/>
43     </xsl:when>
44     <xsl:otherwise>
45      <table>
46       <tr>
47        <td nowrap="true" valign="top">
48         <xsl:apply-templates mode="menu" select="document('../xml/menu.xml')/*/*[2]/*"/>
49        </td>
50        <td width="5%">&#x0A0;</td>
51        <td valign="top">
52         <xsl:copy-of select="$body"/>
53        </td>
54       </tr>
55      </table>
56     </xsl:otherwise>
57    </xsl:choose>
58   </body>
59  </html>
60 </xsl:template>
61
62 <xsl:template match="*|text()|@*">
63  <xsl:choose>
64   <xsl:when test="name(.) = 'html'">
65    <xsl:call-template name="html"/>
66   </xsl:when>
67   <xsl:otherwise>
68    <xsl:copy>
69     <xsl:apply-templates select="*|text()|@*"/>
70    </xsl:copy>
71   </xsl:otherwise>
72  </xsl:choose>
73 </xsl:template>
74
75 <xsl:template match="mowgli:latest-news">
76  <xsl:copy-of select="document('../html/latest-news.xml')/*/*"/>
77 </xsl:template>
78
79 <xsl:template match="mowgli:approaching-deadlines">
80  <xsl:copy-of select="document('../html/approaching-deadlines.xml')/*/*"/>
81 </xsl:template>
82
83 <xsl:template match="mowgli:date">
84  <xsl:copy-of select="$current-date"/>
85 </xsl:template>
86
87 <xsl:template name="a_menu">
88  <xsl:copy>
89   <xsl:choose>
90    <xsl:when test="starts-with(@href,'/') or
91                    starts-with(@href,'http://') or
92                    starts-with(@href,'mailto:')">
93     <xsl:copy-of select="@href"/>
94    </xsl:when>
95    <xsl:otherwise>
96     <xsl:attribute name="href">
97      <xsl:value-of select="$path_to_top"/>
98      <xsl:text>/</xsl:text>
99      <xsl:value-of select="@href"/>
100     </xsl:attribute>
101    </xsl:otherwise>
102   </xsl:choose>
103   <xsl:value-of select="text()"/>
104  </xsl:copy>
105 </xsl:template>
106
107 <xsl:template mode="menu" match="*|text()|@*">
108  <xsl:choose>
109   <xsl:when test="name(.) = 'a'">
110    <xsl:call-template name="a_menu"/>
111   </xsl:when>
112   <xsl:otherwise>
113    <xsl:copy>
114     <xsl:apply-templates mode="menu" select="*|text()|@*"/>
115    </xsl:copy>
116   </xsl:otherwise>
117  </xsl:choose>
118 </xsl:template>
119
120 </xsl:stylesheet>