]> matita.cs.unibo.it Git - helm.git/blob - helm/style/html_set.xsl
Modified Files:
[helm.git] / helm / style / html_set.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 <!-- INIT style for HTML                                                   -->
32 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena                      -->
33 <!--***********************************************************************--> 
34
35 <!-- IN -->
36
37  <xsl:template match="m:apply[m:in]">
38   <xsl:param name="current_indent" select="0"/> 
39   <xsl:param name="width" select="$framewidth"/>
40   <xsl:variable name="uri">
41    <xsl:value-of select="m:in/@definitionURL"/>
42   </xsl:variable>
43   <xsl:variable name="charlength">
44    <xsl:apply-templates select="m:in" mode="charcount"/>
45   </xsl:variable>
46   <xsl:choose>
47     <xsl:when test="$charlength > $framewidth">
48      <xsl:text>(</xsl:text>
49      <xsl:apply-templates select="*[2]">
50       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
51      </xsl:apply-templates>
52      <BR/> 
53      <xsl:call-template name="make_indent">
54       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
55      </xsl:call-template>
56      <a>
57      <xsl:attribute name="href">
58       <xsl:value-of select="concat(string($header),string($uri))"/>
59      </xsl:attribute>
60      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#206;</FONT>
61      </a>
62      <xsl:apply-templates select="*[3]">
63       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
64      </xsl:apply-templates>
65      <xsl:text>)</xsl:text>
66     </xsl:when>
67     <xsl:otherwise>
68      <xsl:text>(</xsl:text>
69      <xsl:apply-templates select="*[2]"/>
70      <a>
71      <xsl:attribute name="href">
72       <xsl:value-of select="concat(string($header),string($uri))"/>
73      </xsl:attribute>
74      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#206;</FONT>
75      </a>
76      <xsl:apply-templates select="*[3]"/>
77      <xsl:text>)</xsl:text>
78     </xsl:otherwise>
79    </xsl:choose>
80  </xsl:template>
81
82 <!-- NOTIN -->
83
84  <xsl:template match="m:apply[m:notin]">
85   <xsl:param name="current_indent" select="0"/> 
86   <xsl:param name="width" select="$framewidth"/>
87   <xsl:variable name="uri">
88    <xsl:value-of select="m:notin/@definitionURL"/>
89   </xsl:variable>
90   <xsl:variable name="charlength">
91    <xsl:apply-templates select="m:notin" mode="charcount"/>
92   </xsl:variable>
93   <xsl:choose>
94     <xsl:when test="$charlength > $framewidth">
95      <xsl:text>(</xsl:text>
96      <xsl:apply-templates select="*[2]">
97       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
98      </xsl:apply-templates>
99      <BR/> 
100      <xsl:call-template name="make_indent">
101       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
102      </xsl:call-template>
103      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#207;</FONT>
104      <xsl:apply-templates select="*[3]">
105       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
106      </xsl:apply-templates>
107      <xsl:text>)</xsl:text>
108     </xsl:when>
109     <xsl:otherwise>
110      <xsl:text>(</xsl:text>
111      <xsl:apply-templates select="*[2]"/>
112      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#207;</FONT>
113      <xsl:apply-templates select="*[3]"/>
114      <xsl:text>)</xsl:text>
115     </xsl:otherwise>
116    </xsl:choose>
117  </xsl:template>
118
119 <!-- SET -->
120
121  <xsl:template match="m:set">
122   <xsl:param name="current_indent" select="0"/> 
123   <xsl:param name="width" select="$framewidth"/>
124   <xsl:variable name="uri">
125    <xsl:value-of select="concat(string($absPath), @definitionURL)"/>
126   </xsl:variable>
127   <xsl:choose>
128    <xsl:when test="count(child::*) = 0">
129     <FONT FACE="symbol" mathcolor="blue">&#198;</FONT>
130    </xsl:when>
131    <xsl:otherwise>
132     <xsl:variable name="charlength">
133      <xsl:apply-templates select="." mode="charcount"/>
134     </xsl:variable>
135     <xsl:choose>
136      <xsl:when test="name(*[1]) = 'm:bvar'">
137       <xsl:choose>
138        <xsl:when test="$charlength > $framewidth">
139         <xsl:text>{</xsl:text>
140         <xsl:apply-templates select="m:bvar/m:ci"/>
141         <xsl:text>:</xsl:text>
142         <xsl:apply-templates select="m:bvar/m:type">
143          <xsl:with-param name="current_indent" 
144            select="$current_indent + 2 + string-length(m:bvar/m:ci)"/>
145         </xsl:apply-templates><BR/>
146         <xsl:call-template name="make_indent">
147          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
148         </xsl:call-template>
149         <xsl:text>|</xsl:text>
150         <xsl:apply-templates select="m:condition">
151          <xsl:with-param name="current_indent" select="$current_indent + 2"/>
152         </xsl:apply-templates>
153         <xsl:text>}</xsl:text>
154        </xsl:when>
155        <xsl:otherwise>
156         <xsl:text>{</xsl:text>
157         <xsl:apply-templates select="m:bvar/m:ci"/>
158         <xsl:text>:</xsl:text>
159         <xsl:apply-templates select="m:bvar/m:type"/>
160         <xsl:text>|</xsl:text>
161         <xsl:apply-templates select="*[position()=2]"/>
162         <xsl:text>}</xsl:text>
163        </xsl:otherwise>
164       </xsl:choose>
165      </xsl:when>
166      <xsl:otherwise>
167       <xsl:choose>
168        <xsl:when test="$charlength > $framewidth">
169         <xsl:text>{</xsl:text>
170          <xsl:apply-templates select="*[position()=1]">
171           <xsl:with-param name="current_indent" select="$current_indent + 2"/>
172          </xsl:apply-templates>
173          <xsl:for-each select="*[position()>1]">
174           <xsl:text>,</xsl:text>
175           <BR/>
176           <xsl:call-template name="make_indent">
177            <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
178           </xsl:call-template>
179           <xsl:apply-templates select=".">
180            <xsl:with-param name="current_indent" select="$current_indent + 2"/>
181           </xsl:apply-templates>
182          </xsl:for-each>
183          <xsl:text>}</xsl:text>
184         </xsl:when>
185         <xsl:otherwise>
186         <xsl:text>{</xsl:text>
187          <xsl:for-each select="*">
188           <xsl:apply-templates select="."/>
189           <xsl:choose>
190            <xsl:when test="position() = last()">
191             <xsl:text>}</xsl:text>
192            </xsl:when>
193            <xsl:otherwise>
194             <xsl:text>,</xsl:text>
195            </xsl:otherwise>
196           </xsl:choose>
197          </xsl:for-each>
198         </xsl:otherwise>
199        </xsl:choose>
200       </xsl:otherwise>
201      </xsl:choose>
202     </xsl:otherwise>
203    </xsl:choose>
204  </xsl:template>
205
206
207 <!-- INTERSECTION -->
208
209 <xsl:template match="m:apply[m:intersect]">
210   <xsl:param name="current_indent" select="0"/> 
211   <xsl:param name="width" select="$framewidth"/>
212   <xsl:variable name="uri">
213    <xsl:value-of select="m:intersect/@definitionURL"/>
214   </xsl:variable>
215   <xsl:variable name="charlength">
216    <xsl:apply-templates select="m:intersect" mode="charcount"/>
217   </xsl:variable>
218   <xsl:choose>
219     <xsl:when test="$charlength > $framewidth">
220      <xsl:text>(</xsl:text>
221      <xsl:apply-templates select="*[2]">
222       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
223      </xsl:apply-templates>
224      <BR/> 
225      <xsl:call-template name="make_indent">
226       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
227      </xsl:call-template>
228      <a>
229      <xsl:attribute name="href">
230       <xsl:value-of select="concat(string($header),string($uri))"/>
231      </xsl:attribute>
232      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#199;</FONT>
233      </a>
234      <xsl:apply-templates select="*[3]">
235       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
236      </xsl:apply-templates>
237      <xsl:text>)</xsl:text>
238     </xsl:when>
239     <xsl:otherwise>
240      <xsl:text>(</xsl:text>
241      <xsl:apply-templates select="*[2]"/>
242      <a>
243      <xsl:attribute name="href">
244       <xsl:value-of select="concat(string($header),string($uri))"/>
245      </xsl:attribute>
246      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#199;</FONT>
247      </a>
248      <xsl:apply-templates select="*[3]"/>
249      <xsl:text>)</xsl:text>
250     </xsl:otherwise>
251    </xsl:choose>
252  </xsl:template>
253
254 <!-- UNION -->
255
256 <xsl:template match="m:apply[m:union]">
257   <xsl:param name="current_indent" select="0"/> 
258   <xsl:param name="width" select="$framewidth"/>
259   <xsl:variable name="uri">
260    <xsl:value-of select="m:union/@definitionURL"/>
261   </xsl:variable>
262   <xsl:variable name="charlength">
263    <xsl:apply-templates select="m:union" mode="charcount"/>
264   </xsl:variable>
265   <xsl:choose>
266     <xsl:when test="$charlength > $framewidth">
267      <xsl:text>(</xsl:text>
268      <xsl:apply-templates select="*[2]">
269       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
270      </xsl:apply-templates>
271      <BR/> 
272      <xsl:call-template name="make_indent">
273       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
274      </xsl:call-template>
275      <a>
276      <xsl:attribute name="href">
277       <xsl:value-of select="concat(string($header),string($uri))"/>
278      </xsl:attribute>
279      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#200;</FONT>
280      </a>
281      <xsl:apply-templates select="*[3]">
282       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
283      </xsl:apply-templates>
284      <xsl:text>)</xsl:text>
285     </xsl:when>
286     <xsl:otherwise>
287      <xsl:text>(</xsl:text>
288      <xsl:apply-templates select="*[2]"/>
289      <a>
290      <xsl:attribute name="href">
291       <xsl:value-of select="concat(string($header),string($uri))"/>
292      </xsl:attribute>
293      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#200;</FONT>
294      </a>
295      <xsl:apply-templates select="*[3]"/>
296      <xsl:text>)</xsl:text>
297     </xsl:otherwise>
298    </xsl:choose>
299  </xsl:template>
300
301 <!-- SUBSET -->
302 <xsl:template match="m:apply[m:subset]">
303   <xsl:param name="current_indent" select="0"/> 
304   <xsl:param name="width" select="$framewidth"/>
305   <xsl:variable name="uri">
306    <xsl:value-of select="m:subset/@definitionURL"/>
307   </xsl:variable>
308   <xsl:variable name="charlength">
309    <xsl:apply-templates select="m:subset" mode="charcount"/>
310   </xsl:variable>
311   <xsl:choose>
312     <xsl:when test="$charlength > $framewidth">
313      <xsl:text>(</xsl:text>
314      <xsl:apply-templates select="*[2]">
315       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
316      </xsl:apply-templates>
317      <BR/> 
318      <xsl:call-template name="make_indent">
319       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
320      </xsl:call-template>
321      <a>
322      <xsl:attribute name="href">
323       <xsl:value-of select="concat(string($header),string($uri))"/>
324      </xsl:attribute>
325      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#205;</FONT>
326      </a>
327      <xsl:apply-templates select="*[3]">
328       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
329      </xsl:apply-templates>
330      <xsl:text>)</xsl:text>
331     </xsl:when>
332     <xsl:otherwise>
333      <xsl:text>(</xsl:text>
334      <xsl:apply-templates select="*[2]"/>
335      <a>
336      <xsl:attribute name="href">
337       <xsl:value-of select="concat(string($header),string($uri))"/>
338      </xsl:attribute>
339      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#205;</FONT>
340      </a>
341      <xsl:apply-templates select="*[3]"/>
342      <xsl:text>)</xsl:text>
343     </xsl:otherwise>
344    </xsl:choose>
345  </xsl:template>
346
347 <!-- PRSUBSET -->
348 <xsl:template match="m:apply[m:prsubset]">
349   <xsl:param name="current_indent" select="0"/> 
350   <xsl:param name="width" select="$framewidth"/>
351   <xsl:variable name="uri">
352    <xsl:value-of select="m:prsubset/@definitionURL"/>
353   </xsl:variable>
354   <xsl:variable name="charlength">
355    <xsl:apply-templates select="m:prsubset" mode="charcount"/>
356   </xsl:variable>
357   <xsl:choose>
358     <xsl:when test="$charlength > $framewidth">
359      <xsl:text>(</xsl:text>
360      <xsl:apply-templates select="*[2]">
361       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
362      </xsl:apply-templates>
363      <BR/> 
364      <xsl:call-template name="make_indent">
365       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
366      </xsl:call-template>
367      <a>
368      <xsl:attribute name="href">
369       <xsl:value-of select="concat(string($header),string($uri))"/>
370      </xsl:attribute>
371      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#204;</FONT>
372      </a>
373      <xsl:apply-templates select="*[3]">
374       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
375      </xsl:apply-templates>
376      <xsl:text>)</xsl:text>
377     </xsl:when>
378     <xsl:otherwise>
379      <xsl:text>(</xsl:text>
380      <xsl:apply-templates select="*[2]"/>
381      <a>
382      <xsl:attribute name="href">
383       <xsl:value-of select="concat(string($header),string($uri))"/>
384      </xsl:attribute>
385      <FONT FACE="symbol" SIZE="+2" mathcolor="blue">&#204;</FONT>
386      </a>
387      <xsl:apply-templates select="*[3]"/>
388      <xsl:text>)</xsl:text>
389     </xsl:otherwise>
390    </xsl:choose>
391  </xsl:template>
392
393
394 <!-- SETDIFF -->
395
396 <xsl:template match="m:apply[m:setdiff]">
397   <xsl:param name="current_indent" select="0"/> 
398   <xsl:param name="width" select="$framewidth"/>
399   <xsl:variable name="uri">
400    <xsl:value-of select="m:setdiff/@definitionURL"/>
401   </xsl:variable>
402   <xsl:variable name="charlength">
403    <xsl:apply-templates select="m:setdiff" mode="charcount"/>
404   </xsl:variable>
405   <xsl:choose>
406     <xsl:when test="$charlength > $framewidth">
407      <xsl:text>(</xsl:text>
408      <xsl:apply-templates select="*[2]">
409       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
410      </xsl:apply-templates>
411      <BR/> 
412      <xsl:call-template name="make_indent">
413       <xsl:with-param name="current_indent" select="$current_indent + 2"/> 
414      </xsl:call-template>
415      <a>
416      <xsl:attribute name="href">
417       <xsl:value-of select="concat(string($header),string($uri))"/>
418      </xsl:attribute>
419      <xsl:text>/</xsl:text>
420      </a>
421      <xsl:apply-templates select="*[3]">
422       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
423      </xsl:apply-templates>
424      <xsl:text>)</xsl:text>
425     </xsl:when>
426     <xsl:otherwise>
427      <xsl:text>(</xsl:text>
428      <xsl:apply-templates select="*[2]"/>
429      <a>
430      <xsl:attribute name="href">
431       <xsl:value-of select="concat(string($header),string($uri))"/>
432      </xsl:attribute>
433      <xsl:text>/</xsl:text>
434      </a>
435      <xsl:apply-templates select="*[3]"/>
436      <xsl:text>)</xsl:text>
437     </xsl:otherwise>
438    </xsl:choose>
439  </xsl:template>
440
441 <!-- CARD -->
442 <xsl:template match="m:apply[m:card]">
443   <xsl:param name="current_indent" select="0"/> 
444   <xsl:param name="width" select="$framewidth"/>
445   <xsl:variable name="uri">
446    <xsl:value-of select="m:card/@definitionURL"/>
447   </xsl:variable>
448   <xsl:text>|</xsl:text>
449   <xsl:apply-templates select="*[2]">
450    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
451   </xsl:apply-templates>
452   <xsl:text>|</xsl:text>
453  </xsl:template>
454
455 <!-- COUNTING -->
456
457 <xsl:template match="m:in|m:notin|m:intersect|m:union
458            |m:subset|m:prsubset|m:setdiff|m:card" mode="charcount">
459 <xsl:param name="incurrent_length" select="0"/> 
460     <xsl:choose>
461     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
462      <xsl:variable name="siblength"><xsl:apply-templates select="following-sibling::*[position()=1]" mode="charcount"><xsl:with-param name="incurrent_length" select="$incurrent_length + string-length()"/></xsl:apply-templates></xsl:variable>
463      <xsl:choose>
464      <xsl:when test="string($siblength) = &quot;&quot;">
465       <xsl:value-of select="$incurrent_length + string-length()"/>
466      </xsl:when>
467      <xsl:otherwise>
468       <xsl:value-of select="number($siblength)"/>
469      </xsl:otherwise>
470      </xsl:choose>
471     </xsl:when>
472     <xsl:otherwise>
473      <xsl:value-of select="$incurrent_length + string-length()"/>
474     </xsl:otherwise>
475     </xsl:choose>
476 </xsl:template> 
477
478 </xsl:stylesheet> 
479
480
481
482
483
484
485