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