]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/html_init.xsl
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / style / html_init.xsl
index 44d75fd0a0df86d9d6006c8292340a6d6fc84eda..46fc61b249fa71842a62649809165a69ed6896c4 100644 (file)
 <?xml version="1.0"?>
 
+<!-- Copyright (C) 2000, HELM Team                                     -->
+<!--                                                                   -->
+<!-- This file is part of HELM, an Hypertextual, Electronic            -->
+<!-- Library of Mathematics, developed at the Computer Science         -->
+<!-- Department, University of Bologna, Italy.                         -->
+<!--                                                                   -->
+<!-- HELM is free software; you can redistribute it and/or             -->
+<!-- modify it under the terms of the GNU General Public License       -->
+<!-- as published by the Free Software Foundation; either version 2    -->
+<!-- of the License, or (at your option) any later version.            -->
+<!--                                                                   -->
+<!-- HELM is distributed in the hope that it will be useful,           -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of    -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     -->
+<!-- GNU General Public License for more details.                      -->
+<!--                                                                   -->
+<!-- You should have received a copy of the GNU General Public License -->
+<!-- along with HELM; if not, write to the Free Software               -->
+<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston,            -->
+<!-- MA  02111-1307, USA.                                              -->
+<!--                                                                   -->
+<!-- For details, see the HELM World-Wide-Web page,                    -->
+<!-- http://cs.unibo.it/helm/.                                         -->
+
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                               xmlns:m="http://www.w3.org/1998/Math/MathML">
 
+<xsl:template name="mksymbol-init">
+ <xsl:param name="symbol" select="''"/>
+  <xsl:choose>
+   <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">
+    <xsl:variable name="fontsymbol">
+     <xsl:choose>
+      <xsl:when test="$symbol = 'and'">
+       <xsl:value-of select="'&#217;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'or'">
+       <xsl:value-of select="'&#218;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'eq'">
+       <xsl:value-of select="'&#61;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'neq'">
+       <xsl:value-of select="'&#185;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'leq'">
+       <xsl:value-of select="'&#163;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'lt'">
+       <xsl:value-of select="'&#60;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'geq'">
+       <xsl:value-of select="'&#179;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'gt'">
+       <xsl:value-of select="'&#62;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'plus'">
+       <xsl:value-of select="'&#43;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'times'">
+       <xsl:value-of select="'&#42;'"/>
+      </xsl:when> 
+      <xsl:when test="$symbol = 'divide'">
+       <xsl:value-of select="'&#47;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'minus'">
+       <xsl:value-of select="'&#45;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'not'">
+       <xsl:value-of select="'&#216;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'exists'">
+       <xsl:value-of select="'&#36;'"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>???</xsl:text>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <FONT FACE="symbol" color="'blue'">
+     <xsl:value-of select="$fontsymbol"/>
+    </FONT>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:variable name="unicodesymbol">
+     <xsl:choose>
+      <xsl:when test="$symbol = 'and'">
+       <xsl:value-of select="'&#8743;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'or'">
+       <xsl:value-of select="'&#8744;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'eq'">
+       <xsl:value-of select="'&#61;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'neq'">
+       <xsl:value-of select="'&#8800;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'leq'">
+       <xsl:value-of select="'&#8804;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'lt'">
+       <xsl:value-of select="'&#60;&#32;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'geq'">
+       <xsl:value-of select="'&#8805;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'gt'">
+       <xsl:value-of select="'&#62;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'plus'">
+       <xsl:value-of select="'&#43;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'times'">
+       <xsl:value-of select="'&#8727;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'divide'">
+       <xsl:value-of select="'&#47;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'minus'">
+       <xsl:value-of select="'&#8722;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'not'">
+       <xsl:value-of select="'&#172;'"/>
+      </xsl:when>
+      <xsl:when test="$symbol = 'exists'">
+       <xsl:value-of select="'&#8707;'"/>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>???</xsl:text>
+      </xsl:otherwise>
+     </xsl:choose>
+    </xsl:variable>
+    <FONT color="'blue'">
+     <xsl:value-of select="$unicodesymbol"/>
+    </FONT>
+   </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+
 <!--***********************************************************************--> 
 <!-- INIT style for HTML                                                   -->
 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
 <!--***********************************************************************--> 
 
