3 <!-- Copyright (C) 2000, HELM Team -->
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. -->
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. -->
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. -->
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. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
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">
30 <!--***********************************************************************-->
31 <!-- auxiliary functions -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
33 <!--***********************************************************************-->
35 <!-- * is used for objects -->
36 <!-- th* is used for theories -->
37 <!-- embed* is used for objects embedded in theories -->
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="''"/>
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'"/>
49 <xsl:param name="naturalLanguage" select="'yes'"/>
50 <xsl:param name="annotations" select="'no'"/>
51 <xsl:param name="UNICODEvsSYMBOL" select="'symbol'"/>
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'"/>
60 <xsl:template name="quote">
61 <xsl:param name="s" select="''"/>
62 <xsl:param name="news" select="''"/>
64 <xsl:when test="$s = ''"><xsl:value-of select="$news"/></xsl:when>
66 <xsl:variable name="char" select="substring($s,1,1)"/>
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')"/>
74 <xsl:when test="$char = '&'">
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')"/>
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')"/>
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')"/>
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')"/>
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')"/>
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')"/>
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)"/>
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>
129 <xsl:variable name="escaped-doctype-public">
130 <xsl:call-template name="quote">
131 <xsl:with-param name="s" select="$doctype-public"/>
135 <xsl:variable name="escaped-processorURL">
136 <xsl:call-template name="quote">
137 <xsl:with-param name="s" select="$processorURL"/>
141 <xsl:variable name="escaped-getterURL">
142 <xsl:call-template name="quote">
143 <xsl:with-param name="s" select="$getterURL"/>
147 <xsl:variable name="escaped-interfaceURL">
148 <xsl:call-template name="quote">
149 <xsl:with-param name="s" select="$interfaceURL"/>
153 <xsl:variable name="escaped-thinterfaceURL">
154 <xsl:call-template name="quote">
155 <xsl:with-param name="s" select="$thinterfaceURL"/>
159 <xsl:variable name="quotedthkeys">
160 <xsl:call-template name="quote">
161 <xsl:with-param name="s" select="$thkeys"/>
165 <xsl:variable name="quotedembedkeys">
166 <xsl:call-template name="quote">
167 <xsl:with-param name="s" select="$embedkeys"/>
171 <xsl:variable name="quotedkeys">
172 <xsl:call-template name="quote">
173 <xsl:with-param name="s" select="$keys"/>
177 <xsl:variable name="quotedquotedkeys">
178 <xsl:call-template name="quote">
179 <xsl:with-param name="s" select="$quotedkeys"/>
183 <xsl:variable name="quotedquotedthkeys">
184 <xsl:call-template name="quote">
185 <xsl:with-param name="s" select="$quotedthkeys"/>
189 <xsl:variable name="quotedquotedembedkeys">
190 <xsl:call-template name="quote">
191 <xsl:with-param name="s" select="$quotedembedkeys"/>
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">&param.naturalLanguage=<xsl:value-of select="$naturalLanguage"/>&param.UNICODEvsSYMBOL=<xsl:value-of select="$UNICODEvsSYMBOL"/>&param.annotations=<xsl:value-of select="$annotations"/>&prop.doctype-public=<xsl:value-of select="$escaped-doctype-public"/>&param.doctype-public=<xsl:value-of select="$escaped-doctype-public"/>&param.encoding=<xsl:value-of select="$encoding"/>&param.media-type=<xsl:value-of select="$media-type"/>&param.keys=<xsl:value-of select="$quotedkeys"/>&param.getterURL=<xsl:value-of select="$escaped-getterURL"/>&param.processorURL=<xsl:value-of select="$escaped-processorURL"/>&param.interfaceURL=<xsl:value-of select="$escaped-interfaceURL"/>&xmluri=<xsl:value-of select="$absPath"/></xsl:variable>
199 <xsl:variable name="header2">&prop.media-type=<xsl:value-of select="$media-type"/>&prop.encoding=<xsl:value-of select="$encoding"/></xsl:variable>
200 <xsl:variable name="thheader2">&prop.media-type=<xsl:value-of select="$thmedia-type"/>&param.thmedia-type=<xsl:value-of select="$thmedia-type"/>&param.thkeys=<xsl:value-of select="$quotedthkeys"/>&param.embedkeys=<xsl:value-of select="$quotedembedkeys"/>&param.thinterfaceURL=<xsl:value-of select="$escaped-thinterfaceURL"/>&param.thencoding=<xsl:value-of select="$thencoding"/>&prop.encoding=<xsl:value-of select="$thencoding"/></xsl:variable>
202 <xsl:variable name="quotedheader1">
203 <xsl:call-template name="quote">
204 <xsl:with-param name="s" select="$header1"/>
208 <xsl:variable name="quotedbothheader2">
209 <xsl:call-template name="quote">
210 <xsl:with-param name="s" select="$bothheader2"/>
214 <xsl:variable name="quotedheader2">
215 <xsl:call-template name="quote">
216 <xsl:with-param name="s" select="$header2"/>
220 <xsl:variable name="quotedthheader2">
221 <xsl:call-template name="quote">
222 <xsl:with-param name="s" select="$thheader2"/>
226 <!-- makeURL() maps URIs into URLs -->
227 <!-- The target of the URL is the whole frameset -->
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"/>
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"/>
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">
254 <xsl:when test="$uri_after_sharp">
255 <xsl:value-of select="substring-before($uri,'#')"/>
258 <xsl:value-of select="$uri"/>
262 <xsl:variable name="sharpsuffix">
264 <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
265 <xsl:otherwise></xsl:otherwise>
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"/>
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">
278 <xsl:when test="$uri_after_sharp">
279 <xsl:value-of select="substring-before($uri,'#')"/>
282 <xsl:value-of select="$uri"/>
286 <xsl:variable name="sharpsuffix">
288 <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
289 <xsl:otherwise></xsl:otherwise>
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"/>
297 <!-- makeURL4embedding() maps URIs into URLs -->
298 <!-- The target of the URL is only the processed document -->
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">
306 <xsl:when test="$uri_after_sharp">
307 <xsl:value-of select="substring-before($uri,'#')"/>
310 <xsl:value-of select="$uri"/>
314 <xsl:variable name="sharpsuffix">
316 <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
317 <xsl:otherwise></xsl:otherwise>
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"/>&param.CICURI=<xsl:value-of select="$cleanuri"/>&param.type=<xsl:value-of select="$type"/><xsl:value-of select="$sharpsuffix"/>
327 <!-- makeURL4InnerTypes() maps URIs into URLs -->
328 <!-- The target of the URL is only the processed document -->
330 <xsl:template name="makeURL4InnerTypes">
331 <xsl:param name="uri" select="''"/>
332 <xsl:variable name="cleanuri">
334 <xsl:when test="$uri_after_sharp">
335 <xsl:value-of select="substring-before($uri,'#')"/>
338 <xsl:value-of select="$uri"/>
342 <xsl:variable name="sharpsuffix">
344 <xsl:when test="$uri_after_sharp">%23<xsl:value-of select="$uri_after_sharp"/></xsl:when>
345 <xsl:otherwise></xsl:otherwise>
348 <xsl:value-of select="$header1"/>d_c&param.getterURL=<xsl:value-of select="$escaped-getterURL"/>&param.CICURI=<xsl:value-of select="$cleanuri"/>&xmluri=<xsl:value-of select="$absPath"/><xsl:value-of select="$cleanuri"/>
349 <xsl:value-of select="$sharpsuffix"/>