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