]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/params.xsl
This commit was manufactured by cvs2svn to create branch 'init'.
[helm.git] / helm / style / params.xsl
diff --git a/helm/style/params.xsl b/helm/style/params.xsl
deleted file mode 100644 (file)
index d703bfe..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-<?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">
-
-<!--***********************************************************************--> 
-<!-- auxiliary functions                                                   -->
-<!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
-<!--***********************************************************************--> 
-
-<!--***********************************************************************-->
-<!-- get the name from a URI                                               -->
-<!--***********************************************************************-->
-
-<!-- CSC: PROBLEMA: URI CHE NON CONTENGONO / ED INIZIANO CON cic: -->
-<xsl:template name="name_of_uri">
- <xsl:param name="uri" select="&quot;&quot;"/>
- <xsl:variable name="suffix" select="substring-after($uri, &quot;/&quot;)"/>
- <xsl:choose>
-  <xsl:when test="$suffix = &quot;&quot;">
-   <!-- CSC: PROBLEMA: .con PUO' APPARIRE ALL'INTERNO DELLE URI ===>
-     SCRIVERE UNA FUNZIONE RICORSIVA CHE RISOLVA -->
-   <xsl:value-of select="substring-before($uri,&quot;.con&quot;)"/>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:call-template name="name_of_uri">
-    <xsl:with-param name="uri" select="$suffix"/>
-   </xsl:call-template>
-  </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!--***********************************************************************-->
-<!-- erase common prefix from two uris                                     -->
-<!--***********************************************************************-->
-
-<xsl:template name="common_prefix">
- <xsl:param name="first_uri" select="&quot;&quot;"/>
- <xsl:param name="second_uri" select="&quot;&quot;"/>
- <xsl:choose>
-  <xsl:when test="(substring-before($first_uri,&quot;/&quot;) = 
-                substring-before($second_uri,&quot;/&quot;) and 
-                substring-after($second_uri,&quot;/&quot;) != &quot;&quot;)">
-   <xsl:call-template name="common_prefix">
-    <xsl:with-param 
-        name="first_uri" select="substring-after($first_uri,&quot;/&quot;)"/>
-    <xsl:with-param 
-        name="second_uri" select="substring-after($second_uri,&quot;/&quot;)"/>    </xsl:call-template>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:call-template name="slash_counting">
-    <xsl:with-param name="uri" select="$second_uri"/>
-    <xsl:with-param name="counter" select="0"/>
-   </xsl:call-template>
-  </xsl:otherwise>   
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="slash_counting">
- <xsl:param name="uri" select="&quot;&quot;"/>
- <xsl:param name="counter" select="0"/>
- <xsl:choose>
-  <xsl:when test="(substring-after($uri,&quot;/&quot;) != &quot;&quot;)">
-   <xsl:call-template name="slash_counting">
-    <xsl:with-param 
-        name="uri" select="substring-after($uri,&quot;/&quot;)"/>
-    <xsl:with-param
-        name="counter" select="$counter +1"/> 
-   </xsl:call-template>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:value-of select="$counter"/>
-  </xsl:otherwise>
- </xsl:choose>   
-</xsl:template>
-
-<xsl:template name="blank_counting">
- <xsl:param name="string" select="&quot;&quot;"/>
- <xsl:param name="counter" select="0"/>
- <xsl:choose>
-  <xsl:when test="(substring-after($string,&quot; &quot;) != &quot;&quot;)">
-   <xsl:call-template name="blank_counting">
-    <xsl:with-param 
-        name="string" select="substring-after($string,&quot; &quot;)"/>
-    <xsl:with-param 
-        name="counter" select="$counter +1"/> 
-   </xsl:call-template>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:value-of select="$counter + 1"/>
-  </xsl:otherwise> 
- </xsl:choose>  
-</xsl:template>
-
-<xsl:template name="double_point_counting">
- <xsl:param name="string" select="&quot;&quot;"/>
- <xsl:param name="counter" select="0"/>
- <xsl:choose>
-  <xsl:when test="(substring-after($string,&quot;:&quot;) != &quot;&quot;)">
-   <xsl:call-template name="double_point_counting">
-    <xsl:with-param 
-        name="string" select="substring-after($string,&quot;:&quot;)"/>
-    <xsl:with-param 
-        name="counter" select="$counter +1"/> 
-   </xsl:call-template>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:value-of select="$counter"/>
-  </xsl:otherwise> 
- </xsl:choose>  
-</xsl:template>
-
-<xsl:template name="min">
- <xsl:param name="string" select="&quot;&quot;"/>
- <xsl:param name="counter" select="0"/>
- <xsl:choose>
-  <xsl:when test="contains($string,concat($counter,&quot;:&quot;))
-         or (0 > $counter)">
-  <xsl:value-of select="$counter"/>
-  </xsl:when>
-  <xsl:otherwise>
-   <xsl:call-template name="min">
-    <xsl:with-param 
-        name="string" select="$string"/>
-    <xsl:with-param 
-        name="counter" select="$counter -1"/> 
-   </xsl:call-template>
-  </xsl:otherwise>
- </xsl:choose>  
-</xsl:template>
-
-<xsl:template name="get_no_params">
-    <xsl:param name="first_uri" select="&quot;&quot;"/>
-    <xsl:param name="second_uri" select="&quot;&quot;"/>
-     <xsl:variable name="offset">
-      <xsl:call-template name="common_prefix">
-       <xsl:with-param name="first_uri" select="$first_uri"/>
-       <xsl:with-param name="second_uri" select="$second_uri"/>
-      </xsl:call-template>
-     </xsl:variable>
-     <xsl:choose>
-         <xsl:when test="$offset > 0">
-          <xsl:variable name="params"> 
-        <xsl:variable name="second_url">
-                       <xsl:call-template name="URLofURI4getter">
-                               <xsl:with-param name="uri" select="$second_uri"/>
-                       </xsl:call-template>
-               </xsl:variable>
-        <xsl:value-of select="document($second_url)/*/@params"/>
-       </xsl:variable>
-       <xsl:variable name="minimum">
-        <xsl:call-template name="min">
-         <xsl:with-param name="string" select="$params"/>
-         <xsl:with-param name="counter" select="$offset - 1"/>
-        </xsl:call-template>
-       </xsl:variable>
-       <xsl:choose>
-        <xsl:when test="0 > $minimum">0</xsl:when>
-        <xsl:otherwise>
-         <xsl:variable name="relevant_params">
-          <!-- the blank after : in the next line is essential -->
-          <xsl:value-of 
-            select="substring-after($params,concat($minimum,&quot;: &quot;))"/>
-         </xsl:variable>
-         <xsl:variable name="tokens">
-          <xsl:call-template name="blank_counting">
-           <xsl:with-param name="string" select="$relevant_params"/>
-           <xsl:with-param name="counter" select="0"/>
-          </xsl:call-template>
-         </xsl:variable>
-         <xsl:variable name="separators">
-          <xsl:call-template name="double_point_counting">
-           <xsl:with-param name="string" select="$relevant_params"/>
-           <xsl:with-param name="counter" select="0"/>
-          </xsl:call-template>
-         </xsl:variable>
-         <xsl:value-of select="number($tokens - $separators)"/>
-        </xsl:otherwise>
-       </xsl:choose>
-      </xsl:when>
-      <xsl:otherwise>0</xsl:otherwise>
-     </xsl:choose>
-</xsl:template>
-
-
-<!--***********************************************************************-->
-<!--  Insert a subscript if there is a number at the end of a ci element   -->
-<!--***********************************************************************-->
-
-<xsl:template name="insert_subscript">
-<xsl:param name="node_value" select="&quot;&quot;"/>
-<xsl:param name="current_pos" select="1"/>
-<xsl:param name="start_pos" select="0"/>
-    <xsl:choose>
-    <xsl:when test="$current_pos &lt;= string-length(string($node_value))">
-    <xsl:variable name="current_char"><xsl:value-of select="substring(string($node_value),$current_pos,1)"/></xsl:variable>
-     <xsl:choose>
-     <xsl:when test="(string($current_char) != &quot;0&quot;) and (string($current_char) != &quot;1&quot;) and (string($current_char) != &quot;2&quot;) and (string($current_char) != &quot;3&quot;) and (string($current_char) != &quot;4&quot;) and (string($current_char) != &quot;5&quot;) and (string($current_char) != &quot;6&quot;) and (string($current_char) !=  &quot;7&quot;) and (string($current_char) != &quot;8&quot;) and (string($current_char) != &quot;9&quot;)">
-      <xsl:choose> 
-      <xsl:when test="$start_pos != 0">
-       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="0"/></xsl:call-template>
-      </xsl:when> 
-      <xsl:otherwise>
-       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$start_pos"/></xsl:call-template>
-      </xsl:otherwise>
-      </xsl:choose>
-     </xsl:when>
-     <xsl:otherwise>  
-      <xsl:choose>
-      <xsl:when test="$start_pos = 0">
-       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$current_pos"/></xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value" select="$node_value"/><xsl:with-param name="current_pos" select="$current_pos + 1"/><xsl:with-param name="start_pos" select="$start_pos"/></xsl:call-template>
-      </xsl:otherwise>
-      </xsl:choose>      
-     </xsl:otherwise>
-     </xsl:choose>
-    </xsl:when>
-    <xsl:otherwise>
-     <xsl:choose>
-     <xsl:when test="$start_pos != 0">
-      <m:msub>
-       <m:mi><xsl:value-of select="substring(string($node_value),1,$start_pos -1)"/></m:mi>
-       <m:mn><xsl:value-of select="substring(string($node_value),$start_pos)"/></m:mn>
-       </m:msub>
-     </xsl:when>
-     <xsl:otherwise>
-      <xsl:value-of select="$node_value"/>
-     </xsl:otherwise>
-     </xsl:choose>
-    </xsl:otherwise>    
-    </xsl:choose>
-</xsl:template>
-
-
-<!--*******************************************-->
-<!--    ABSTRACTING PARAMETERS AND COUNTING    -->
-<!--*******************************************-->
-<!-- Si dimentica i CAST dei termini che astrae. Nel caso dell'astrazione -->
-<!-- dei lambda dei pattern del CASE, qualora i lambda non si trovino     -->
-<!-- nella forma weak-head, astrae solo i lambda che trova e restituisce  -->
-<!-- un corpo depurato da tutti i primi cast che precedono il termine     -->
-<!-- restituito.                                                          -->
-
-<xsl:template match="*" mode="abstparams">
-<xsl:param name="noparams" select="0"/>
-<xsl:param name="target" select="0"/>
-<xsl:param name="binder">PROD</xsl:param>
-    <xsl:choose>
-    <xsl:when test="($noparams != 0) and ((name(.)=string($binder)) or (name(.)=&quot;CAST&quot;))">
-     <xsl:choose>
-     <xsl:when test="name(.) = string($binder)">
-      <xsl:if test="$target = 0">
-       <xsl:choose>
-       <xsl:when test="string($binder) = &quot;LAMBDA&quot;">
-        <m:ci>
-         <xsl:call-template name="insert_subscript"><xsl:with-param name="node_value"><xsl:value-of select="target/@binder"/></xsl:with-param></xsl:call-template>
-        </m:ci>
-       </xsl:when>
-       <xsl:otherwise> 
-        <Param name="{target/@binder}">
-         <xsl:apply-templates select="source"/>
-        </Param>
-       </xsl:otherwise>
-       </xsl:choose>
-      </xsl:if>
-      <xsl:apply-templates select="target/*[1]" mode="abstparams">
-       <xsl:with-param name="noparams" select="$noparams - 1"/>
-       <xsl:with-param name="target" select="$target"/>
-       <xsl:with-param name="binder" select="$binder"/>
-      </xsl:apply-templates>
-     </xsl:when>
-     <xsl:otherwise>
-      <xsl:apply-templates select="term/*[1]" mode="abstparams">
-       <xsl:with-param name="noparams" select="$noparams"/>
-       <xsl:with-param name="target" select="$target"/>
-       <xsl:with-param name="binder" select="$binder"/>
-      </xsl:apply-templates>
-     </xsl:otherwise>
-     </xsl:choose>
-    </xsl:when>
-    <xsl:otherwise> 
-     <xsl:choose>
-     <xsl:when test="($target = 1) and ($noparams != 0)">
-      <m:apply>
-      <m:csymbol>app</m:csymbol>
-<!-- Mancava modalita': sono all'interno di un termine -->
-      <xsl:apply-templates select="." mode="pure"/>
-      <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
-      </m:apply>
-     </xsl:when>
-     <xsl:otherwise>
-      <xsl:choose>
-      <xsl:when test="$noparams != 0">
-      <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noparams"/></xsl:call-template>
-      </xsl:when>
-      <xsl:otherwise>
-       <xsl:if test="$target = 1">
-<!-- Mancava modalita': con target=1 posso provenire sia da un oggetto che da un termine -->
-        <xsl:choose>
-        <xsl:when test="string($binder) = &quot;LAMBDA&quot;">
-        <!-- CSC: era pure, ma deve essere noannot. Giusto, Irene? -->
-         <xsl:apply-templates select="." mode="noannot"/>
-        </xsl:when>
-        <xsl:otherwise>
-         <xsl:apply-templates select="."/>
-        </xsl:otherwise>
-        </xsl:choose>
-       </xsl:if>
-      </xsl:otherwise>
-      </xsl:choose>
-     </xsl:otherwise>
-     </xsl:choose>
-    </xsl:otherwise>
-    </xsl:choose>
-</xsl:template>
-
-<xsl:template name="printparam">
-<xsl:param name="noleft" select="0"/>
-<xsl:param name="number" select="1"/>
-    <xsl:if test="$noleft != 0">
-     <m:ci><xsl:call-template name="insert_subscript"><xsl:with-param name="node_value">$<xsl:value-of select="$number"/></xsl:with-param></xsl:call-template></m:ci>
-     <xsl:call-template name="printparam"><xsl:with-param name="noleft" select="$noleft - 1"/><xsl:with-param name="number" select="$number + 1"/></xsl:call-template>  
-    </xsl:if>
-</xsl:template>
-
-<xsl:template match="*" mode="counting">
-<xsl:param name="noparams" select="0"/>
-<xsl:param name="count" select="0"/>
- <xsl:choose>
- <xsl:when test="name(.) = &quot;PROD&quot;">
-  <xsl:apply-templates select="target/*[1]" mode="counting">
-   <xsl:with-param name="noparams" select="$noparams"/>
-   <xsl:with-param name="count" select="$count + 1"/>
-  </xsl:apply-templates>
- </xsl:when>
- <xsl:when test="name(.) = &quot;CAST&quot;">
-  <xsl:apply-templates select="term/*[1]" mode="counting">
-   <xsl:with-param name="noparams" select="$noparams"/>
-   <xsl:with-param name="count" select="$count"/> 
-  </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
-  <xsl:value-of select="$count - $noparams"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>