-<xsl:variable name="absPath">http://localhost:8081/getciconly?uri=</xsl:variable>
+<!-- INLINE MODE : BASIC OPERATORS -->
+
+<xsl:template mode="inline" match="m:infinity">
+ <xsl:choose>
+  <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">
+   <FONT FACE="symbol" color="'blue'">
+    <xsl:value-of select="'&#165;'"/>
+   </FONT>
+  </xsl:when>
+  <xsl:otherwise>
+   <FONT color="'blue'">
+    <!-- VERIFICARE -->
+    <xsl:value-of select="'&#165;'"/>
+   </FONT>
+  </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template mode="inline" match="m:eq|m:leq|m:lt|m:geq|m:gt">
+  <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
+  <xsl:choose>
+  <xsl:when test="$uri != ''">
+   <a href="{$uri}">
+    <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="local-name(.)"/>
+    </xsl:call-template>
+   </a>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="local-name(.)"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+ <xsl:template mode="inline" match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
+       |m:geq|m:gt|m:plus|m:times|m:divide]">
+  <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
+  <xsl:text>(</xsl:text>
+  <xsl:apply-templates mode="inline" select="*[2]"/>
+  <xsl:choose>
+  <xsl:when test="$uri != ''">
+   <a href="{$uri}">
+    <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="local-name(*[1])"/>
+    </xsl:call-template>
+   </a>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="local-name(*[1])"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+  </xsl:choose>
+  <xsl:apply-templates mode="inline" select="*[3]"/>
+  <xsl:text>)</xsl:text>
+ </xsl:template>
+
+<!-- INLINE MODE - MINUS (can be unary!) -->
+
+<xsl:template mode="inline" match="m:apply[m:minus]">
+  <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
+  <xsl:choose>
+   <xsl:when test="count(child::*)=2">
+    <xsl:choose>
+    <xsl:when test="$uri != ''">
+     <a href="{$uri}">
+      <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+      </xsl:call-template>
+     </a>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+     </xsl:call-template>
+    </xsl:otherwise>
+    </xsl:choose>
+    <xsl:apply-templates mode="inline" select="*[2]"/>
+   </xsl:when>
+   <xsl:otherwise>
+    <xsl:text>(</xsl:text>
+    <xsl:apply-templates mode="inline" select="*[2]"/>
+    <xsl:choose>
+    <xsl:when test="$uri != ''">
+     <a href="{$uri}">
+      <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+      </xsl:call-template>
+     </a>
+    </xsl:when>
+    <xsl:otherwise>
+     <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+     </xsl:call-template>
+    </xsl:otherwise>
+    </xsl:choose>
+    <xsl:apply-templates mode="inline" select="*[3]"/>
+    <xsl:text>)</xsl:text>
+   </xsl:otherwise>
+  </xsl:choose>
+ </xsl:template>
+
+<!-- INLINE MODE NOT -->
+
+<xsl:template mode="inline" match="m:apply[m:not]">
+  <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
+  <xsl:choose>
+  <xsl:when test="$uri != ''">
+   <a href="{$uri}">
+    <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="'not'"/>
+    </xsl:call-template>
+   </a>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:call-template name="mksymbol-init">
+    <xsl:with-param name="symbol" select="'not'"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+  </xsl:choose>
+  <xsl:apply-templates mode="inline" select="*[2]"/>
+</xsl:template>
 
+<!-- INLINE MODE EXISTS -->
+
+ <xsl:template mode="inline" match="m:apply[m:exists]">
+  <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
+  <xsl:choose>
+  <xsl:when test="$uri != ''">
+   <a href="{$uri}">
+    <xsl:call-template name="mksymbol-init">
+     <xsl:with-param name="symbol" select="'exists'"/>
+    </xsl:call-template>
+   </a>
+  </xsl:when>
+  <xsl:otherwise>
+   <xsl:call-template name="mksymbol-init">
+    <xsl:with-param name="symbol" select="'exists'"/>
+   </xsl:call-template>
+  </xsl:otherwise>
+  </xsl:choose>
+  <xsl:apply-templates select="m:bvar/m:ci"/>
+  <xsl:text>:</xsl:text>
+  <xsl:apply-templates mode="inline" select="m:condition"/>
+  <xsl:text>.</xsl:text>
+  <xsl:apply-templates mode="inline" select="*[last()]"/>
+ </xsl:template>
+
+<!-- COUNTING MODE -->
 
 <!-- BASIC OPERATORS -->
 
  <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
-       |m:geq|m:gt|m:plus|m:times]">
+       |m:geq|m:gt|m:plus|m:times|m:divide]">
   <xsl:param name="current_indent" select="0"/> 
   <xsl:param name="width" select="$framewidth"/>
-  <xsl:variable name="uri">
-   <xsl:value-of select="*[1]/@definitionURL"/>
-  </xsl:variable>
+  <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
   <xsl:variable name="charlength">
    <xsl:apply-templates select="*[1]" mode="charcount"/>
   </xsl:variable>
