]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mk_dep_graph.xsl
Bug removed/Feature changed: CIC URIs for inductive data types
[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 <xsl:template match="/">
154  <!--
155  <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];&CSCbr;</xsl:text>
156  -->
157  <xsl:text>strict digraph L0 { size = "83,83"; node [style=filled, shape = box];&CSCbr;</xsl:text>
158  <xsl:variable name="quoted_CICURI">
159   <xsl:call-template name="quote_url">
160    <xsl:with-param name="s" select="$CICURI"/>
161   </xsl:call-template>
162  </xsl:variable>
163  <!-- The nonce is used to force the document reload -->
164  <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))"/>
165  <xsl:variable name="dummy1" select="document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
166  <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
167  <xsl:variable name="dummy2" select="document(concat($uri_set_queueURL,'reset_to_empty?PID=',$PID))"/>
168  <xsl:text>}</xsl:text>
169 </xsl:template>
170
171 <xsl:template mode="loop" match="empty"/>
172
173 <xsl:template mode="loop" match="uri|marked_uri">
174  <xsl:variable name="rawuri">
175   <xsl:call-template name="removeXPointer">
176    <xsl:with-param name="uri" select="@value"/>
177   </xsl:call-template>
178  </xsl:variable>
179  <xsl:apply-templates mode="first_time" select="document(concat($base_URL_of_URI,$rawuri))/*">
180   <xsl:with-param name="currentCICURI" select="@value"/>
181   <xsl:with-param name="quotedCurrentCICURI">
182    <xsl:call-template name="quote">
183     <xsl:with-param name="s" select="@value"/>
184    </xsl:call-template>
185   </xsl:with-param>
186   <xsl:with-param name="do_not_visit" select="name(.)"/>
187  </xsl:apply-templates>
188  <xsl:variable name="quoted_value">
189   <xsl:call-template name="quote_url">
190    <xsl:with-param name="s" select="@value"/>
191   </xsl:call-template>
192  </xsl:variable>
193  <!-- The couple (uri,nonce) is used to force the document reload -->
194  <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_value,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
195 </xsl:template>
196
197 <xsl:template mode="first_time" match="*">
198  <xsl:param name="currentCICURI" select="''"/>
199  <xsl:param name="quotedCurrentCICURI" select="''"/>
200  <xsl:param name="do_not_visit" select="'uri'"/>
201  <xsl:if test="$do_not_visit='uri'">
202   <xsl:apply-templates select=".">
203    <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
204    <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
205   </xsl:apply-templates>
206  </xsl:if>
207  <xsl:text> </xsl:text>
208  <xsl:value-of select="$quotedCurrentCICURI"/>
209 <!-- <xsl:text> [fontname="LucidaSansRegular",color=red,label="</xsl:text> -->
210  <xsl:text> [label="</xsl:text>
211  <xsl:value-of select="$currentCICURI"/>
212  <xsl:text>",URL="</xsl:text>
213  <xsl:value-of select="$currentCICURI"/>
214  <xsl:text>"</xsl:text>
215  <xsl:if test="name(document(concat($uri_set_queueURL,'is_overflowed?uri=',$quotedCurrentCICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))/*)='true'">
216   <xsl:text>,color=red</xsl:text>
217  </xsl:if>
218  <xsl:text>];&CSCbr;</xsl:text>
219 </xsl:template>
220
221 <!-- CSC: uriType missing!!! -->
222 <xsl:template match="*">
223  <xsl:param name="currentCICURI" select="''"/>
224  <xsl:param name="quotedCurrentCICURI" select="''"/>
225  <xsl:if test="@uri">
226   <xsl:variable name="quotedURI">
227    <xsl:call-template name="quote">
228     <xsl:with-param name="s" select="@uri"/>
229    </xsl:call-template>
230   </xsl:variable>
231   <!-- The nonce, quotedCurrentCICURI are used to force the document reload -->
232   <xsl:if test="not(name(document(concat($uri_set_queueURL,'add_if_not_in?uri=',@uri,'&amp;nonce=',generate-id(),'&amp;PID=',$PID,'&amp;quotedCurrentCICURI=',$quotedCurrentCICURI))/*)='not_added_because_already_too_many')">
233    <xsl:text> </xsl:text>
234    <xsl:value-of select="$quotedCurrentCICURI"/>
235    <xsl:text> -&gt; </xsl:text>
236    <xsl:value-of select="$quotedURI"/>
237    <xsl:text>;&CSCbr;</xsl:text>
238   </xsl:if>
239  </xsl:if>
240  <xsl:apply-templates>
241   <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
242   <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
243  </xsl:apply-templates>
244 </xsl:template>
245
246 <xsl:template match="text()"/>
247 </xsl:stylesheet>