]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mk_dep_graph.xsl
mk_dep_graph.xsl now differentiates the constructors from the
[helm.git] / helm / style / mk_dep_graph.xsl
1 <?xml version="1.0"?>
2
3 <!-- Copyright (C) 2000, HELM Team                                     -->
4 <!--                                                                   -->
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.                         -->
8 <!--                                                                   -->
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.            -->
13 <!--                                                                   -->
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.                      -->
18 <!--                                                                   -->
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.                                              -->
23 <!--                                                                   -->
24 <!-- For details, see the HELM World-Wide-Web page,                    -->
25 <!-- http://cs.unibo.it/helm/.                                         -->
26
27 <!-- CSC: Sostituire l'andata a capo con la entity numerica opportuna -->
28 <!DOCTYPE html [
29  <!ENTITY CSCbr "
30 ">
31 ]>
32
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">
35
36 <xsl:output method="text"/>
37
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=')"/>
44
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="''"/>
50  <xsl:choose>
51   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
52   <xsl:otherwise>
53    <xsl:variable name="char" select="substring($s,1,1)"/>
54    <xsl:choose>
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')"/>
59      </xsl:call-template>
60     </xsl:when>
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')"/>
65      </xsl:call-template>
66     </xsl:when>
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')"/>
71      </xsl:call-template>
72     </xsl:when>
73     <xsl:when test='$char = "&apos;"'>
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')"/>
77      </xsl:call-template>
78     </xsl:when>
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')"/>
83      </xsl:call-template>
84     </xsl:when>
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')"/>
89      </xsl:call-template>
90     </xsl:when>
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')"/>
95      </xsl:call-template>
96     </xsl:when>
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')"/>
101      </xsl:call-template>
102     </xsl:when>
103     <xsl:otherwise>
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)"/>
107      </xsl:call-template>
108     </xsl:otherwise>
109    </xsl:choose>
110   </xsl:otherwise>
111  </xsl:choose>
112 </xsl:template>
113
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="''"/>
118  <xsl:choose>
119   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
120   <xsl:otherwise>
121    <xsl:variable name="char" select="substring($s,1,1)"/>
122    <xsl:choose>
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')"/>
127      </xsl:call-template>
128     </xsl:when>
129     <xsl:otherwise>
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)"/>
133      </xsl:call-template>
134     </xsl:otherwise>
135    </xsl:choose>
136   </xsl:otherwise>
137  </xsl:choose>
138 </xsl:template>
139
140 <xsl:template name="removeXPointer">
141  <xsl:param name="uri" select="''"/>
142  <xsl:variable name="before" select="substring-before($uri,'#xpointer')"/>
143  <xsl:choose>
144   <xsl:when test="$before=''">
145    <xsl:value-of select="$uri"/>
146   </xsl:when>
147   <xsl:otherwise>
148    <xsl:value-of select="$before"/>
149   </xsl:otherwise>
150  </xsl:choose>
151 </xsl:template>
152
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="/.."/>
157     <xsl:choose>
158      <xsl:when test="name($node)='CONST'">
159       <xsl:value-of select="$node/@uri"/>
160      </xsl:when>
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/',
164             $noType,')')"/>
165      </xsl:when>
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,')')"/>
170      </xsl:when>
171      <xsl:otherwise>
172       <!-- CSC: Is it possible to reach this branch? -->
173       <xsl:value-of select="$node/@uri"/>
174      </xsl:otherwise>
175     </xsl:choose>
176 </xsl:template> 
177
178
179 <xsl:template match="/">
180  <!--
181  <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];&CSCbr;</xsl:text>
182  -->
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"/>
187   </xsl:call-template>
188  </xsl:variable>
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,'&amp;nonce=',generate-id(),'&amp;PID=',$PID,'&amp;size=',$uri_set_size))"/>
191  <xsl:variable name="dummy1" select="document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
192  <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
193  <xsl:variable name="dummy2" select="document(concat($uri_set_queueURL,'reset_to_empty?PID=',$PID))"/>
194  <xsl:text>}</xsl:text>
195 </xsl:template>
196
197 <xsl:template mode="loop" match="empty"/>
198
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"/>
203   </xsl:call-template>
204  </xsl:variable>
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"/>
210    </xsl:call-template>
211   </xsl:with-param>
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"/>
217   </xsl:call-template>
218  </xsl:variable>
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,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
221 </xsl:template>
222
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>
232  </xsl:if>
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,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))/*)='true'">
242   <xsl:text>,color=red</xsl:text>
243  </xsl:if>
244  <xsl:text>];&CSCbr;</xsl:text>
245 </xsl:template>
246
247 <!-- CSC: uriType missing!!! -->
248 <xsl:template match="*">
249  <xsl:param name="currentCICURI" select="''"/>
250  <xsl:param name="quotedCurrentCICURI" select="''"/>
251  <xsl:if test="@uri">
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="."/>
257      </xsl:call-template>
258     </xsl:with-param>
259    </xsl:call-template>
260   </xsl:variable>
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="."/>
266      </xsl:call-template>
267     </xsl:with-param>
268    </xsl:call-template>
269   </xsl:variable>
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,'&amp;nonce=',generate-id(),'&amp;PID=',$PID,'&amp;quotedCurrentCICURI=',$quotedCurrentCICURI))/*)='not_added_because_already_too_many')">
272    <xsl:text> </xsl:text>
273    <xsl:value-of select="$quotedCurrentCICURI"/>
274    <xsl:text> -&gt; </xsl:text>
275    <xsl:value-of select="$quotedURI"/>
276    <xsl:text>;&CSCbr;</xsl:text>
277   </xsl:if>
278  </xsl:if>
279  <xsl:apply-templates>
280   <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
281   <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
282  </xsl:apply-templates>
283 </xsl:template>
284
285 <xsl:template match="text()"/>
286 </xsl:stylesheet>