-  <xsl:variable name="symbol">
-   <xsl:choose>
-    <xsl:when test="m:and">
-     <xsl:value-of select="'&#217;'"/>
-    </xsl:when>
-    <xsl:when test="m:or">
-     <xsl:value-of select="'&#218;'"/>
-    </xsl:when>
-    <xsl:when test="m:eq">
-     <xsl:value-of select="'&#61;'"/>
-    </xsl:when>
-    <xsl:when test="m:neq">
-     <xsl:value-of select="'&#185;'"/>
-    </xsl:when>
-    <xsl:when test="m:leq">
-     <xsl:value-of select="'&#163;'"/>
-    </xsl:when>
-    <xsl:when test="m:lt">
-     <xsl:value-of select="'&#60;'"/>
-    </xsl:when>
-    <xsl:when test="m:geq">
-     <xsl:value-of select="'&#179;'"/>
-    </xsl:when>
-    <xsl:when test="m:gt">
-     <xsl:value-of select="'&#62;'"/>
-    </xsl:when>
-    <xsl:when test="m:plus">
-     <xsl:value-of select="'&#43;'"/>
-    </xsl:when>
-    <xsl:when test="m:times">
-     <xsl:value-of select="'&#42;'"/>
-    </xsl:when>
-   </xsl:choose>
-  </xsl:variable>
   <xsl:choose>
     <xsl:when test="$charlength > $framewidth">
      <xsl:text>(</xsl:text>
      <xsl:call-template name="make_indent">
       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
      </xsl:call-template>
-     <a>
-     <xsl:attribute name="href">
-      <xsl:value-of select="concat(string($header),string($uri))"/>
-     </xsl:attribute>
-     <FONT FACE="symbol" color="blue">
-      <xsl:value-of select="$symbol"/>
-     </FONT>
-     </a>
+     <xsl:choose>
+     <xsl:when test="$uri != ''">
+      <a href="{$uri}">
+       <xsl:call-template name="mksymbol-init">
+        <xsl:with-param name="symbol" select="local-name(*[1])"/>
+       </xsl:call-template>
+      </a>
+     </xsl:when>
+     <xsl:otherwise>
+       <xsl:call-template name="mksymbol-init">
+        <xsl:with-param name="symbol" select="local-name(*[1])"/>
+       </xsl:call-template>
+     </xsl:otherwise>
+     </xsl:choose>
      <xsl:apply-templates select="*[3]">
       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
      </xsl:apply-templates>
      <xsl:text>)</xsl:text>
     </xsl:when>
     <xsl:otherwise>
-     <xsl:text>(</xsl:text>
-     <xsl:apply-templates select="*[2]"/>
-     <a>
-     <xsl:attribute name="href">
-      <xsl:value-of select="concat(string($header),string($uri))"/>
-     </xsl:attribute>
-     <FONT FACE="symbol" color="blue">
-     <xsl:value-of select="$symbol"/>
-     </FONT>
-     </a>
-     <xsl:apply-templates select="*[3]"/>
-     <xsl:text>)</xsl:text>
+     <xsl:apply-templates mode="inline" select="."/>
     </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
 <xsl:template match="m:apply[m:minus]">
   <xsl:param name="current_indent" select="0"/> 
   <xsl:param name="width" select="$framewidth"/>
-  <xsl:variable name="uri">
-   <xsl:value-of select="*[1]/@definitionURL"/>
-  </xsl:variable>
+  <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
   <xsl:choose>
    <xsl:when test="count(child::*)=2">
-    <a>
-    <xsl:attribute name="href">
-     <xsl:value-of select="concat(string($header),string($uri))"/>
-    </xsl:attribute>
-    <xsl:text>-</xsl:text>
-    </a>
+    <xsl:choose>
+    <xsl:when test="$uri != ''">
+     <a href="{$uri}">
+      <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+      </xsl:call-template>
+     </a>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="mksymbol-init">
+       <xsl:with-param name="symbol" select="'minus'"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+    </xsl:choose>
     <xsl:apply-templates select="*[2]">
      <xsl:with-param name="current_indent" select="$current_indent + 1"/>
     </xsl:apply-templates>
       <xsl:call-template name="make_indent">
        <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
       </xsl:call-template>
