3 <!-- Copyright (C) 2000, HELM Team -->
5 <!-- This file is part of HELM, an Hypertextual, Electronic -->
6 <!-- Library of Mathematics, developed at the Computer Science -->
7 <!-- Department, University of Bologna, Italy. -->
9 <!-- HELM is free software; you can redistribute it and/or -->
10 <!-- modify it under the terms of the GNU General Public License -->
11 <!-- as published by the Free Software Foundation; either version 2 -->
12 <!-- of the License, or (at your option) any later version. -->
14 <!-- HELM is distributed in the hope that it will be useful, -->
15 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
16 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
17 <!-- GNU General Public License for more details. -->
19 <!-- You should have received a copy of the GNU General Public License -->
20 <!-- along with HELM; if not, write to the Free Software -->
21 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
22 <!-- MA 02111-1307, USA. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
27 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28 xmlns:m="http://www.w3.org/1998/Math/MathML">
30 <!--***********************************************************************-->
31 <!-- auxiliary functions -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
33 <!--***********************************************************************-->
35 <!--***********************************************************************-->
36 <!-- get the name from a URI -->
37 <!--***********************************************************************-->
39 <!-- CSC: PROBLEMA: URI CHE NON CONTENGONO / ED INIZIANO CON cic: -->
40 <xsl:template name="name_of_uri">
41 <xsl:param name="uri" select=""""/>
42 <xsl:variable name="suffix" select="substring-after($uri, "/")"/>
44 <xsl:when test="$suffix = """>
45 <!-- CSC: PROBLEMA: .con PUO' APPARIRE ALL'INTERNO DELLE URI ===>
46 SCRIVERE UNA FUNZIONE RICORSIVA CHE RISOLVA -->
47 <xsl:value-of select="substring-before($uri,".con")"/>
50 <xsl:call-template name="name_of_uri">
51 <xsl:with-param name="uri" select="$suffix"/>
57 <!--***********************************************************************-->
58 <!-- erase common prefix from two uris -->
59 <!--***********************************************************************-->
61 <xsl:template name="common_prefix">
62 <xsl:param name="first_uri" select=""""/>
63 <xsl:param name="second_uri" select=""""/>
65 <xsl:when test="(substring-before($first_uri,"/") =
66 substring-before($second_uri,"/") and
67 substring-after($second_uri,"/") != "")">
68 <xsl:call-template name="common_prefix">
70 name="first_uri" select="substring-after($first_uri,"/")"/>
72 name="second_uri" select="substring-after($second_uri,"/")"/> </xsl:call-template>
75 <xsl:call-template name="slash_counting">
76 <xsl:with-param name="uri" select="$second_uri"/>
77 <xsl:with-param name="counter" select="0"/>
83 <xsl:template name="slash_counting">
84 <xsl:param name="uri" select=""""/>
85 <xsl:param name="counter" select="0"/>
87 <xsl:when test="(substring-after($uri,"/") != "")">
88 <xsl:call-template name="slash_counting">
90 name="uri" select="substring-after($uri,"/")"/>
92 name="counter" select="$counter +1"/>
96 <xsl:value-of select="$counter"/>
101 <xsl:template name="blank_counting">
102 <xsl:param name="string" select=""""/>
103 <xsl:param name="counter" select="0"/>
105 <xsl:when test="(substring-after($string," ") != "")">
106 <xsl:call-template name="blank_counting">
108 name="string" select="substring-after($string," ")"/>
110 name="counter" select="$counter +1"/>
114 <xsl:value-of select="$counter + 1"/>
119 <xsl:template name="double_point_counting">
120 <xsl:param name="string" select=""""/>
121 <xsl:param name="counter" select="0"/>
123 <xsl:when test="(substring-after($string,":") != "")">
124 <xsl:call-template name="double_point_counting">
126 name="string" select="substring-after($string,":")"/>
128 name="counter" select="$counter +1"/>
132 <xsl:value-of select="$counter"/>
137 <xsl:template name="min">
138 <xsl:param name="string" select=""""/>
139 <xsl:param name="counter" select="0"/>
141 <xsl:when test="contains($string,concat($counter,":"))
143 <xsl:value-of select="$counter"/>
146 <xsl:call-template name="min">
148 name="string" select="$string"/>
150 name="counter" select="$counter -1"/>
156 <xsl:template name="get_no_params">
157 <xsl:param name="first_uri" select=""""/>
158 <xsl:param name="second_uri" select=""""/>
159 <xsl:variable name="offset">
160 <xsl:call-template name="common_prefix">
161 <xsl:with-param name="first_uri" select="$first_uri"/>
162 <xsl:with-param name="second_uri" select="$second_uri"/>
166 <xsl:when test="$offset > 0">
167 <xsl:variable name="params">
169 select="document(concat(string($absPath),$second_uri))/*/@params"/>
171 <xsl:variable name="minimum">
172 <xsl:call-template name="min">
173 <xsl:with-param name="string" select="$params"/>
174 <xsl:with-param name="counter" select="$offset - 1"/>
178 <xsl:when test="0 > $minimum">
182 <xsl:variable name="relevant_params">
183 <!-- the blank after : in the next line is essential -->
185 select="substring-after($params,concat($minimum,": "))"/>
187 <xsl:variable name="tokens">
188 <xsl:call-template name="blank_counting">
189 <xsl:with-param name="string" select="$relevant_params"/>
190 <xsl:with-param name="counter" select="0"/>
193 <xsl:variable name="separators">
194 <xsl:call-template name="double_point_counting">
195 <xsl:with-param name="string" select="$relevant_params"/>
196 <xsl:with-param name="counter" select="0"/>
199 <xsl:value-of select="$tokens - $separators"/>
210 <!--***********************************************************************-->
211 <!-- Insert a subscript if there is a number at the end of a ci element -->
212 <!--***********************************************************************-->
214 <xsl:template name="insert_subscript">
215 <xsl:param name="node_value" select=""""/>
216 <xsl:param name="current_pos" select="1"/>
217 <xsl:param name="start_pos" select="0"/>
219 <xsl:when test="$current_pos <= string-length(string($node_value))">
220 <xsl:variable name="current_char"><xsl:value-of select="substring(string($node_value),$current_pos,1)"/></xsl:variable>
222 <xsl:when test="(string($current_char) != "0") and (string($current_char) != "1") and (string($current_char) != "2") and (string($current_char) != "3") and (string($current_char) != "4") and (string($current_char) != "5") and (string($current_char) != "6") and (string($current_char) != "7") and (string($current_char) != "8") and (string($current_char) != "9")">
224 <xsl:when test="$start_pos != 0">
225 <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>
228 <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>
234 <xsl:when test="$start_pos = 0">
235 <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>
238 <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>
246 <xsl:when test="$start_pos != 0">
248 <m:mi><xsl:value-of select="substring(string($node_value),1,$start_pos -1)"/></m:mi>
249 <m:mn><xsl:value-of select="substring(string($node_value),$start_pos)"/></m:mn>
253 <xsl:value-of select="$node_value"/>