]> matita.cs.unibo.it Git - helm.git/blob - helm/on-line/xslt/makeGraphLinks.xsl
metadataLib2.xsl renamed makeGraphLinks.xsl and committed.
[helm.git] / helm / on-line / xslt / makeGraphLinks.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 <xsl:stylesheet version="1.0"
28  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29  xmlns:subst="http://www.cs.unibo.it/helm/subst">
30
31 <xsl:param name="uri_set_size" select="'30'"/>
32
33 <xsl:output method="html" encoding="iso-8859-1"/>
34
35 <xsl:template match="/|*">
36   <xsl:copy>
37    <xsl:copy-of select="@*"/>
38    <xsl:apply-templates/>
39   </xsl:copy>
40 </xsl:template>
41
42 <xsl:template match="head">
43   <xsl:copy>
44    <xsl:copy-of select="@*"/>
45    <subst:script language="JavaScript" src="/javascript/defaults.js"/>
46    <subst:script language="JavaScript" src="/javascript/utils.js"/>
47    <subst:script language="JavaScript" src="/javascript/control.js"/>
48    <script language="JavaScript" type="text/javascript">
49     <!-- topurl will be used by the code in jsmenu/* -->
50     var topurl = "<subst:topurl/>";
51    </script>
52    <script language="JavaScript" type="text/javascript">
53 <![CDATA[
54 if(window.event + "" == "undefined") event = null;
55 function HM_f_PopUp(){return false};
56 function HM_f_PopDown(){return false};
57 popUp = HM_f_PopUp;
58 popDown = HM_f_PopDown;
59 var selectedURI;
60 ]]>
61    </script>
62    <script language="JavaScript1.2" type="text/javascript">
63 <![CDATA[
64 HM_PG_MenuWidth = 300;
65 HM_PG_FontFamily = "Arial,sans-serif";
66 HM_PG_FontSize = 10;
67 HM_PG_FontBold = 0;
68 HM_PG_FontItalic = 0;
69 HM_PG_FontColor = "blue";
70 HM_PG_FontColorOver = "green";
71 HM_PG_BGColor = "#DDDDDD";
72 HM_PG_BGColorOver = "#FFCCCC";
73 HM_PG_ItemPadding = 3;
74
75 HM_PG_BorderWidth = 2;
76 HM_PG_BorderColor = "black";
77 HM_PG_BorderStyle = "solid";
78 HM_PG_SeparatorSize = 2;
79 HM_PG_SeparatorColor = "#d0ff00";
80
81 HM_PG_ImageSrc = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_black_right.gif";
82 HM_PG_ImageSrcLeft = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_black_left.gif";
83 HM_PG_ImageSrcOver = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_white_right.gif";
84 HM_PG_ImageSrcLeftOver = ]]> topurl + <![CDATA["/javascript/jsmenu/HM_More_white_left.gif";
85
86 HM_PG_ImageSize = 5;
87 HM_PG_ImageHorizSpace = 0;
88 HM_PG_ImageVertSpace = 2;
89
90 HM_PG_KeepHilite = true; 
91 HM_PG_ClickStart = 0;
92 HM_PG_ClickKill = false;
93 HM_PG_ChildOverlap = 20;
94 HM_PG_ChildOffset = 10;
95 HM_PG_ChildPerCentOver = null;
96 HM_PG_TopSecondsVisible = .5;
97 HM_PG_StatusDisplayBuild =0;
98 HM_PG_StatusDisplayLink = 0;
99 HM_PG_UponDisplay = null;
100 HM_PG_UponHide = null;
101 HM_PG_RightToLeft = 0;
102
103 HM_PG_CreateTopOnly = 0;
104 HM_PG_ShowLinkCursor = 1;
105 HM_PG_NSFontOver = true;
106
107 //HM_a_TreesToBuild = [2];
108 ]]>
109    </script>
110    <script>
111 <![CDATA[
112 function mkRDFURI(uri)
113 {
114    var prefix = "helm:rdf:www.cs.unibo.it/helm/rdf/backward//";
115    var re1 = /#xpointer\(1\/(\d+)\/(\d+)\)/;
116    var re2 = /#xpointer\(1\/(\d+)\)/;
117    // Just one of the following replace will do something
118    uri = uri.replace(re1,",$1,$2");
119    uri = uri.replace(re2,",$1");
120
121    return (prefix + uri);
122 }
123
124 function removeXPointer(uri)
125 {
126    //var re = /#xpointer(\.*)/;
127    // CSC: Why the r.e.s below work and the one above does not?
128    var re1 = /#xpointer\(1\/(\d+)\/(\d+)\)/;
129    var re2 = /#xpointer\(1\/(\d+)\)/;
130    var res = uri.replace(re1,"");
131    res = res.replace(re2,"");
132
133    return res;
134 }
135
136
137 // (use_rdf_uri==true) if the stylesheet must be applied to the
138 // metadata; (use_rdf_uri==false) otherwise
139 function mkGraphURL(uri,keys,use_rdf_uri)
140 {
141    var getterURL = unescape(getParam("param.getterURL"));
142    var draw_graphURL = unescape(getParam("param.draw_graphURL"));
143    var url= setParam(location.href,"keys",keys);
144    var rdfuri = mkRDFURI(uri);
145    url = setParam(url,"xmluri", getterURL + 'getxml%3Furi%3D' +
146     (use_rdf_uri ? rdfuri : removeXPointer(uri)));
147    url = setParam(url,"param.CICURI",escape(uri));
148    var uri_set_size = document.uri_set_size.elements[0].value;
149    url = setParam(url,"param.uri_set_size",uri_set_size);
150    url = draw_graphURL + 'draw?url=' + escape(url);
151    var url2 = setParam(location.href,"keys","MGL,RT");
152    url2 = setParam(url2,"xmluri",escape(url));
153    url2 = setParam(url2,"param.uri_set_size",uri_set_size);
154    return url2;
155 }
156
157 function mkDepURL(uri)
158 {
159    return mkGraphURL(uri,"MDG",0);
160 }
161
162
163 function mkMetaURL(uri)
164 {
165    return mkGraphURL(uri,"MMG",1);
166 }
167
168 function mkCICURL(uri)
169 {
170    var rawuri = removeXPointer(uri);
171    var getterURL = getParam("param.getterURL");
172    var interfaceURL = unescape(getParam("param.interfaceURL"));
173    var url= setParam(location.href,"keys",getParam("param.keys"));
174    url = setParam(url,"xmluri", getterURL + 'getxml%3Furi%3D' + rawuri);
175    url = setParam(url,"param.CICURI",rawuri);
176    url = interfaceURL + "?url=" + escape(url);
177    return url;
178 }
179 ]]>
180    </script>
181    <xsl:apply-templates/>
182   </xsl:copy>
183 </xsl:template>
184
185 <xsl:template match="body">
186   <form name="uri_set_size">
187    Number of nodes to show when following an hyperlink:
188    <input type="text" onClick="return false" value="{$uri_set_size}" size="2"/> (30 suggested)
189   </form>
190   <xsl:copy>
191    <xsl:copy-of select="@*"/>
192    <xsl:apply-templates/>
193    <script>
194 HM_Array1 = [
195 <![CDATA[
196 [,,,
197 ,,,,,,,,,,,,,,,,
198 1,true],
199 ["Objects this one depends on.","javascript:window.open(mkDepURL(selectedURI),'graph')",1,0,0],
200 ["Render this object.","javascript:window.open(mkCICURL(selectedURI),'cic')",1,0,0],
201 ["Objects depending on this one.","javascript:window.open(mkMetaURL(selectedURI),'graph')",1,0,0]
202 ];
203 ]]>
204    </script>
205    <subst:script Language="JavaScript1.2" src="/javascript/jsmenu/HM_Loader_prova.js"/>
206   </xsl:copy>
207 </xsl:template>
208
209 <xsl:template match = "area">
210  <xsl:variable name="uri" select="@href"/>
211  <xsl:copy>
212   <xsl:copy-of select="@*"/> 
213   <xsl:if test="starts-with(@href,&quot;cic:&quot;)">
214 <!-- CSC: I don't know why the following one does not work.
215      CSC: Replaced with the following line
216    <xsl:attribute name="onMouseOver">selectedURI=this.href;HM_f_PopUp('elMenu1',event)</xsl:attribute>
217 -->
218    <xsl:attribute name="onMouseOver">selectedURI='<xsl:value-of select="$uri"/>';HM_f_PopUp('elMenu1',event)</xsl:attribute>
219    <xsl:attribute name="onMouseOut">HM_f_PopDown('elMenu1')</xsl:attribute>
220   </xsl:if>
221   <xsl:apply-templates/>
222  </xsl:copy>
223 </xsl:template>
224
225 </xsl:stylesheet>