]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/mowgli/home/xsl/xhtml-content.xsl
ocaml 3.09 transition
[helm.git] / helm / mowgli / home / xsl / xhtml-content.xsl
index 1830cd829cfdf9ab8c086a3d1c498dbc1610ce0f..296dbf8c9ecb635c3466e2aa91e7e2cb0a921e81 100644 (file)
 <?xml version="1.0"?>
 
 <xsl:stylesheet version="1.0"
-                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:mowgli="http://mowgli.cs.unibo.it/website">
 
 <xsl:import href="common.xsl"/>
 
 <xsl:output method="html"/>
 
 <xsl:param name="path_to_top" select="'.'"/>
+<xsl:param name="current-date"/>
+<xsl:param name="make_header" select="true()"/>
+<xsl:param name="make_footer" select="true()"/>
+<xsl:param name="use_frames" select="'yes'"/>
 
-<xsl:template match="content">
+<!--CSC: The following mess is due to a bug of xsltproc w.r.t. patterns
+         precedence: the less general pattern is sometimes applied ;-( -->
+<xsl:template match="html">
+ <xsl:call-template name="html"/>
+</xsl:template>
+
+<xsl:template name="html">
  <html>
   <head>
-   <title><xsl:value-of select="@title"/></title>
-   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+   <title><xsl:value-of select="head/title"/></title>
    <link rel="stylesheet" href="{$path_to_top}/../style/mowgli.css" type="text/css"/>
   </head>
   <body>
-    <xsl:call-template name="head">
-     <xsl:with-param name="path_to_top" select="$path_to_top"/>
-    </xsl:call-template>
-    <xsl:copy-of select="node()"/>
-    <xsl:call-template name="foot">
-     <xsl:with-param name="path_to_top" select="$path_to_top"/>
-    </xsl:call-template>
+   <xsl:variable name="body">
+    <xsl:if test="$make_header">
+     <xsl:call-template name="head">
+      <xsl:with-param name="path_to_top" select="$path_to_top"/>
+     </xsl:call-template>
+    </xsl:if>
+    <xsl:apply-templates select="*[2]/node()"/>
+    <xsl:if test="$make_footer">
+     <xsl:call-template name="foot">
+      <xsl:with-param name="path_to_top" select="$path_to_top"/>
+     </xsl:call-template>
+    </xsl:if>
+   </xsl:variable>
+   <xsl:choose>
+    <xsl:when test="$use_frames = 'yes'">
+     <xsl:copy-of select="$body"/>
+    </xsl:when>
+    <xsl:otherwise>
+     <table>
+      <tr>
+       <td nowrap="true" valign="top">
+        <xsl:apply-templates mode="menu" select="document('../xml/menu.xml')/*/*[2]/*"/>
+       </td>
+       <td width="5%">&#x0A0;</td>
+       <td valign="top">
+        <xsl:copy-of select="$body"/>
+       </td>
+      </tr>
+     </table>
+    </xsl:otherwise>
+   </xsl:choose>
   </body>
  </html>
 </xsl:template>
 
-</xsl:stylesheet>
+<xsl:template match="*|text()|@*">
+ <xsl:choose>
+  <xsl:when test="name(.) = 'html'">
+   <xsl:call-template name="html"/>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:copy>
+    <xsl:apply-templates select="*|text()|@*"/>
+   </xsl:copy>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
 
+<xsl:template match="mowgli:latest-news">
+ <xsl:copy-of select="document('../html/latest-news.xml')/*/*"/>
+</xsl:template>
+
+<xsl:template match="mowgli:approaching-deadlines">
+ <xsl:copy-of select="document('../html/approaching-deadlines.xml')/*/*"/>
+</xsl:template>
+
+<xsl:template match="mowgli:date">
+ <xsl:copy-of select="$current-date"/>
+</xsl:template>
+
+<xsl:template match="mowgli:change-frame-settings">
+ <br/>
+ <p>
+ <xsl:choose>
+  <xsl:when test="$use_frames = 'yes'">
+   [<a href="../html_no_frames" target="_top">No frames</a>]
+  </xsl:when>
+  <xsl:otherwise>
+   [<a href="{$path_to_top}/../html_yes_frames" target="_top">Frames</a>]
+  </xsl:otherwise>
+ </xsl:choose>
+ </p>
+</xsl:template>
+
+<xsl:template name="a_menu">
+ <xsl:copy>
+  <xsl:choose>
+   <xsl:when test="starts-with(@href,'/') or
+                   starts-with(@href,'http://') or
+                   starts-with(@href,'mailto:')">
+    <xsl:copy-of select="@href"/>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:attribute name="href">
+     <xsl:value-of select="$path_to_top"/>
+     <xsl:text>/</xsl:text>
+     <xsl:value-of select="@href"/>
+    </xsl:attribute>
+   </xsl:otherwise>
+  </xsl:choose>
+  <xsl:value-of select="text()"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template mode="menu" match="*|text()|@*">
+ <xsl:choose>
+  <xsl:when test="name(.) = 'a'">
+   <xsl:call-template name="a_menu"/>
+  </xsl:when>
+  <xsl:when test="name(.) = 'mowgli:change-frame-settings'">
+   <xsl:apply-templates select="."/>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:copy>
+    <xsl:apply-templates mode="menu" select="*|text()|@*"/>
+   </xsl:copy>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>