]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mk_meta_graph.xsl
0f6acba1dcbafcfa768d70529d21b8d36e48a8c3
[helm.git] / helm / style / mk_meta_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="'http://localhost:8084/'"/>
42 <xsl:param name="uri_set_size" select="30"/>
43 <xsl:variable name="RDF_base_URL_of_CIC_URI" select="concat($getterURL,'getxml?uri=helm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//')"/>
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
48 <!-- The next function is used to quote URIs for dotty -->
49 <xsl:template name="quote">
50  <xsl:param name="s" select="''"/>
51  <xsl:param name="news" select="''"/>
52  <xsl:choose>
53   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
54   <xsl:otherwise>
55    <xsl:variable name="char" select="substring($s,1,1)"/>
56    <xsl:choose>
57     <xsl:when test="$char = '/'">
58      <xsl:call-template name="quote">
59       <xsl:with-param name="s" select="substring($s,2)"/>
60       <xsl:with-param name="news" select="concat($news,'X')"/>
61      </xsl:call-template>
62     </xsl:when>
63     <xsl:when test="$char = ':'">
64      <xsl:call-template name="quote">
65       <xsl:with-param name="s" select="substring($s,2)"/>
66       <xsl:with-param name="news" select="concat($news,'Y')"/>
67      </xsl:call-template>
68     </xsl:when>
69     <xsl:when test="$char = '.'">
70      <xsl:call-template name="quote">
71       <xsl:with-param name="s" select="substring($s,2)"/>
72       <xsl:with-param name="news" select="concat($news,'Z')"/>
73      </xsl:call-template>
74     </xsl:when>
75     <xsl:when test='$char = "&apos;"'>
76      <xsl:call-template name="quote">
77       <xsl:with-param name="s" select="substring($s,2)"/>
78       <xsl:with-param name="news" select="concat($news,'W')"/>
79      </xsl:call-template>
80     </xsl:when>
81     <xsl:when test="$char = '-'">
82      <xsl:call-template name="quote">
83       <xsl:with-param name="s" select="substring($s,2)"/>
84       <xsl:with-param name="news" select="concat($news,'J')"/>
85      </xsl:call-template>
86     </xsl:when>
87     <xsl:when test="$char = '#'">
88      <xsl:call-template name="quote">
89       <xsl:with-param name="s" select="substring($s,2)"/>
90       <xsl:with-param name="news" select="concat($news,'G')"/>
91      </xsl:call-template>
92     </xsl:when>
93     <xsl:when test="$char = '('">
94      <xsl:call-template name="quote">
95       <xsl:with-param name="s" select="substring($s,2)"/>
96       <xsl:with-param name="news" select="concat($news,'O')"/>
97      </xsl:call-template>
98     </xsl:when>
99     <xsl:when test="$char = ')'">
100      <xsl:call-template name="quote">
101       <xsl:with-param name="s" select="substring($s,2)"/>
102       <xsl:with-param name="news" select="concat($news,'C')"/>
103      </xsl:call-template>
104     </xsl:when>
105     <xsl:otherwise>
106      <xsl:call-template name="quote">
107       <xsl:with-param name="s" select="substring($s,2)"/>
108       <xsl:with-param name="news" select="concat($news,$char)"/>
109      </xsl:call-template>
110     </xsl:otherwise>
111    </xsl:choose>
112   </xsl:otherwise>
113  </xsl:choose>
114 </xsl:template>
115
116 <!-- The next function is used to quote URIs to embed them in an URL -->
117 <xsl:template name="quote_url">
118  <xsl:param name="s" select="''"/>
119  <xsl:param name="news" select="''"/>
120  <xsl:choose>
121   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
122   <xsl:otherwise>
123    <xsl:variable name="char" select="substring($s,1,1)"/>
124    <xsl:choose>
125     <xsl:when test="$char = '#'">
126      <xsl:call-template name="quote_url">
127       <xsl:with-param name="s" select="substring($s,2)"/>
128       <xsl:with-param name="news" select="concat($news,'%23')"/>
129      </xsl:call-template>
130     </xsl:when>
131     <xsl:otherwise>
132      <xsl:call-template name="quote_url">
133       <xsl:with-param name="s" select="substring($s,2)"/>
134       <xsl:with-param name="news" select="concat($news,$char)"/>
135      </xsl:call-template>
136     </xsl:otherwise>
137    </xsl:choose>
138   </xsl:otherwise>
139  </xsl:choose>
140 </xsl:template>
141
142 <xsl:template match="/">
143  <!--
144  <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];&CSCbr;</xsl:text>
145  -->
146  <xsl:text>strict digraph L0 { size = "83,83"; node [style=filled, shape = box];&CSCbr;</xsl:text>
147  <xsl:variable name="quoted_CICURI">
148   <xsl:call-template name="quote_url">
149    <xsl:with-param name="s" select="$CICURI"/>
150   </xsl:call-template>
151  </xsl:variable>
152  <!-- The nonce is used to force the document reload -->
153  <xsl:variable name="dummy0" select="document(concat($uri_set_queueURL,'set_uri_set_size?uri=',$CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID,'&amp;size=',$uri_set_size))"/>
154  <xsl:variable name="dummy1" select="document(concat($uri_set_queueURL,'add_if_not_in?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
155  <xsl:apply-templates mode="loop" select="document(concat($uri_set_queueURL,'get_next?uri=',$quoted_CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
156  <xsl:variable name="dummy2" select="document(concat($uri_set_queueURL,'reset_to_empty?PID=',$PID))"/>
157  <xsl:text>}</xsl:text>
158 </xsl:template>
159
160 <xsl:template mode="loop" match="empty"/>
161
162 <xsl:template mode="loop" match="uri|marked_uri">
163  <xsl:variable name="document" select="document(concat($RDF_base_URL_of_CIC_URI,@value))"/>
164  <xsl:choose>
165   <xsl:when test="$document/*">
166    <xsl:apply-templates mode="first_time" select="$document/*">
167     <xsl:with-param name="currentCICURI" select="@value"/>
168     <xsl:with-param name="quotedCurrentCICURI">
169      <xsl:call-template name="quote">
170       <xsl:with-param name="s" select="@value"/>
171      </xsl:call-template>
172     </xsl:with-param>
173     <xsl:with-param name="do_not_visit" select="name(.)"/>
174    </xsl:apply-templates>
175   </xsl:when>
176   <xsl:otherwise>
177    <xsl:apply-templates mode="first_time" select=".">
178     <xsl:with-param name="currentCICURI" select="@value"/>
179     <xsl:with-param name="quotedCurrentCICURI">
180      <xsl:call-template name="quote">
181       <xsl:with-param name="s" select="@value"/>
182      </xsl:call-template>
183     </xsl:with-param>
184     <xsl:with-param name="do_not_visit" select="'no_deps'"/>
185    </xsl:apply-templates>
186   </xsl:otherwise>
187  </xsl:choose>
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
198 <xsl:template mode="first_time" match="*">
199  <xsl:param name="currentCICURI" select="''"/>
200  <xsl:param name="quotedCurrentCICURI" select="''"/>
201  <xsl:param name="do_not_visit" select="'uri'"/>
202  <xsl:if test="$do_not_visit='uri'">
203   <xsl:apply-templates select=".">
204    <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
205    <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
206   </xsl:apply-templates>
207  </xsl:if>
208  <xsl:text> </xsl:text>
209  <xsl:value-of select="$quotedCurrentCICURI"/>
210 <!-- <xsl:text> [fontname="LucidaSansRegular",color=red,label="</xsl:text> -->
211  <xsl:text> [label="</xsl:text>
212  <xsl:value-of select="$currentCICURI"/>
213  <xsl:text>",URL="</xsl:text>
214  <xsl:value-of select="$currentCICURI"/>
215  <xsl:text>"</xsl:text>
216  <xsl:if test="name(document(concat($uri_set_queueURL,'is_overflowed?uri=',$quotedCurrentCICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))/*)='true'">
217   <xsl:text>,color=red</xsl:text>
218  </xsl:if>
219  <xsl:text>];&CSCbr;</xsl:text>
220 </xsl:template>
221
222 <xsl:template match="occurs">
223  <xsl:param name="currentCICURI" select="''"/>
224  <xsl:param name="quotedCurrentCICURI" select="''"/>
225  <xsl:for-each select="*">
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  <xsl:variable name="quoted_uri">
232   <xsl:call-template name="quote_url">
233    <xsl:with-param name="s" select="@uri"/>
234   </xsl:call-template>
235  </xsl:variable>
236   <!-- The nonce, quotedCurrentCICURI are used to force the document reload -->
237   <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')">
238    <xsl:text> </xsl:text>
239    <xsl:value-of select="$quotedCurrentCICURI"/>
240    <xsl:text> -&gt; </xsl:text>
241    <xsl:value-of select="$quotedURI"/>
242    <xsl:text>;&CSCbr;</xsl:text>
243   </xsl:if>
244  </xsl:for-each>
245 </xsl:template>
246
247 </xsl:stylesheet>