-      <a>
-      <xsl:attribute name="href">
-       <xsl:value-of select="concat(string($header),string($uri))"/>
-      </xsl:attribute>
-      <xsl:text>-</xsl:text>
-      </a>
+      <xsl:choose>
+      <xsl:when test="$uri != ''">
+       <a href="{$uri}">
+        <xsl:call-template name="mksymbol-init">
+         <xsl:with-param name="symbol" select="'minus'"/>
+        </xsl:call-template>
+       </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="mksymbol-init">
+         <xsl:with-param name="symbol" select="'minus'"/>
+        </xsl:call-template>
+      </xsl:otherwise>
+      </xsl:choose>  
       <xsl:apply-templates select="*[3]">
        <xsl:with-param name="current_indent" select="$current_indent + 2"/>
       </xsl:apply-templates>
       <xsl:text>)</xsl:text>
      </xsl:when>
      <xsl:otherwise>
-      <xsl:text>(</xsl:text>
-      <xsl:apply-templates select="*[2]"/>
-      <a>
-      <xsl:attribute name="href">
-       <xsl:value-of select="concat(string($header),string($uri))"/>
-      </xsl:attribute>
-      <xsl:text>-</xsl:text>
-      </a>
-      <xsl:apply-templates select="*[3]"/>
-      <xsl:text>)</xsl:text>
+      <xsl:apply-templates mode="inline" select="."/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:otherwise>
 
 <!-- NOT -->
 
- <xsl:template match="m:apply[m:not]">
+<xsl:template match="m:apply[m:not]">
   <xsl:param name="current_indent" select="0"/> 
   <xsl:param name="width" select="$framewidth"/>
-  <xsl:variable name="uri">
-   <xsl:value-of select="m:not/@definitionURL"/>
-  </xsl:variable>
-     <a>
-     <xsl:attribute name="href">
-      <xsl:value-of select="concat(string($header),string($uri))"/>
-     </xsl:attribute>
-     <FONT FACE="symbol" color="blue">&#216;</FONT>
-     </a>
-     <xsl:apply-templates select="*[2]"/>
+  <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
+   <xsl:choose>
+   <xsl:when test="$uri != ''">
+    <a href="{$uri}">
+     <xsl:call-template name="mksymbol-init">
+      <xsl:with-param name="symbol" select="'not'"/>
+     </xsl:call-template>
+    </a>
+   </xsl:when>
+   <xsl:otherwise>
+     <xsl:call-template name="mksymbol-init">
+      <xsl:with-param name="symbol" select="'not'"/>
+     </xsl:call-template>
+   </xsl:otherwise>
+   </xsl:choose>
+   <xsl:apply-templates select="*[2]"/>
  </xsl:template>
 
 <!-- EXISTS -->
  <xsl:template match="m:apply[m:exists]">
   <xsl:param name="current_indent" select="0"/> 
   <xsl:param name="width" select="$framewidth"/>
-  <xsl:variable name="uri">
-   <xsl:value-of select="m:exists/@definitionURL"/>
-  </xsl:variable>
+  <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
   <xsl:variable name="charlength">
    <xsl:apply-templates select="m:exists" mode="charcount"/>
   </xsl:variable>
   <xsl:choose>
     <xsl:when test="$charlength > $framewidth">
-     <a>
-     <xsl:attribute name="href">
-      <xsl:value-of select="concat(string($header),string($uri))"/>
-     </xsl:attribute>
-     <FONT FACE="symbol" color="blue">&#36;</FONT>
-     </a>
+     <xsl:choose>
+     <xsl:when test="$uri != ''">
+      <a href="{$uri}">
+       <xsl:call-template name="mksymbol-init">
+        <xsl:with-param name="symbol" select="'exists'"/>
+       </xsl:call-template>
+      </a>
+     </xsl:when>
+     <xsl:otherwise>
+       <xsl:call-template name="mksymbol-init">
+        <xsl:with-param name="symbol" select="'exists'"/>
+       </xsl:call-template>
+     </xsl:otherwise>
+     </xsl:choose>
      <xsl:apply-templates select="m:bvar/m:ci"/>
      <xsl:text>:</xsl:text>
      <xsl:apply-templates select="m:condition">
       </xsl:apply-templates>
     </xsl:when>
     <xsl:otherwise>
-     <a>
-     <xsl:attribute name="href">
-      <xsl:value-of select="concat(string($header),string($uri))"/>
-     </xsl:attribute>
-     <FONT FACE="symbol" color="blue">&#36;</FONT>
-     </a>
-     <xsl:apply-templates select="m:bvar/m:ci"/>
-     <xsl:text>:</xsl:text>
-     <xsl:apply-templates select="m:condition"/>
-     <xsl:text>.</xsl:text>
-     <xsl:apply-templates select="*[last()]">
-      <xsl:with-param name="current_indent" select="$current_indent + 2"/>
-     </xsl:apply-templates>
+     <xsl:apply-templates mode="inline" select="."/>
     </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
 </xsl:template> 
 
 </xsl:stylesheet> 
-
-