]> matita.cs.unibo.it Git - helm.git/blob - helm/style/html_reals.xsl
72d6dab7d60f1e57360141a069690220c219e317
[helm.git] / helm / style / html_reals.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 <!-- **************************************************************** -->
36 <!--                   INLINE MODE                                    -->
37 <!-- **************************************************************** -->
38
39 <!-- LIMIT -->
40
41
42 <xsl:template mode="inline" match="m:apply[m:limit]">
43      <xsl:variable name="uri">
44       <xsl:value-of select="m:limit/@definitionURL"/>
45      </xsl:variable>
46      <a>
47      <xsl:attribute name="href">
48       <xsl:call-template name="makeURL">
49        <xsl:with-param name="url" select="$uri"/>
50       </xsl:call-template>
51      </xsl:attribute>
52      <xsl:text>lim</xsl:text>
53      </a>
54      <SUB>
55       <xsl:apply-templates select="m:bvar/m:ci"/>
56       <FONT FACE="symbol" mathcolor="blue">&#174;</FONT>
57       <xsl:apply-templates mode="inline" select="m:lowlimit"/>
58      </SUB>
59      <xsl:apply-templates mode="inline" select="*[4]"/>
60  </xsl:template>
61
62 <!-- DIFFERENTIATION -->
63
64 <xsl:template mode="inline" match="m:apply[m:diff]">
65      <xsl:variable name="uri">
66       <xsl:value-of select="m:diff/@definitionURL"/>
67      </xsl:variable>
68      <a>
69      <xsl:attribute name="href">
70       <xsl:call-template name="makeURL">
71        <xsl:with-param name="url" select="$uri"/>
72       </xsl:call-template>
73      </xsl:attribute>
74      <SUP>d</SUP>
75       <xsl:text>/</xsl:text>
76      <SUB>
77       <xsl:text>d</xsl:text>
78       <xsl:value-of select="m:bvar/m:ci"/>
79      </SUB>
80      </a>
81      <xsl:apply-templates mode="inline" select="*[3]"/>
82  </xsl:template>
83
84 <!-- ABSOLUTE VALUE -->
85 <xsl:template mode="inline" match="m:apply[m:abs]">
86   <xsl:variable name="uri">
87    <xsl:value-of select="m:abs/@definitionURL"/>
88   </xsl:variable>
89   <xsl:text>|</xsl:text>
90   <xsl:apply-templates mode="inline" select="*[2]"/>
91   <xsl:text>|</xsl:text>
92 </xsl:template>
93
94 <!-- FACTORIAL -->
95
96 <xsl:template mode="inline" match="m:apply[m:fact]">
97   <xsl:variable name="uri">
98    <xsl:value-of select="m:abs/@definitionURL"/>
99   </xsl:variable>
100   <xsl:apply-templates mode="inline" select="*[2]"/>
101   <xsl:text>!</xsl:text>
102 </xsl:template>
103
104 <!-- SQUARE ROOT -->
105
106 <xsl:template match="m:apply[m:root]">
107   <xsl:variable name="uri">
108    <xsl:value-of select="m:abs/@definitionURL"/>
109   </xsl:variable>
110   <xsl:text>(sqr</xsl:text>
111   <xsl:apply-templates mode="inline" select="*[2]"/>
112   <xsl:text>)</xsl:text>
113 </xsl:template>
114
115 <!-- POWER -->
116
117 <xsl:template mode="inline" match="m:apply[m:power]">
118   <xsl:variable name="uri">
119    <xsl:value-of select="m:power/@definitionURL"/>
120   </xsl:variable>
121   <xsl:apply-templates mode="inline" select="*[2]"/>
122   <SUP>
123   <xsl:apply-templates mode="inline" select="*[3]"/>
124   </SUP>
125 </xsl:template>
126
127 <!-- MIN and MAX (binari: estendere) -->
128
129  <xsl:template mode="inline" match="m:apply[m:min|m:max]">
130   <xsl:variable name="uri">
131    <xsl:value-of select="*[1]/@definitionURL"/>
132   </xsl:variable>
133   <xsl:variable name="symbol">
134    <xsl:choose>
135     <xsl:when test="m:min">
136      <xsl:value-of select="'min'"/>
137     </xsl:when>
138     <xsl:when test="m:max">
139      <xsl:value-of select="'max'"/>
140     </xsl:when>
141    </xsl:choose>
142   </xsl:variable>
143   <a>
144    <xsl:attribute name="href">
145     <xsl:call-template name="makeURL">
146      <xsl:with-param name="url" select="$uri"/>
147     </xsl:call-template>
148    </xsl:attribute>
149    <xsl:value-of select="$symbol"/>
150   </a>
151   <xsl:text>{</xsl:text>
152   <xsl:apply-templates mode="inline" select="*[2]"/>
153   <xsl:text>, </xsl:text>
154   <xsl:apply-templates mode="inline" select="*[3]"/>
155   <xsl:text>}</xsl:text>
156 </xsl:template>
157
158 <!-- **************************************************************** -->
159 <!--                   COUNTING MODE                                    -->
160 <!-- **************************************************************** -->
161
162
163 <xsl:template match="m:apply[m:limit]">
164   <xsl:param name="current_indent" select="0"/> 
165   <xsl:param name="width" select="$framewidth"/>
166   <xsl:variable name="uri">
167    <xsl:value-of select="m:limit/@definitionURL"/>
168   </xsl:variable>
169   <xsl:variable name="charlength">
170    <xsl:apply-templates select="m:limit" mode="charcount"/>
171   </xsl:variable>
172   <xsl:choose>
173     <xsl:when test="$charlength > $framewidth">
174      <a>
175      <xsl:attribute name="href">
176       <xsl:call-template name="makeURL">
177        <xsl:with-param name="url" select="$uri"/>
178       </xsl:call-template>
179      </xsl:attribute>
180      <xsl:text>lim</xsl:text>
181      </a>
182      <SUB>
183       <xsl:apply-templates select="m:bvar/m:ci"/>
184       <FONT FACE="symbol" mathcolor="blue">&#174;</FONT>
185       <xsl:apply-templates select="m:lowlimit"/>
186      </SUB>
187      <BR/> 
188      <xsl:call-template name="make_indent">
189       <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
190      </xsl:call-template>
191      <xsl:apply-templates select="*[4]">
192       <xsl:with-param name="current_indent" select="$current_indent + 5"/>
193      </xsl:apply-templates>
194     </xsl:when>
195     <xsl:otherwise>
196      <xsl:apply-templates mode="inline" select="."/>
197     </xsl:otherwise>
198    </xsl:choose>
199  </xsl:template>
200
201 <!-- DIFFERENTIATION -->
202 <xsl:template match="m:apply[m:diff]">
203   <xsl:param name="current_indent" select="0"/> 
204   <xsl:param name="width" select="$framewidth"/>
205   <xsl:variable name="uri">
206    <xsl:value-of select="m:diff/@definitionURL"/>
207   </xsl:variable>
208      <a>
209      <xsl:attribute name="href">
210       <xsl:call-template name="makeURL">
211        <xsl:with-param name="url" select="$uri"/>
212       </xsl:call-template>
213      </xsl:attribute>
214      <SUP>d</SUP>
215       <xsl:text>/</xsl:text>
216      <SUB>
217       <xsl:text>d</xsl:text>
218       <xsl:value-of select="m:bvar/m:ci"/>
219      </SUB>
220      </a>
221      <xsl:apply-templates select="*[3]">
222       <xsl:with-param name="current_indent" select="$current_indent + 5"/>
223      </xsl:apply-templates>
224  </xsl:template>
225
226
227 <!-- ABSOLUTE VALUE -->
228 <xsl:template match="m:apply[m:abs]">
229   <xsl:param name="current_indent" select="0"/> 
230   <xsl:param name="width" select="$framewidth"/>
231   <xsl:variable name="uri">
232    <xsl:value-of select="m:abs/@definitionURL"/>
233   </xsl:variable>
234   <xsl:text>|</xsl:text>
235   <xsl:apply-templates select="*[2]">
236    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
237   </xsl:apply-templates>
238   <xsl:text>|</xsl:text>
239  </xsl:template>
240
241 <!-- FACTORIAL -->
242
243 <xsl:template match="m:apply[m:fact]">
244   <xsl:param name="current_indent" select="0"/> 
245   <xsl:param name="width" select="$framewidth"/>
246   <xsl:variable name="uri">
247    <xsl:value-of select="m:abs/@definitionURL"/>
248   </xsl:variable>
249   <xsl:apply-templates select="*[2]">
250    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
251   </xsl:apply-templates>
252   <xsl:text>!</xsl:text>
253  </xsl:template>
254
255 <!-- SQUARE ROOT -->
256
257 <xsl:template match="m:apply[m:root]">
258   <xsl:param name="current_indent" select="0"/> 
259   <xsl:param name="width" select="$framewidth"/>
260   <xsl:variable name="uri">
261    <xsl:value-of select="m:abs/@definitionURL"/>
262   </xsl:variable>
263   <xsl:text>(sqr</xsl:text>
264   <xsl:apply-templates select="*[2]">
265    <xsl:with-param name="current_indent" select="$current_indent + 5"/>
266   </xsl:apply-templates>
267   <xsl:text>)</xsl:text>
268  </xsl:template>
269
270 <!-- POWER -->
271
272 <xsl:template match="m:apply[m:power]">
273   <xsl:param name="current_indent" select="0"/> 
274   <xsl:param name="width" select="$framewidth"/>
275   <xsl:variable name="uri">
276    <xsl:value-of select="m:power/@definitionURL"/>
277   </xsl:variable>
278   <xsl:apply-templates select="*[2]"/>
279   <SUP>
280   <xsl:apply-templates select="*[3]"/>
281   </SUP>
282  </xsl:template>
283
284 <!-- MIN and MAX (binari: estendere) -->
285
286  <xsl:template match="m:apply[m:min|m:max]">
287   <xsl:param name="current_indent" select="0"/> 
288   <xsl:param name="width" select="$framewidth"/>
289   <xsl:variable name="uri">
290    <xsl:value-of select="*[1]/@definitionURL"/>
291   </xsl:variable>
292   <xsl:variable name="charlength">
293    <xsl:apply-templates select="*[1]" mode="charcount"/>
294   </xsl:variable>
295   <xsl:variable name="symbol">
296    <xsl:choose>
297     <xsl:when test="m:min">
298      <xsl:value-of select="'min'"/>
299     </xsl:when>
300     <xsl:when test="m:max">
301      <xsl:value-of select="'max'"/>
302     </xsl:when>
303    </xsl:choose>
304   </xsl:variable>
305   <xsl:choose>
306     <xsl:when test="$charlength > $framewidth">
307      <a>
308      <xsl:attribute name="href">
309       <xsl:call-template name="makeURL">
310        <xsl:with-param name="url" select="$uri"/>
311       </xsl:call-template>
312      </xsl:attribute>
313      <xsl:value-of select="$symbol"/>
314      </a>
315      <xsl:text>{</xsl:text>
316      <xsl:apply-templates select="*[2]">
317       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
318      </xsl:apply-templates>
319      <xsl:text>,</xsl:text>
320      <BR/> 
321      <xsl:call-template name="make_indent">
322       <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
323      </xsl:call-template>
324      <xsl:apply-templates select="*[3]">
325       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
326      </xsl:apply-templates>
327      <xsl:text>}</xsl:text>
328     </xsl:when>
329     <xsl:otherwise>
330      <xsl:apply-templates mode="inline" select="."/>
331     </xsl:otherwise>
332    </xsl:choose>
333  </xsl:template>
334
335 <!-- COUNTING -->
336
337 <xsl:template match="m:abs|m:fact|m:root
338            |m:limit|m:diff|m:min|m:max" mode="charcount">
339 <xsl:param name="incurrent_length" select="0"/> 
340     <xsl:choose>
341     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
342      <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>
343      <xsl:choose>
344      <xsl:when test="string($siblength) = &quot;&quot;">
345       <xsl:value-of select="$incurrent_length + string-length()"/>
346      </xsl:when>
347      <xsl:otherwise>
348       <xsl:value-of select="number($siblength)"/>
349      </xsl:otherwise>
350      </xsl:choose>
351     </xsl:when>
352     <xsl:otherwise>
353      <xsl:value-of select="$incurrent_length + string-length()"/>
354     </xsl:otherwise>
355     </xsl:choose>
356 </xsl:template> 
357
358 </xsl:stylesheet> 
359
360
361
362
363
364
365