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