3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:m="http://www.w3.org/1998/Math/MathML">
6 <!--***********************************************************************-->
7 <!-- auxiliary functions -->
8 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
9 <!--***********************************************************************-->
11 <!--***********************************************************************-->
12 <!-- get the name from a URI -->
13 <!--***********************************************************************-->
15 <!-- CSC: PROBLEMA: URI CHE NON CONTENGONO / ED INIZIANO CON cic: -->
16 <xsl:template name="name_of_uri">
17 <xsl:param name="uri" select=""""/>
18 <xsl:variable name="suffix" select="substring-after($uri, "/")"/>
20 <xsl:when test="$suffix = """>
21 <!-- CSC: PROBLEMA: .con PUO' APPARIRE ALL'INTERNO DELLE URI ===>
22 SCRIVERE UNA FUNZIONE RICORSIVA CHE RISOLVA -->
23 <xsl:value-of select="substring-before($uri,".con")"/>
26 <xsl:call-template name="name_of_uri">
27 <xsl:with-param name="uri" select="$suffix"/>
33 <!--***********************************************************************-->
34 <!-- erase common prefix from two uris -->
35 <!--***********************************************************************-->
37 <xsl:template name="common_prefix">
38 <xsl:param name="first_uri" select=""""/>
39 <xsl:param name="second_uri" select=""""/>
41 <xsl:when test="(substring-before($first_uri,"/") =
42 substring-before($second_uri,"/") and
43 substring-after($second_uri,"/") != "")">
44 <xsl:call-template name="common_prefix">
46 name="first_uri" select="substring-after($first_uri,"/")"/>
48 name="second_uri" select="substring-after($second_uri,"/")"/> </xsl:call-template>
51 <xsl:call-template name="slash_counting">
52 <xsl:with-param name="uri" select="$second_uri"/>
53 <xsl:with-param name="counter" select="0"/>
59 <xsl:template name="slash_counting">
60 <xsl:param name="uri" select=""""/>
61 <xsl:param name="counter" select="0"/>
63 <xsl:when test="(substring-after($uri,"/") != "")">
64 <xsl:call-template name="slash_counting">
66 name="uri" select="substring-after($uri,"/")"/>
68 name="counter" select="$counter +1"/>
72 <xsl:value-of select="$counter"/>
77 <xsl:template name="blank_counting">
78 <xsl:param name="string" select=""""/>
79 <xsl:param name="counter" select="0"/>
81 <xsl:when test="(substring-after($string," ") != "")">
82 <xsl:call-template name="blank_counting">
84 name="string" select="substring-after($string," ")"/>
86 name="counter" select="$counter +1"/>
90 <xsl:value-of select="$counter + 1"/>
95 <xsl:template name="double_point_counting">
96 <xsl:param name="string" select=""""/>
97 <xsl:param name="counter" select="0"/>
99 <xsl:when test="(substring-after($string,":") != "")">
100 <xsl:call-template name="double_point_counting">
102 name="string" select="substring-after($string,":")"/>
104 name="counter" select="$counter +1"/>
108 <xsl:value-of select="$counter"/>
113 <xsl:template name="min">
114 <xsl:param name="string" select=""""/>
115 <xsl:param name="counter" select="0"/>
117 <xsl:when test="contains($string,concat($counter,":"))
119 <xsl:value-of select="$counter"/>
122 <xsl:call-template name="min">
124 name="string" select="$string"/>
126 name="counter" select="$counter -1"/>
132 <xsl:template name="get_no_params">
133 <xsl:param name="first_uri" select=""""/>
134 <xsl:param name="second_uri" select=""""/>
135 <xsl:variable name="offset">
136 <xsl:call-template name="common_prefix">
137 <xsl:with-param name="first_uri" select="$first_uri"/>
138 <xsl:with-param name="second_uri" select="$second_uri"/>
142 <xsl:when test="$offset > 0">
143 <xsl:variable name="params">
145 select="document(concat(string($absPath),$second_uri))/*/@params"/>
147 <xsl:variable name="minimum">
148 <xsl:call-template name="min">
149 <xsl:with-param name="string" select="$params"/>
150 <xsl:with-param name="counter" select="$offset - 1"/>
154 <xsl:when test="0 > $minimum">
158 <xsl:variable name="relevant_params">
159 <!-- the blank after : in the next line is essential -->
161 select="substring-after($params,concat($minimum,": "))"/>
163 <xsl:variable name="tokens">
164 <xsl:call-template name="blank_counting">
165 <xsl:with-param name="string" select="$relevant_params"/>
166 <xsl:with-param name="counter" select="0"/>
169 <xsl:variable name="separators">
170 <xsl:call-template name="double_point_counting">
171 <xsl:with-param name="string" select="$relevant_params"/>
172 <xsl:with-param name="counter" select="0"/>
175 <xsl:value-of select="$tokens - $separators"/>