]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mk_meta_graph.xsl
First implementation of graphs stuff. Working on my notebook,
[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="maxDepth" select="5"/>
41 <xsl:param name="getterURL" select="''"/>
42 <xsl:variable name="RDF_base_URL_of_CIC_URI" select="concat($getterURL,'getxml?uri=helm:rdf:www.cs.unibo.it/helm/rdf/rdfprova//')"/>
43
44 <!-- CSC: next function because I don't remember the name of the    -->
45 <!-- CSC: subst function of xslt and I don't have the specs with me -->
46 <xsl:template name="quote">
47  <xsl:param name="s" select="''"/>
48  <xsl:param name="news" select="''"/>
49  <xsl:choose>
50   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
51   <xsl:otherwise>
52    <xsl:variable name="char" select="substring($s,1,1)"/>
53    <xsl:choose>
54     <xsl:when test="$char = '/'">
55      <xsl:call-template name="quote">
56       <xsl:with-param name="s" select="substring($s,2)"/>
57       <xsl:with-param name="news" select="concat($news,'X')"/>
58      </xsl:call-template>
59     </xsl:when>
60     <xsl:when test="$char = ':'">
61      <xsl:call-template name="quote">
62       <xsl:with-param name="s" select="substring($s,2)"/>
63       <xsl:with-param name="news" select="concat($news,'Y')"/>
64      </xsl:call-template>
65     </xsl:when>
66     <xsl:when test="$char = '.'">
67      <xsl:call-template name="quote">
68       <xsl:with-param name="s" select="substring($s,2)"/>
69       <xsl:with-param name="news" select="concat($news,'Z')"/>
70      </xsl:call-template>
71     </xsl:when>
72     <xsl:when test='$char = "&apos;"'>
73      <xsl:call-template name="quote">
74       <xsl:with-param name="s" select="substring($s,2)"/>
75       <xsl:with-param name="news" select="concat($news,'W')"/>
76      </xsl:call-template>
77     </xsl:when>
78     <xsl:when test="$char = '-'">
79      <xsl:call-template name="quote">
80       <xsl:with-param name="s" select="substring($s,2)"/>
81       <xsl:with-param name="news" select="concat($news,'J')"/>
82      </xsl:call-template>
83     </xsl:when>
84     <xsl:otherwise>
85      <xsl:call-template name="quote">
86       <xsl:with-param name="s" select="substring($s,2)"/>
87       <xsl:with-param name="news" select="concat($news,$char)"/>
88      </xsl:call-template>
89     </xsl:otherwise>
90    </xsl:choose>
91   </xsl:otherwise>
92  </xsl:choose>
93 </xsl:template>
94
95 <xsl:template match="/">
96  <!-- dep_url_scheme -->
97  <xsl:text>http://localhost:8083/draw?url=http%3A//localhost%3A8080/helm/servlet/uwobo/apply%3Fxmluri%3Dhttp%3A//localhost%3A8081/getxml%253Furi%253D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>%26keys%3DMDG%26param.getterURL%3Dhttp%253A//localhost%253A8081/%26prop.media-type%3Dtext/plain%26param.CICURI%3D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>&CSCbr;</xsl:text>
98  <!-- meta_url_scheme -->
99  <xsl:text>http://localhost:8083/draw?url=http%3A%2F%2Flocalhost%3A8080%2Fhelm%2Fservlet%2Fuwobo%2Fapply%3Fxmluri%3Dhttp%3A%2F%2Flocalhost%3A8081%2Fgetxml%253Furi%253Dhelm%3Ardf%3Awww%2Ecs%2Eunibo.it/helm/rdf/rdfprova//</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>%26keys%3DMMG%26param.getterURL%3Dhttp%253A//localhost%253A8081/%26prop.media-type%3Dtext/plain%26param.CICURI%3D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>%26keys%3DMMG%26param%2EgetterURL%3Dhttp%253A%2F%2Flocalhost%253A8081%2F%26prop%2Emedia%2Dtype%3Dtext%2Fplain%26param%2ECICURI%3D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>&CSCbr;</xsl:text>
100  <!-- cic_url_scheme -->
101  <xsl:text>file:///projects/helm/on-line/html/cic/index.html?url=http://localhost:8080/helm/servlet/uwobo/apply%3Fkeys%3DC1%252CHC2%252CL%26prop.media-type%3Dtext/html%26prop.encoding%3Diso-8859-1%26param.naturalLanguage%3Dyes%26param.UNICODEvsSYMBOL%3Dsymbol%26param.annotations%3DNO%26prop.doctype-public%3D-//W3C//DTD%2520XHTML%25201.0%2520Transitional//EN%26param.doctype-public%3D-//W3C//DTD%2520XHTML%25201.0%2520Transitional//EN%26param.encoding%3Diso-8859-1%26param.media-type%3Dtext/html%26param.keys%3DC1%252CHC2%252CL%26param.getterURL%3Dhttp://localhost:8081/%26param.processorURL%3Dhttp://localhost:8080/helm/servlet/uwobo/%26param.interfaceURL%3Dfile:///projects/helm/on-line/html/cic/index.html%26param.topurl%3Dfile:///projects/helm/on-line%26xmluri%3Dhttp://localhost:8081/getxml%253Furi%253D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>%26param.CICURI%3D</xsl:text><xsl:value-of select="'#uri#'"/><xsl:text>&CSCbr;</xsl:text>
102  <!--
103  <xsl:text>strict digraph L0 { size = "83,83"; concentrate=true; node [style=filled, shape = box];&CSCbr;</xsl:text>
104  -->
105  <xsl:text>strict digraph L0 { size = "83,83"; node [style=filled, shape = box];&CSCbr;</xsl:text>
106  <xsl:variable name="dummy1" select="document(concat('http://localhost:8084/add_if_not_in?uri=',$CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
107  <xsl:apply-templates mode="loop" select="document(concat('http://localhost:8084/get_next?uri=',$CICURI,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
108  <xsl:variable name="dummy2" select="document(concat('http://localhost:8084/reset_to_empty?PID=',$PID))"/>
109  <xsl:text>}</xsl:text>
110 </xsl:template>
111
112 <xsl:template mode="loop" match="empty"/>
113
114 <xsl:template mode="loop" match="uri|marked_uri">
115  <xsl:variable name="document" select="document(concat($RDF_base_URL_of_CIC_URI,@value))"/>
116  <xsl:choose>
117   <xsl:when test="$document/*">
118    <xsl:apply-templates mode="first_time" select="$document/*">
119     <xsl:with-param name="currentCICURI" select="@value"/>
120     <xsl:with-param name="quotedCurrentCICURI">
121      <xsl:call-template name="quote">
122       <xsl:with-param name="s" select="@value"/>
123      </xsl:call-template>
124     </xsl:with-param>
125     <xsl:with-param name="do_not_visit" select="name(.)"/>
126    </xsl:apply-templates>
127   </xsl:when>
128   <xsl:otherwise>
129    <xsl:apply-templates mode="first_time" select=".">
130     <xsl:with-param name="currentCICURI" select="@value"/>
131     <xsl:with-param name="quotedCurrentCICURI">
132      <xsl:call-template name="quote">
133       <xsl:with-param name="s" select="@value"/>
134      </xsl:call-template>
135     </xsl:with-param>
136     <xsl:with-param name="do_not_visit" select="'no_deps'"/>
137    </xsl:apply-templates>
138   </xsl:otherwise>
139  </xsl:choose>
140  <!-- The couple (uri,nonce) is used to force the document reload -->
141  <xsl:apply-templates mode="loop" select="document(concat('http://localhost:8084/get_next?uri=',@value,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
142 </xsl:template>
143
144
145 <xsl:template mode="first_time" match="*">
146  <xsl:param name="currentCICURI" select="''"/>
147  <xsl:param name="quotedCurrentCICURI" select="''"/>
148  <xsl:param name="do_not_visit" select="'uri'"/>
149  <xsl:text> </xsl:text>
150  <xsl:value-of select="$quotedCurrentCICURI"/>
151 <!-- <xsl:text> [fontname="LucidaSansRegular",color=red,label="</xsl:text> -->
152  <xsl:text> [label="</xsl:text>
153  <xsl:value-of select="$currentCICURI"/>
154  <xsl:text>",URL="</xsl:text>
155  <xsl:value-of select="$currentCICURI"/>
156  <xsl:text>"</xsl:text>
157  <xsl:if test="$do_not_visit='marked_uri'">
158   <xsl:text>,color=red</xsl:text>
159  </xsl:if>
160  <xsl:text>];&CSCbr;</xsl:text>
161  <xsl:if test="$do_not_visit='uri'">
162   <xsl:apply-templates select=".">
163    <xsl:with-param name="maxDepth" select="$newMaxDepth"/>
164    <xsl:with-param name="currentCICURI" select="$currentCICURI"/>
165    <xsl:with-param name="quotedCurrentCICURI" select="$quotedCurrentCICURI"/>
166   </xsl:apply-templates>
167  </xsl:if>
168 </xsl:template>
169
170 <xsl:template match="occurs">
171  <xsl:param name="maxDepth" select="''"/>
172  <xsl:param name="currentCICURI" select="''"/>
173  <xsl:param name="quotedCurrentCICURI" select="''"/>
174  <xsl:for-each select="*">
175   <xsl:variable name="quotedURI">
176    <xsl:call-template name="quote">
177     <xsl:with-param name="s" select="@uri"/>
178    </xsl:call-template>
179   </xsl:variable>
180   <xsl:text> </xsl:text>
181   <xsl:value-of select="$quotedCurrentCICURI"/>
182   <xsl:text> -&gt; </xsl:text>
183   <xsl:value-of select="$quotedURI"/>
184   <xsl:text>;&CSCbr;</xsl:text>
185   <!-- The nonce is used to force the document reload -->
186   <xsl:variable name="dummy" select="document(concat('http://localhost:8084/add_if_not_in?uri=',@uri,'&amp;nonce=',generate-id(),'&amp;PID=',$PID))"/>
187  </xsl:for-each>
188 </xsl:template>
189
190 </xsl:stylesheet>