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