]> matita.cs.unibo.it Git - helm.git/blob - helm/mowgli/home/xsl/xhtml-content.xsl
ocaml 3.09 transition
[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="make_footer" select="true()"/>
15 <xsl:param name="use_frames" select="'yes'"/>
16
17 <!--CSC: The following mess is due to a bug of xsltproc w.r.t. patterns
18          precedence: the less general pattern is sometimes applied ;-( -->
19 <xsl:template match="html">
20  <xsl:call-template name="html"/>
21 </xsl:template>
22
23 <xsl:template name="html">
24  <html>
25   <head>
26    <title><xsl:value-of select="head/title"/></title>
27    <link rel="stylesheet" href="{$path_to_top}/../style/mowgli.css" type="text/css"/>
28   </head>
29   <body>
30    <xsl:variable name="body">
31     <xsl:if test="$make_header">
32      <xsl:call-template name="head">
33       <xsl:with-param name="path_to_top" select="$path_to_top"/>
34      </xsl:call-template>
35     </xsl:if>
36     <xsl:apply-templates select="*[2]/node()"/>
37     <xsl:if test="$make_footer">
38      <xsl:call-template name="foot">
39       <xsl:with-param name="path_to_top" select="$path_to_top"/>
40      </xsl:call-template>
41     </xsl:if>
42    </xsl:variable>
43    <xsl:choose>
44     <xsl:when test="$use_frames = 'yes'">
45      <xsl:copy-of select="$body"/>
46     </xsl:when>
47     <xsl:otherwise>
48      <table>
49       <tr>
50        <td nowrap="true" valign="top">
51         <xsl:apply-templates mode="menu" select="document('../xml/menu.xml')/*/*[2]/*"/>
52        </td>
53        <td width="5%">&#x0A0;</td>
54        <td valign="top">
55         <xsl:copy-of select="$body"/>
56        </td>
57       </tr>
58      </table>
59     </xsl:otherwise>
60    </xsl:choose>
61   </body>
62  </html>
63 </xsl:template>
64
65 <xsl:template match="*|text()|@*">
66  <xsl:choose>
67   <xsl:when test="name(.) = 'html'">
68    <xsl:call-template name="html"/>
69   </xsl:when>
70   <xsl:otherwise>
71    <xsl:copy>
72     <xsl:apply-templates select="*|text()|@*"/>
73    </xsl:copy>
74   </xsl:otherwise>
75  </xsl:choose>
76 </xsl:template>
77
78 <xsl:template match="mowgli:latest-news">
79  <xsl:copy-of select="document('../html/latest-news.xml')/*/*"/>
80 </xsl:template>
81
82 <xsl:template match="mowgli:approaching-deadlines">
83  <xsl:copy-of select="document('../html/approaching-deadlines.xml')/*/*"/>
84 </xsl:template>
85
86 <xsl:template match="mowgli:date">
87  <xsl:copy-of select="$current-date"/>
88 </xsl:template>
89
90 <xsl:template match="mowgli:change-frame-settings">
91  <br/>
92  <p>
93  <xsl:choose>
94   <xsl:when test="$use_frames = 'yes'">
95    [<a href="../html_no_frames" target="_top">No frames</a>]
96   </xsl:when>
97   <xsl:otherwise>
98    [<a href="{$path_to_top}/../html_yes_frames" target="_top">Frames</a>]
99   </xsl:otherwise>
100  </xsl:choose>
101  </p>
102 </xsl:template>
103
104 <xsl:template name="a_menu">
105  <xsl:copy>
106   <xsl:choose>
107    <xsl:when test="starts-with(@href,'/') or
108                    starts-with(@href,'http://') or
109                    starts-with(@href,'mailto:')">
110     <xsl:copy-of select="@href"/>
111    </xsl:when>
112    <xsl:otherwise>
113     <xsl:attribute name="href">
114      <xsl:value-of select="$path_to_top"/>
115      <xsl:text>/</xsl:text>
116      <xsl:value-of select="@href"/>
117     </xsl:attribute>
118    </xsl:otherwise>
119   </xsl:choose>
120   <xsl:value-of select="text()"/>
121  </xsl:copy>
122 </xsl:template>
123
124 <xsl:template mode="menu" match="*|text()|@*">
125  <xsl:choose>
126   <xsl:when test="name(.) = 'a'">
127    <xsl:call-template name="a_menu"/>
128   </xsl:when>
129   <xsl:when test="name(.) = 'mowgli:change-frame-settings'">
130    <xsl:apply-templates select="."/>
131   </xsl:when>
132   <xsl:otherwise>
133    <xsl:copy>
134     <xsl:apply-templates mode="menu" select="*|text()|@*"/>
135    </xsl:copy>
136   </xsl:otherwise>
137  </xsl:choose>
138 </xsl:template>
139
140 </xsl:stylesheet>