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 <!-- CSC: Sostituire l'andata a capo con la entity numerica opportuna -->
33 <xsl:stylesheet version="0.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34 xmlns:ht="http://www.cs.unibo.it/helm/namespaces/helm-theory">
36 <xsl:output method="text"/>
38 <xsl:param name="CICURI" select="''"/>
39 <xsl:param name="PID" select="''"/>
40 <xsl:param name="getterURL" select="''"/>
41 <xsl:param name="uri_set_queueURL" select="''"/>
42 <xsl:param name="uri_set_size" select="30"/>
43 <xsl:variable name="base_URL_of_URI" select="concat($getterURL,'getxml?uri=')"/>
45 <!-- CSC: next functions because I don't remember the name of the -->
46 <!-- CSC: subst function of xslt and I don't have the specs with me -->
47 <xsl:template name="quote">
48 <xsl:param name="s" select="''"/>
49 <xsl:param name="news" select="''"/>
51 <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
53 <xsl:variable name="char" select="substring($s,1,1)"/>
55 <xsl:when test="$char = '/'">
56 <xsl:call-template name="quote">
57 <xsl:with-param name="s" select="substring($s,2)"/>
58 <xsl:with-param name="news" select="concat($news,'X')"/>
61 <xsl:when test="$char = ':'">
62 <xsl:call-template name="quote">
63 <xsl:with-param name="s" select="substring($s,2)"/>
64 <xsl:with-param name="news" select="concat($news,'Y')"/>
67 <xsl:when test="$char = '.'">
68 <xsl:call-template name="quote">
69 <xsl:with-param name="s" select="substring($s,2)"/>
70 <xsl:with-param name="news" select="concat($news,'Z')"/>
73 <xsl:when test='$char = "'"'>
74 <xsl:call-template name="quote">
75 <xsl:with-param name="s" select="substring($s,2)"/>
76 <xsl:with-param name="news" select="concat($news,'W')"/>
79 <xsl:when test="$char = '-'">
80 <xsl:call-template name="quote">
81 <xsl:with-param name="s" select="substring($s,2)"/>
82 <xsl:with-param name="news" select="concat($news,'J')"/>
85 <xsl:when test="$char = '#'">
86 <xsl:call-template name="quote">
87 <xsl:with-param name="s" select="substring($s,2)"/>
88 <xsl:with-param name="news" select="concat($news,'G')"/>
91 <xsl:when test="$char = '('">
92 <xsl:call-template name="quote">
93 <xsl:with-param name="s" select="substring($s,2)"/>
94 <xsl:with-param name="news" select="concat($news,'O')"/>
97 <xsl:when test="$char = ')'">
98 <xsl:call-template name="quote">
99 <xsl:with-param name="s" select="substring($s,2)"/>
100 <xsl:with-param name="news" select="concat($news,'C')"/>
104 <xsl:call-template name="quote">
105 <xsl:with-param name="s" select="substring($s,2)"/>
106 <xsl:with-param name="news" select="concat($news,$char)"/>
114 <!-- The next function is used to quote URIs to embed them in an URL -->
115 <xsl:template name="quote_url">
116 <xsl:param name="s" select="''"/>
117 <xsl:param name="news" select="''"/>
119 <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
121 <xsl:variable name="char" select="substring($s,1,1)"/>
123 <xsl:when test="$char = '#'">
124 <xsl:call-template name="quote_url">
125 <xsl:with-param name="s" select="substring($s,2)"/>
126 <xsl:with-param name="news" select="concat($news,'%23')"/>
130 <xsl:call-template name="quote_url">
131 <xsl:with-param name="s" select="substring($s,2)"/>
132 <xsl:with-param name="news" select="concat($news,$char)"/>
140 <xsl:template name="removeXPointer">
141 <xsl:param name="uri" select="''"/>
142 <xsl:variable name="before" select="substring-before($uri,'#xpointer')"/>
144 <xsl:when test="$before=''">
145 <xsl:value-of select="$uri"/>
148 <xsl:value-of select="$before"/>
153 <!-- CSC: Next function has been copied from -->
154 <!-- CSC: metadata/xslt/occurrences.xsl and modified -->
155 <xsl:template name="get_expanded_name">
156 <xsl:param name="node" select="/.."/>
158 <xsl:when test="name($node)='CONST'">
159 <xsl:value-of select="$node/@uri"/>
161 <xsl:when test="name($node)='MUTIND'">
162 <xsl:variable name="noType" select="$node/@noType + 1"/>
163 <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
166 <xsl:when test="name($node)='MUTCONSTRUCT'">
167 <xsl:variable name="noType" select="$node/@noType + 1"/>
168 <xsl:value-of select="concat($node/@uri,'#','xpointer(1/',
169 $noType,'/',$node/@noConstr,')')"/>
172 <!-- CSC: Is it possible to reach this branch? -->
173 <xsl:value-of select="$node/@uri"/>
179 <xsl:template match="/">
181 <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];&CSCbr;</xsl:text>
183 <xsl:text>strict digraph L0 { size = "83,83"; node [style=filled, shape = box];&CSCbr;</xsl:text>
184 <xsl:variable name="quoted_CICURI">
185 <xsl:call-template name="quote_url">
186 <xsl:with-param name="s" select="$CICURI"/>
189 <!-- The nonce is used to force the document reload -->
190 <xsl:variable name="dummy0" select="document(concat($uri_set_queueURL,'set_uri_set_size?uri=',$quoted_CICURI,'&nonce=',generate-id(),'&PID=',$PID,'&size=',$uri_set_size))"/>
191 <xsl:variable name="dummy1" select="document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_CICURI,'&nonce=',generate-id(),'&PID=',$PID))"/>
192 <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_CICURI,'&nonce=',generate-id(),'&PID=',$PID))"/>
193 <xsl:variable name="dummy2" select="document(concat($uri_set_queueURL,'reset_to_empty?PID=',$PID))"/>
194 <xsl:text>}</xsl:text>
197 <xsl:template mode="loop" match="empty"/>
199 <xsl:template mode="loop" match="uri|marked_uri">
200 <xsl:variable name="rawuri">
201 <xsl:call-template name="removeXPointer">
202 <xsl:with-param name="uri" select="@value"/>
205 <xsl:apply-templates mode="first_time" select="document(concat($base_URL_of_URI,$rawuri))/*">
206 <xsl:with-param name="currentCICURI" select="@value"/>
207 <xsl:with-param name="quotedCurrentCICURI">
208 <xsl:call-template name="quote">
209 <xsl:with-param name="s" select="@value"/>
212 <xsl:with-param name="do_not_visit" select="name(.)"/>
213 </xsl:apply-templates>
214 <xsl:variable name="quoted_value">
215 <xsl:call-template name="quote_url">
216 <xsl:with-param name="s" select="@value"/>
219 <!-- The couple (uri,nonce) is used to force the document reload -->
220 <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_value,'&nonce=',generate-id(),'&PID=',$PID))"/>
223 <xsl:template mode="first_time" match="*">
224 <xsl:param name="currentCICURI" select="''"/>
225 <xsl:param name="quotedCurrentCICURI" select="''"/>
226 <xsl:param name="do_not_visit" select="'uri'"/>
227 <xsl:if test="$do_not_visit='uri'">
228 <xsl:apply-templates select=".">
229 <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
230 <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
231 </xsl:apply-templates>
233 <xsl:text> </xsl:text>
234 <xsl:value-of select="$quotedCurrentCICURI"/>
235 <!-- <xsl:text> [fontname="LucidaSansRegular",color=red,label="</xsl:text> -->
236 <xsl:text> [label="</xsl:text>
237 <xsl:value-of select="$currentCICURI"/>
238 <xsl:text>",URL="</xsl:text>
239 <xsl:value-of select="$currentCICURI"/>
240 <xsl:text>"</xsl:text>
241 <xsl:if test="name(document(concat($uri_set_queueURL,'is_overflowed?uri=',$quotedCurrentCICURI,'&nonce=',generate-id(),'&PID=',$PID))/*)='true'">
242 <xsl:text>,color=red</xsl:text>
244 <xsl:text>];&CSCbr;</xsl:text>
247 <!-- CSC: uriType missing!!! -->
248 <xsl:template match="*">
249 <xsl:param name="currentCICURI" select="''"/>
250 <xsl:param name="quotedCurrentCICURI" select="''"/>
252 <xsl:variable name="quotedURI">
253 <xsl:call-template name="quote">
254 <xsl:with-param name="s">
255 <xsl:call-template name="get_expanded_name">
256 <xsl:with-param name="node" select="."/>
261 <xsl:variable name="quoted_uri">
262 <xsl:call-template name="quote_url">
263 <xsl:with-param name="s">
264 <xsl:call-template name="get_expanded_name">
265 <xsl:with-param name="node" select="."/>
270 <!-- The nonce, quotedCurrentCICURI are used to force the document reload -->
271 <xsl:if test="not(name(document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_uri,'&nonce=',generate-id(),'&PID=',$PID,'&quotedCurrentCICURI=',$quotedCurrentCICURI))/*)='not_added_because_already_too_many')">
272 <xsl:text> </xsl:text>
273 <xsl:value-of select="$quotedCurrentCICURI"/>
274 <xsl:text> -> </xsl:text>
275 <xsl:value-of select="$quotedURI"/>
276 <xsl:text>;&CSCbr;</xsl:text>
279 <xsl:apply-templates>
280 <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
281 <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
282 </xsl:apply-templates>
285 <xsl:template match="text()"/>