]> matita.cs.unibo.it Git - helm.git/blob - helm/style/links_library.xsl
...
[helm.git] / helm / style / links_library.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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28                               xmlns:m="http://www.w3.org/1998/Math/MathML">
29
30 <!--***********************************************************************--> 
31 <!-- auxiliary functions                                                   -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
33 <!--***********************************************************************--> 
34
35 <!--      * is used for objects                      -->
36 <!--    th* is used for theories                     -->
37 <!-- embed* is used for objects embedded in theories -->
38
39 <xsl:param name="getterURL" select="'http://localhost:8081/'"/>
40 <xsl:param name="processorURL" select="'http://localhost:8080/helm/servlet/uwobo/'"/>
41 <xsl:param name="draw_graphURL" select="'http://localhost:8083/'"/>
42 <xsl:param name="uri_set_queueURL" select="'http://localhost:8084/'"/>
43 <!-- URL to the frameset (control + output) -->
44 <xsl:param name="topurl" select="''"/>
45 <xsl:param name="interfaceURL" select="''"/>
46 <xsl:param name="thinterfaceURL" select="''"/>
47
48 <xsl:param name="keys" select="'C1,HC2,L'"/>
49 <xsl:param name="embedkeys" select="'TC1,HC2,L'"/>
50 <xsl:param name="thkeys" select="'T1,T2,L,E'"/>
51
52 <xsl:param name="naturalLanguage" select="'yes'"/>
53 <xsl:param name="annotations" select="'no'"/>
54 <xsl:param name="UNICODEvsSYMBOL" select="'symbol'"/>
55
56 <xsl:param name="media-type" select="'text/html'"/>
57 <xsl:param name="thmedia-type" select="'text/html'"/>
58 <xsl:param name="doctype-public" select="'-//W3C//DTD XHTML 1.0 Transitional//EN'"/>
59 <xsl:param name="encoding" select="'iso-8859-1'"/>
60 <xsl:param name="thencoding" select="'iso-8859-1'"/>
61
62
63 <xsl:template name="quote">
64  <xsl:param name="s" select="''"/>
65  <xsl:param name="news" select="''"/>
66  <xsl:choose>
67   <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
68   <xsl:otherwise>
69    <xsl:variable name="char" select="substring($s,1,1)"/>
70    <xsl:choose>
71     <xsl:when test="$char = ' '">
72      <xsl:call-template name="quote">
73       <xsl:with-param name="s" select="substring($s,2)"/>
74       <xsl:with-param name="news" select="concat($news,'%20')"/>
75      </xsl:call-template>
76     </xsl:when>
77     <xsl:when test="$char = '&amp;'">
78      <xsl:call-template name="quote">
79       <xsl:with-param name="s" select="substring($s,2)"/>
80       <xsl:with-param name="news" select="concat($news,'%26')"/>
81      </xsl:call-template>
82     </xsl:when>
83     <xsl:when test="$char = '?'">
84      <xsl:call-template name="quote">
85       <xsl:with-param name="s" select="substring($s,2)"/>
86       <xsl:with-param name="news" select="concat($news,'%3F')"/>
87      </xsl:call-template>
88     </xsl:when>
89     <xsl:when test="$char = '='">
90      <xsl:call-template name="quote">
91       <xsl:with-param name="s" select="substring($s,2)"/>
92       <xsl:with-param name="news" select="concat($news,'%3D')"/>
93      </xsl:call-template>
94     </xsl:when>
95     <xsl:when test="$char = '%'">
96      <xsl:call-template name="quote">
97       <xsl:with-param name="s" select="substring($s,2)"/>
98       <xsl:with-param name="news" select="concat($news,'%25')"/>
99      </xsl:call-template>
100     </xsl:when>
101     <xsl:when test="$char = ','">
102      <xsl:call-template name="quote">
103       <xsl:with-param name="s" select="substring($s,2)"/>
104       <xsl:with-param name="news" select="concat($news,'%2C')"/>
105      </xsl:call-template>
106     </xsl:when>
107 <!--CSC: This breaks all the rest ;-)
108     <xsl:when test="$char = ':'">
109      <xsl:call-template name="quote">
110       <xsl:with-param name="s" select="substring($s,2)"/>
111       <xsl:with-param name="news" select="concat($news,'%3A')"/>
112      </xsl:call-template>
113     </xsl:when>
114 -->
115     <xsl:otherwise>
116      <xsl:call-template name="quote">
117       <xsl:with-param name="s" select="substring($s,2)"/>
118       <xsl:with-param name="news" select="concat($news,$char)"/>
119      </xsl:call-template>
120     </xsl:otherwise>
121    </xsl:choose>
122   </xsl:otherwise>
123  </xsl:choose>
124 </xsl:template>
125
126 <xsl:variable name="absPath">
127  <xsl:call-template name="quote">
128   <xsl:with-param name="s"><xsl:value-of select="$getterURL"/>getxml?uri=</xsl:with-param>
129  </xsl:call-template>
130 </xsl:variable>
131
132 <xsl:variable name="escaped-doctype-public">
133  <xsl:call-template name="quote">
134   <xsl:with-param name="s" select="$doctype-public"/>
135  </xsl:call-template>
136 </xsl:variable>
137
138 <xsl:variable name="escaped-processorURL">
139  <xsl:call-template name="quote">
140   <xsl:with-param name="s" select="$processorURL"/>
141  </xsl:call-template>
142 </xsl:variable>
143
144 <xsl:variable name="escaped-getterURL">
145  <xsl:call-template name="quote">
146   <xsl:with-param name="s" select="$getterURL"/>
147  </xsl:call-template>
148 </xsl:variable>
149
150 <xsl:variable name="escaped-interfaceURL">
151  <xsl:call-template name="quote">
152   <xsl:with-param name="s" select="$interfaceURL"/>
153  </xsl:call-template>
154 </xsl:variable>
155
156 <xsl:variable name="escaped-topurl">
157  <xsl:call-template name="quote">
158   <xsl:with-param name="s" select="$topurl"/>
159  </xsl:call-template>
160 </xsl:variable>
161
162 <xsl:variable name="escaped-thinterfaceURL">
163  <xsl:call-template name="quote">
164   <xsl:with-param name="s" select="$thinterfaceURL"/>
165  </xsl:call-template>
166 </xsl:variable>
167
168 <xsl:variable name="quotedthkeys">
169  <xsl:call-template name="quote">
170   <xsl:with-param name="s" select="$thkeys"/>
171  </xsl:call-template>
172 </xsl:variable>
173
174 <xsl:variable name="quotedembedkeys">
175  <xsl:call-template name="quote">
176   <xsl:with-param name="s" select="$embedkeys"/>
177  </xsl:call-template>
178 </xsl:variable>
179
180 <xsl:variable name="quotedkeys">
181  <xsl:call-template name="quote">
182   <xsl:with-param name="s" select="$keys"/>
183  </xsl:call-template>
184 </xsl:variable>
185
186 <xsl:variable name="quotedquotedkeys">
187  <xsl:call-template name="quote">
188   <xsl:with-param name="s" select="$quotedkeys"/>
189  </xsl:call-template>
190 </xsl:variable>
191
192 <xsl:variable name="quotedquotedthkeys">
193  <xsl:call-template name="quote">
194   <xsl:with-param name="s" select="$quotedthkeys"/>
195  </xsl:call-template>
196 </xsl:variable>
197
198 <xsl:variable name="quotedquotedembedkeys">
199  <xsl:call-template name="quote">
200   <xsl:with-param name="s" select="$quotedembedkeys"/>
201  </xsl:call-template>
202 </xsl:variable>
203
204 <xsl:variable name="header0"><xsl:value-of select="$interfaceURL"/>?url=</xsl:variable>
205 <xsl:variable name="thheader0"><xsl:value-of select="$thinterfaceURL"/>?url=</xsl:variable>
206 <xsl:variable name="header1"><xsl:value-of select="$escaped-processorURL"/>apply?keys=</xsl:variable>
207 <xsl:variable name="bothheader2">&#x26;param.naturalLanguage=<xsl:value-of select="$naturalLanguage"/>&#x26;param.draw_graphURL=<xsl:value-of select="$draw_graphURL"/>&#x26;param.uri_set_queueURL=<xsl:value-of select="$uri_set_queueURL"/>&#x26;param.UNICODEvsSYMBOL=<xsl:value-of select="$UNICODEvsSYMBOL"/>&#x26;param.annotations=<xsl:value-of select="$annotations"/>&#x26;prop.doctype-public=<xsl:value-of select="$escaped-doctype-public"/>&#x26;param.doctype-public=<xsl:value-of select="$escaped-doctype-public"/>&#x26;param.encoding=<xsl:value-of select="$encoding"/>&#x26;param.media-type=<xsl:value-of select="$media-type"/>&#x26;param.keys=<xsl:value-of select="$quotedkeys"/>&#x26;param.getterURL=<xsl:value-of select="$escaped-getterURL"/>&#x26;param.processorURL=<xsl:value-of select="$escaped-processorURL"/>&#x26;param.interfaceURL=<xsl:value-of select="$escaped-interfaceURL"/>&#x26;param.topurl=<xsl:value-of select="$escaped-topurl"/>&#x26;xmluri=<xsl:value-of select="$absPath"/></xsl:variable>
208 <xsl:variable name="header2">&#x26;prop.media-type=<xsl:value-of select="$media-type"/>&#x26;prop.encoding=<xsl:value-of select="$encoding"/></xsl:variable>
209 <xsl:variable name="thheader2">&#x26;prop.media-type=<xsl:value-of select="$thmedia-type"/>&#x26;param.thmedia-type=<xsl:value-of select="$thmedia-type"/>&#x26;param.thkeys=<xsl:value-of select="$quotedthkeys"/>&#x26;param.embedkeys=<xsl:value-of select="$quotedembedkeys"/>&#x26;param.thinterfaceURL=<xsl:value-of select="$escaped-thinterfaceURL"/>&#x26;param.thencoding=<xsl:value-of select="$thencoding"/>&#x26;prop.encoding=<xsl:value-of select="$thencoding"/></xsl:variable>
210
211 <xsl:variable name="quotedheader1">
212  <xsl:call-template name="quote">
213   <xsl:with-param name="s" select="$header1"/>
214  </xsl:call-template>
215 </xsl:variable>
216
217 <xsl:variable name="quotedbothheader2">
218  <xsl:call-template name="quote">
219   <xsl:with-param name="s" select="$bothheader2"/>
220  </xsl:call-template>
221 </xsl:variable>
222
223 <xsl:variable name="quotedheader2">
224  <xsl:call-template name="quote">
225   <xsl:with-param name="s" select="$header2"/>
226  </xsl:call-template>
227 </xsl:variable>
228
229 <xsl:variable name="quotedthheader2">
230  <xsl:call-template name="quote">
231   <xsl:with-param name="s" select="$thheader2"/>
232  </xsl:call-template>
233 </xsl:variable>
234
235 <!-- makeURL() maps URIs into URLs               -->
236 <!-- The target of the URL is the whole frameset -->
237
238 <xsl:variable name="biquotedfixedheader">
239  <xsl:value-of select="$header0"/>
240  <xsl:value-of select="$quotedheader1"/>
241  <xsl:value-of select="$quotedquotedkeys"/>
242  <xsl:value-of select="$quotedheader2"/>
243  <xsl:value-of select="$quotedbothheader2"/>
244 </xsl:variable>
245
246 <xsl:variable name="biquotedthfixedheader">
247  <xsl:value-of select="$thheader0"/>
248  <xsl:value-of select="$quotedheader1"/>
249  <xsl:value-of select="$quotedquotedthkeys"/>
250  <xsl:value-of select="$quotedthheader2"/>
251  <xsl:value-of select="$quotedbothheader2"/>
252 </xsl:variable>
253
254 <!-- NOTE: embedkeys and thkeys are propagated, but we are sure that -->
255 <!-- they won't never be used.                                       -->
256 <!--CSC: fixare il punto sopra!!! -->
257 <!-- type, instead, is not propagated                                -->
258 <xsl:template name="makeURL">
259 <xsl:param name="uri" select="''"/>
260  <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
261  <xsl:variable name="cleanuri">
262   <xsl:choose>
263    <xsl:when test="$uri_after_sharp">
264     <xsl:value-of select="substring-before($uri,'#')"/>
265    </xsl:when>
266    <xsl:otherwise>
267     <xsl:value-of select="$uri"/>
268    </xsl:otherwise>
269   </xsl:choose>
270  </xsl:variable>
271  <xsl:variable name="sharpsuffix">
272   <xsl:choose>
273    <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
274    <xsl:otherwise></xsl:otherwise>
275   </xsl:choose>
276  </xsl:variable>
277      <xsl:value-of select="$biquotedfixedheader"/>
278      <xsl:value-of select="$cleanuri"/>%26param.CICURI%3D<xsl:value-of select="$cleanuri"/>
279      <xsl:value-of select="$sharpsuffix"/>
280 </xsl:template>
281
282 <xsl:template name="makeTheoryURL">
283 <xsl:param name="uri" select="''"/>
284  <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
285  <xsl:variable name="cleanuri">
286   <xsl:choose>
287    <xsl:when test="$uri_after_sharp">
288     <xsl:value-of select="substring-before($uri,'#')"/>
289    </xsl:when>
290    <xsl:otherwise>
291     <xsl:value-of select="$uri"/>
292    </xsl:otherwise>
293   </xsl:choose>
294  </xsl:variable>
295  <xsl:variable name="sharpsuffix">
296   <xsl:choose>
297    <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
298    <xsl:otherwise></xsl:otherwise>
299   </xsl:choose>
300  </xsl:variable>
301      <xsl:value-of select="$biquotedthfixedheader"/>
302      <xsl:value-of select="$cleanuri"/>%26param.CICURI%3D<xsl:value-of select="$cleanuri"/>
303      <xsl:value-of select="$sharpsuffix"/>
304 </xsl:template>
305
306 <!-- makeURL4embedding() maps URIs into URLs              -->
307 <!-- The target of the URL is only the processed document -->
308
309 <xsl:template name="makeURL4embedding">
310 <xsl:param name="uri" select="''"/>
311 <xsl:param name="type" select="'standalone'"/>
312  <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
313  <xsl:variable name="cleanuri">
314   <xsl:choose>
315    <xsl:when test="$uri_after_sharp">
316     <xsl:value-of select="substring-before($uri,'#')"/>
317    </xsl:when>
318    <xsl:otherwise>
319     <xsl:value-of select="$uri"/>
320    </xsl:otherwise>
321   </xsl:choose>
322  </xsl:variable>
323  <xsl:variable name="sharpsuffix">
324   <xsl:choose>
325    <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
326    <xsl:otherwise></xsl:otherwise>
327   </xsl:choose>
328  </xsl:variable>
329  <xsl:value-of select="$header1"/>
330  <xsl:value-of select="$quotedembedkeys"/>
331  <xsl:value-of select="$header2"/>
332  <xsl:value-of select="$bothheader2"/>
333  <xsl:value-of select="$cleanuri"/>&#x26;param.CICURI=<xsl:value-of select="$cleanuri"/>&#x26;param.type=<xsl:value-of select="$type"/><xsl:value-of select="$sharpsuffix"/>
334 </xsl:template>
335
336 <!-- makeURL4InnerTypes() maps URIs into URLs              -->
337 <!-- The target of the URL is only the processed document -->
338
339 <xsl:template name="makeURL4InnerTypes">
340 <xsl:param name="uri" select="''"/>
341  <xsl:variable name="uri_after_sharp" select="substring-after($uri,'#')"/>
342  <xsl:variable name="cleanuri">
343   <xsl:choose>
344    <xsl:when test="$uri_after_sharp">
345     <xsl:value-of select="substring-before($uri,'#')"/>
346    </xsl:when>
347    <xsl:otherwise>
348     <xsl:value-of select="$uri"/>
349    </xsl:otherwise>
350   </xsl:choose>
351  </xsl:variable>
352  <xsl:variable name="sharpsuffix">
353   <xsl:choose>
354    <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
355    <xsl:otherwise></xsl:otherwise>
356   </xsl:choose>
357  </xsl:variable>
358  <xsl:value-of select="$header1"/>d_c&#x26;param.getterURL=<xsl:value-of select="$escaped-getterURL"/>&#x26;param.CICURI=<xsl:value-of select="$cleanuri"/>&#x26;xmluri=<xsl:value-of select="$absPath"/><xsl:value-of select="$cleanuri"/>
359  <xsl:value-of select="$sharpsuffix"/>
360 </xsl:template>
361
362 </xsl:stylesheet>