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