]> 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 <!-- LIMIT -->
36
37 <xsl:template match="m:apply[m:limit]">
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:limit/@definitionURL"/>
42   </xsl:variable>
43   <xsl:variable name="charlength">
44    <xsl:apply-templates select="m:limit" mode="charcount"/>
45   </xsl:variable>
46   <xsl:choose>
47     <xsl:when test="$charlength > $framewidth">
48      <a>
49      <xsl:attribute name="href">
50       <xsl:value-of select="concat(string($header),string($uri))"/>
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 select="m:lowlimit"/>
58      </SUB>
59      <BR/> 
60      <xsl:call-template name="make_indent">
61       <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
62      </xsl:call-template>
63      <xsl:apply-templates select="*[4]">
64       <xsl:with-param name="current_indent" select="$current_indent + 5"/>
65      </xsl:apply-templates>
66     </xsl:when>
67     <xsl:otherwise>
68      <a>
69      <xsl:attribute name="href">
70       <xsl:value-of select="concat(string($header),string($uri))"/>
71      </xsl:attribute>
72      <xsl:text>lim</xsl:text>
73      </a>
74      <SUB>
75       <xsl:apply-templates select="m:bvar/m:ci"/>
76       <FONT FACE="symbol" mathcolor="blue">&#174;</FONT>
77       <xsl:apply-templates select="m:lowlimit"/>
78      </SUB>
79      <xsl:apply-templates select="*[4]">
80       <xsl:with-param name="current_indent" select="$current_indent + 5"/>
81      </xsl:apply-templates>
82     </xsl:otherwise>
83    </xsl:choose>
84  </xsl:template>
85
86 <!-- DIFFERENTIATION -->
87
88 <xsl:template match="m:apply[m:diff]">
89   <xsl:param name="current_indent" select="0"/> 
90   <xsl:param name="width" select="$framewidth"/>
91   <xsl:variable name="uri">
92    <xsl:value-of select="m:diff/@definitionURL"/>
93   </xsl:variable>
94      <a>
95      <xsl:attribute name="href">
96       <xsl:value-of select="concat(string($header),string($uri))"/>
97      </xsl:attribute>
98      <SUP>d</SUP>
99       <xsl:text>/</xsl:text>
100      <SUB>
101       <xsl:text>d</xsl:text>
102       <xsl:value-of select="m:bvar/m:ci"/>
103      </SUB>
104      </a>
105      <xsl:apply-templates select="*[3]">
106       <xsl:with-param name="current_indent" select="$current_indent + 5"/>
107      </xsl:apply-templates>
108  </xsl:template>
109
110 <!-- ABSOLUTE VALUE -->
111 <xsl:template match="m:apply[m:abs]">
112   <xsl:param name="current_indent" select="0"/> 
113   <xsl:param name="width" select="$framewidth"/>
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 select="*[2]">
119    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
120   </xsl:apply-templates>
121   <xsl:text>|</xsl:text>
122  </xsl:template>
123
124 <!-- FACTORIAL -->
125
126 <xsl:template match="m:apply[m:fact]">
127   <xsl:param name="current_indent" select="0"/> 
128   <xsl:param name="width" select="$framewidth"/>
129   <xsl:variable name="uri">
130    <xsl:value-of select="m:abs/@definitionURL"/>
131   </xsl:variable>
132   <xsl:apply-templates select="*[2]">
133    <xsl:with-param name="current_indent" select="$current_indent + 2"/>
134   </xsl:apply-templates>
135   <xsl:text>!</xsl:text>
136  </xsl:template>
137
138 <!-- SQUARE ROOT -->
139
140 <xsl:template match="m:apply[m:root]">
141   <xsl:param name="current_indent" select="0"/> 
142   <xsl:param name="width" select="$framewidth"/>
143   <xsl:variable name="uri">
144    <xsl:value-of select="m:abs/@definitionURL"/>
145   </xsl:variable>
146   <xsl:text>(sqr</xsl:text>
147   <xsl:apply-templates select="*[2]">
148    <xsl:with-param name="current_indent" select="$current_indent + 5"/>
149   </xsl:apply-templates>
150   <xsl:text>)</xsl:text>
151  </xsl:template>
152
153 <!-- POWER -->
154
155 <xsl:template match="m:apply[m:power]">
156   <xsl:param name="current_indent" select="0"/> 
157   <xsl:param name="width" select="$framewidth"/>
158   <xsl:variable name="uri">
159    <xsl:value-of select="m:power/@definitionURL"/>
160   </xsl:variable>
161   <xsl:apply-templates select="*[2]"/>
162   <SUP>
163   <xsl:apply-templates select="*[3]"/>
164   </SUP>
165  </xsl:template>
166
167 <!-- MIN and MAX (binari: estendere) -->
168
169  <xsl:template match="m:apply[m:min|m:max]">
170   <xsl:param name="current_indent" select="0"/> 
171   <xsl:param name="width" select="$framewidth"/>
172   <xsl:variable name="uri">
173    <xsl:value-of select="*[1]/@definitionURL"/>
174   </xsl:variable>
175   <xsl:variable name="charlength">
176    <xsl:apply-templates select="*[1]" mode="charcount"/>
177   </xsl:variable>
178   <xsl:variable name="symbol">
179    <xsl:choose>
180     <xsl:when test="m:min">
181      <xsl:value-of select="'min'"/>
182     </xsl:when>
183     <xsl:when test="m:max">
184      <xsl:value-of select="'max'"/>
185     </xsl:when>
186    </xsl:choose>
187   </xsl:variable>
188   <xsl:choose>
189     <xsl:when test="$charlength > $framewidth">
190      <a>
191      <xsl:attribute name="href">
192       <xsl:value-of select="concat(string($header),string($uri))"/>
193      </xsl:attribute>
194      <xsl:value-of select="$symbol"/>
195      </a>
196      <xsl:text>{</xsl:text>
197      <xsl:apply-templates select="*[2]">
198       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
199      </xsl:apply-templates>
200      <xsl:text>,</xsl:text>
201      <BR/> 
202      <xsl:call-template name="make_indent">
203       <xsl:with-param name="current_indent" select="$current_indent + 5"/> 
204      </xsl:call-template>
205      <xsl:apply-templates select="*[3]">
206       <xsl:with-param name="current_indent" select="$current_indent + 2"/>
207      </xsl:apply-templates>
208      <xsl:text>}</xsl:text>
209     </xsl:when>
210     <xsl:otherwise>
211      <a>
212      <xsl:attribute name="href">
213       <xsl:value-of select="concat(string($header),string($uri))"/>
214      </xsl:attribute>
215      <xsl:value-of select="$symbol"/>
216      </a>
217      <xsl:text>{</xsl:text>
218      <xsl:apply-templates select="*[2]"/>
219      <xsl:text>, </xsl:text>
220      <xsl:apply-templates select="*[3]"/>
221      <xsl:text>}</xsl:text>
222     </xsl:otherwise>
223    </xsl:choose>
224  </xsl:template>
225
226 <!-- COUNTING -->
227
228 <xsl:template match="m:abs|m:fact|m:root
229            |m:limit|m:diff|m:min|m:max" mode="charcount">
230 <xsl:param name="incurrent_length" select="0"/> 
231     <xsl:choose>
232     <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
233      <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>
234      <xsl:choose>
235      <xsl:when test="string($siblength) = &quot;&quot;">
236       <xsl:value-of select="$incurrent_length + string-length()"/>
237      </xsl:when>
238      <xsl:otherwise>
239       <xsl:value-of select="number($siblength)"/>
240      </xsl:otherwise>
241      </xsl:choose>
242     </xsl:when>
243     <xsl:otherwise>
244      <xsl:value-of select="$incurrent_length + string-length()"/>
245     </xsl:otherwise>
246     </xsl:choose>
247 </xsl:template> 
248
249 </xsl:stylesheet> 
250
251
252
253
254
255
256