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"
28 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
30 xmlns:h="http://www.cs.unibo.it/helm/schemas/mattone.rdf#">
32 <xsl:output method="text"/>
34 <xsl:param name="CICURI" select="''"/>
35 <xsl:param name="PID" select="''"/>
36 <xsl:param name="getterURL" select="''"/>
37 <xsl:param name="uri_set_queueURL" select="''"/>
38 <xsl:param name="uri_set_size" select="30"/>
39 <xsl:variable name="base_URL_of_URI" select="concat($getterURL,'getxml?uri=')"/>
41 <!-- CSC: next functions because I don't remember the name of the -->
42 <!-- CSC: subst function of xslt and I don't have the specs with me -->
44 <!-- The next function is used to quote URIs for dotty -->
45 <xsl:template name="quote">
46 <xsl:param name="s" select="''"/>
47 <xsl:param name="news" select="''"/>
49 <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
51 <xsl:variable name="char" select="substring($s,1,1)"/>
53 <xsl:when test="$char = '/'">
54 <xsl:call-template name="quote">
55 <xsl:with-param name="s" select="substring($s,2)"/>
56 <xsl:with-param name="news" select="concat($news,'X')"/>
59 <xsl:when test="$char = ':'">
60 <xsl:call-template name="quote">
61 <xsl:with-param name="s" select="substring($s,2)"/>
62 <xsl:with-param name="news" select="concat($news,'Y')"/>
65 <xsl:when test="$char = '.'">
66 <xsl:call-template name="quote">
67 <xsl:with-param name="s" select="substring($s,2)"/>
68 <xsl:with-param name="news" select="concat($news,'Z')"/>
71 <xsl:when test='$char = "'"'>
72 <xsl:call-template name="quote">
73 <xsl:with-param name="s" select="substring($s,2)"/>
74 <xsl:with-param name="news" select="concat($news,'W')"/>
77 <xsl:when test="$char = '-'">
78 <xsl:call-template name="quote">
79 <xsl:with-param name="s" select="substring($s,2)"/>
80 <xsl:with-param name="news" select="concat($news,'J')"/>
83 <xsl:when test="$char = '#'">
84 <xsl:call-template name="quote">
85 <xsl:with-param name="s" select="substring($s,2)"/>
86 <xsl:with-param name="news" select="concat($news,'G')"/>
89 <xsl:when test="$char = '('">
90 <xsl:call-template name="quote">
91 <xsl:with-param name="s" select="substring($s,2)"/>
92 <xsl:with-param name="news" select="concat($news,'O')"/>
95 <xsl:when test="$char = ')'">
96 <xsl:call-template name="quote">
97 <xsl:with-param name="s" select="substring($s,2)"/>
98 <xsl:with-param name="news" select="concat($news,'C')"/>
102 <xsl:call-template name="quote">
103 <xsl:with-param name="s" select="substring($s,2)"/>
104 <xsl:with-param name="news" select="concat($news,$char)"/>
112 <!-- The next function is used to quote URIs to embed them in an URL -->
113 <xsl:template name="quote_url">
114 <xsl:param name="s" select="''"/>
115 <xsl:param name="news" select="''"/>
117 <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
119 <xsl:variable name="char" select="substring($s,1,1)"/>
121 <xsl:when test="$char = '#'">
122 <xsl:call-template name="quote_url">
123 <xsl:with-param name="s" select="substring($s,2)"/>
124 <xsl:with-param name="news" select="concat($news,'%23')"/>
128 <xsl:call-template name="quote_url">
129 <xsl:with-param name="s" select="substring($s,2)"/>
130 <xsl:with-param name="news" select="concat($news,$char)"/>
138 <xsl:template name="RDFURI_of_CICURI">
139 <xsl:param name="uri" select="''"/>
140 <xsl:variable name="before" select="substring-before($uri,'#xpointer(1/')"/>
141 <xsl:value-of select="$base_RDF_URI"/>
143 <xsl:when test="$before=''">
144 <xsl:value-of select="$uri"/>
147 <xsl:value-of select="concat($before,',')"/>
148 <xsl:variable name="after" select="substring-after($uri,'#xpointer(1/')"/>
149 <xsl:value-of select="translate(substring-before($after,')'),'/',',')"/>
154 <xsl:template match="/">
156 <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];
</xsl:text>
158 <xsl:text>strict digraph L0 { size = "83,83"; node [style=filled, shape = box];
</xsl:text>
159 <xsl:variable name="quoted_CICURI">
160 <xsl:call-template name="quote_url">
161 <xsl:with-param name="s" select="$CICURI"/>
164 <!-- The nonce is used to force the document reload -->
165 <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))"/>
166 <xsl:variable name="dummy1" select="document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_CICURI,'&nonce=',generate-id(),'&PID=',$PID))"/>
167 <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_CICURI,'&nonce=',generate-id(),'&PID=',$PID))"/>
168 <xsl:variable name="dummy2" select="document(concat($uri_set_queueURL,'reset_to_empty?PID=',$PID))"/>
169 <xsl:text>}</xsl:text>
172 <xsl:template mode="loop" match="empty"/>
174 <xsl:template mode="loop" match="uri|marked_uri">
175 <xsl:variable name="rdfuri">
176 <xsl:call-template name="RDFURI_of_CICURI">
177 <xsl:with-param name="uri" select="@value"/>
180 <xsl:variable name="document" select="document(concat($base_URL_of_URI,$rdfuri))"/>
182 <xsl:when test="$document/*">
183 <xsl:apply-templates mode="first_time" select="$document/*">
184 <xsl:with-param name="currentCICURI" select="@value"/>
185 <xsl:with-param name="quotedCurrentCICURI">
186 <xsl:call-template name="quote">
187 <xsl:with-param name="s" select="@value"/>
190 <xsl:with-param name="do_not_visit" select="name(.)"/>
191 </xsl:apply-templates>
194 <xsl:apply-templates mode="first_time" select=".">
195 <xsl:with-param name="currentCICURI" select="@value"/>
196 <xsl:with-param name="quotedCurrentCICURI">
197 <xsl:call-template name="quote">
198 <xsl:with-param name="s" select="@value"/>
201 <xsl:with-param name="do_not_visit" select="'no_deps'"/>
202 </xsl:apply-templates>
205 <xsl:variable name="quoted_value">
206 <xsl:call-template name="quote_url">
207 <xsl:with-param name="s" select="@value"/>
210 <!-- The couple (uri,nonce) is used to force the document reload -->
211 <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_value,'&nonce=',generate-id(),'&PID=',$PID))"/>
215 <xsl:template mode="first_time" match="*">
216 <xsl:param name="currentCICURI" select="''"/>
217 <xsl:param name="quotedCurrentCICURI" select="''"/>
218 <xsl:param name="do_not_visit" select="'uri'"/>
219 <xsl:if test="$do_not_visit='uri'">
220 <xsl:apply-templates select=".">
221 <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
222 <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
223 </xsl:apply-templates>
225 <xsl:text> </xsl:text>
226 <xsl:value-of select="$quotedCurrentCICURI"/>
227 <!-- <xsl:text> [fontname="LucidaSansRegular",color=red,label="</xsl:text> -->
228 <xsl:text> [label="</xsl:text>
229 <xsl:value-of select="$currentCICURI"/>
230 <xsl:text>",URL="</xsl:text>
231 <xsl:value-of select="$currentCICURI"/>
232 <xsl:text>"</xsl:text>
233 <xsl:if test="name(document(concat($uri_set_queueURL,'is_overflowed?uri=',$quotedCurrentCICURI,'&nonce=',generate-id(),'&PID=',$PID))/*)='true'">
234 <xsl:text>,color=red</xsl:text>
236 <xsl:text>];
</xsl:text>
239 <xsl:template match="*">
240 <xsl:param name="currentCICURI" select="''"/>
241 <xsl:param name="quotedCurrentCICURI" select="''"/>
242 <xsl:for-each select="*/*/*">
243 <xsl:variable name="quotedURI">
244 <xsl:call-template name="quote">
245 <xsl:with-param name="s" select="h:occurrence"/>
248 <xsl:variable name="quoted_uri">
249 <xsl:call-template name="quote_url">
250 <xsl:with-param name="s" select="h:occurrence"/>
253 <!-- The nonce, quotedCurrentCICURI are used to force the document reload -->
254 <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')">
255 <xsl:text> </xsl:text>
256 <xsl:value-of select="$quotedCurrentCICURI"/>
257 <xsl:text> -> </xsl:text>
258 <xsl:value-of select="$quotedURI"/>
259 <xsl:value-of select="$link_direction"/>
260 <xsl:text>;
</xsl:text>