3 <!-- Copyright (C) 2000, HELM Team -->
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. -->
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. -->
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. -->
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. -->
24 <!-- For details, see the HELM World-Wide-Web page, -->
25 <!-- http://cs.unibo.it/helm/. -->
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">
30 <xsl:template name="mksymbol-init">
31 <xsl:param name="symbol" select="''"/>
33 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">
34 <xsl:variable name="fontsymbol">
36 <xsl:when test="$symbol = 'and'">
37 <xsl:value-of select="'Ù'"/>
39 <xsl:when test="$symbol = 'or'">
40 <xsl:value-of select="'Ú'"/>
42 <xsl:when test="$symbol = 'eq'">
43 <xsl:value-of select="'='"/>
45 <xsl:when test="$symbol = 'neq'">
46 <xsl:value-of select="'¹'"/>
48 <xsl:when test="$symbol = 'leq'">
49 <xsl:value-of select="'£'"/>
51 <xsl:when test="$symbol = 'lt'">
52 <xsl:value-of select="'<'"/>
54 <xsl:when test="$symbol = 'geq'">
55 <xsl:value-of select="'³'"/>
57 <xsl:when test="$symbol = 'gt'">
58 <xsl:value-of select="'>'"/>
60 <xsl:when test="$symbol = 'plus'">
61 <xsl:value-of select="'+'"/>
63 <xsl:when test="$symbol = 'times'">
64 <xsl:value-of select="'*'"/>
66 <xsl:when test="$symbol = 'divide'">
67 <xsl:value-of select="'/'"/>
69 <xsl:when test="$symbol = 'minus'">
70 <xsl:value-of select="'-'"/>
72 <xsl:when test="$symbol = 'not'">
73 <xsl:value-of select="'Ø'"/>
75 <xsl:when test="$symbol = 'exists'">
76 <xsl:value-of select="'$'"/>
79 <xsl:text>???</xsl:text>
83 <FONT FACE="symbol" color="'blue'">
84 <xsl:value-of select="$fontsymbol"/>
88 <xsl:variable name="unicodesymbol">
90 <xsl:when test="$symbol = 'and'">
91 <xsl:value-of select="'∧'"/>
93 <xsl:when test="$symbol = 'or'">
94 <xsl:value-of select="'∨'"/>
96 <xsl:when test="$symbol = 'eq'">
97 <xsl:value-of select="'='"/>
99 <xsl:when test="$symbol = 'neq'">
100 <xsl:value-of select="'≠'"/>
102 <xsl:when test="$symbol = 'leq'">
103 <xsl:value-of select="'≤'"/>
105 <xsl:when test="$symbol = 'lt'">
106 <xsl:value-of select="'< '"/>
108 <xsl:when test="$symbol = 'geq'">
109 <xsl:value-of select="'≥'"/>
111 <xsl:when test="$symbol = 'gt'">
112 <xsl:value-of select="'>'"/>
114 <xsl:when test="$symbol = 'plus'">
115 <xsl:value-of select="'+'"/>
117 <xsl:when test="$symbol = 'times'">
118 <xsl:value-of select="'∗'"/>
120 <xsl:when test="$symbol = 'divide'">
121 <xsl:value-of select="'/'"/>
123 <xsl:when test="$symbol = 'minus'">
124 <xsl:value-of select="'−'"/>
126 <xsl:when test="$symbol = 'not'">
127 <xsl:value-of select="'¬'"/>
129 <xsl:when test="$symbol = 'exists'">
130 <xsl:value-of select="'∃'"/>
133 <xsl:text>???</xsl:text>
137 <FONT color="'blue'">
138 <xsl:value-of select="$unicodesymbol"/>
145 <!--***********************************************************************-->
146 <!-- INIT style for HTML -->
147 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
148 <!--***********************************************************************-->
150 <!-- INLINE MODE : BASIC OPERATORS -->
152 <xsl:template mode="inline" match="m:infinity">
154 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">
155 <FONT FACE="symbol" color="'blue'">
156 <xsl:value-of select="'¥'"/>
160 <FONT color="'blue'">
162 <xsl:value-of select="'¥'"/>
168 <xsl:template mode="inline" match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
169 |m:geq|m:gt|m:plus|m:times|m:divide]">
170 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
171 <xsl:text>(</xsl:text>
172 <xsl:apply-templates mode="inline" select="*[2]"/>
174 <xsl:when test="$uri != ''">
176 <xsl:call-template name="mksymbol-init">
177 <xsl:with-param name="symbol" select="local-name(*[1])"/>
182 <xsl:call-template name="mksymbol-init">
183 <xsl:with-param name="symbol" select="local-name(*[1])"/>
187 <xsl:apply-templates mode="inline" select="*[3]"/>
188 <xsl:text>)</xsl:text>
191 <!-- INLINE MODE - MINUS (can be unary!) -->
193 <xsl:template mode="inline" match="m:apply[m:minus]">
194 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
196 <xsl:when test="count(child::*)=2">
198 <xsl:when test="$uri != ''">
200 <xsl:call-template name="mksymbol-init">
201 <xsl:with-param name="symbol" select="'minus'"/>
206 <xsl:call-template name="mksymbol-init">
207 <xsl:with-param name="symbol" select="'minus'"/>
211 <xsl:apply-templates mode="inline" select="*[2]"/>
214 <xsl:text>(</xsl:text>
215 <xsl:apply-templates mode="inline" select="*[2]"/>
217 <xsl:when test="$uri != ''">
219 <xsl:call-template name="mksymbol-init">
220 <xsl:with-param name="symbol" select="'minus'"/>
225 <xsl:call-template name="mksymbol-init">
226 <xsl:with-param name="symbol" select="'minus'"/>
230 <xsl:apply-templates mode="inline" select="*[3]"/>
231 <xsl:text>)</xsl:text>
236 <!-- INLINE MODE NOT -->
238 <xsl:template mode="inline" match="m:apply[m:not]">
239 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
241 <xsl:when test="$uri != ''">
243 <xsl:call-template name="mksymbol-init">
244 <xsl:with-param name="symbol" select="'not'"/>
249 <xsl:call-template name="mksymbol-init">
250 <xsl:with-param name="symbol" select="'not'"/>
254 <xsl:apply-templates mode="inline" select="*[2]"/>
257 <!-- INLINE MODE EXISTS -->
259 <xsl:template mode="inline" match="m:apply[m:exists]">
260 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
262 <xsl:when test="$uri != ''">
264 <xsl:call-template name="mksymbol-init">
265 <xsl:with-param name="symbol" select="'exists'"/>
270 <xsl:call-template name="mksymbol-init">
271 <xsl:with-param name="symbol" select="'exists'"/>
275 <xsl:apply-templates select="m:bvar/m:ci"/>
276 <xsl:text>:</xsl:text>
277 <xsl:apply-templates mode="inline" select="m:condition"/>
278 <xsl:text>.</xsl:text>
279 <xsl:apply-templates mode="inline" select="*[last()]"/>
282 <!-- COUNTING MODE -->
284 <!-- BASIC OPERATORS -->
286 <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
287 |m:geq|m:gt|m:plus|m:times|m:divide]">
288 <xsl:param name="current_indent" select="0"/>
289 <xsl:param name="width" select="$framewidth"/>
290 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
291 <xsl:variable name="charlength">
292 <xsl:apply-templates select="*[1]" mode="charcount"/>
295 <xsl:when test="$charlength > $framewidth">
296 <xsl:text>(</xsl:text>
297 <xsl:apply-templates select="*[2]">
298 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
299 </xsl:apply-templates>
301 <xsl:call-template name="make_indent">
302 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
305 <xsl:when test="$uri != ''">
307 <xsl:call-template name="mksymbol-init">
308 <xsl:with-param name="symbol" select="local-name(*[1])"/>
313 <xsl:call-template name="mksymbol-init">
314 <xsl:with-param name="symbol" select="local-name(*[1])"/>
318 <xsl:apply-templates select="*[3]">
319 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
320 </xsl:apply-templates>
321 <xsl:text>)</xsl:text>
324 <xsl:apply-templates mode="inline" select="."/>
329 <!-- MINUS (can be unary!) -->
331 <xsl:template match="m:apply[m:minus]">
332 <xsl:param name="current_indent" select="0"/>
333 <xsl:param name="width" select="$framewidth"/>
334 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
336 <xsl:when test="count(child::*)=2">
338 <xsl:when test="$uri != ''">
340 <xsl:call-template name="mksymbol-init">
341 <xsl:with-param name="symbol" select="'minus'"/>
346 <xsl:call-template name="mksymbol-init">
347 <xsl:with-param name="symbol" select="'minus'"/>
351 <xsl:apply-templates select="*[2]">
352 <xsl:with-param name="current_indent" select="$current_indent + 1"/>
353 </xsl:apply-templates>
356 <xsl:variable name="charlength">
357 <xsl:apply-templates select="*[1]" mode="charcount"/>
360 <xsl:when test="$charlength > $framewidth">
361 <xsl:text>(</xsl:text>
362 <xsl:apply-templates select="*[2]">
363 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
364 </xsl:apply-templates>
366 <xsl:call-template name="make_indent">
367 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
370 <xsl:when test="$uri != ''">
372 <xsl:call-template name="mksymbol-init">
373 <xsl:with-param name="symbol" select="'minus'"/>
378 <xsl:call-template name="mksymbol-init">
379 <xsl:with-param name="symbol" select="'minus'"/>
383 <xsl:apply-templates select="*[3]">
384 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
385 </xsl:apply-templates>
386 <xsl:text>)</xsl:text>
389 <xsl:apply-templates mode="inline" select="."/>
398 <xsl:template match="m:apply[m:not]">
399 <xsl:param name="current_indent" select="0"/>
400 <xsl:param name="width" select="$framewidth"/>
401 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
403 <xsl:when test="$uri != ''">
405 <xsl:call-template name="mksymbol-init">
406 <xsl:with-param name="symbol" select="'not'"/>
411 <xsl:call-template name="mksymbol-init">
412 <xsl:with-param name="symbol" select="'not'"/>
416 <xsl:apply-templates select="*[2]"/>
421 <xsl:template match="m:apply[m:exists]">
422 <xsl:param name="current_indent" select="0"/>
423 <xsl:param name="width" select="$framewidth"/>
424 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
425 <xsl:variable name="charlength">
426 <xsl:apply-templates select="m:exists" mode="charcount"/>
429 <xsl:when test="$charlength > $framewidth">
431 <xsl:when test="$uri != ''">
433 <xsl:call-template name="mksymbol-init">
434 <xsl:with-param name="symbol" select="'exists'"/>
439 <xsl:call-template name="mksymbol-init">
440 <xsl:with-param name="symbol" select="'exists'"/>
444 <xsl:apply-templates select="m:bvar/m:ci"/>
445 <xsl:text>:</xsl:text>
446 <xsl:apply-templates select="m:condition">
447 <xsl:with-param name="current_indent" select="$current_indent + 2 +
448 string-length(bvar/ci)"/>
449 </xsl:apply-templates>
451 <xsl:call-template name="make_indent">
452 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
454 <xsl:text>.</xsl:text>
455 <xsl:apply-templates select="*[last()]">
456 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
457 </xsl:apply-templates>
460 <xsl:apply-templates mode="inline" select="."/>
470 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
471 |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
472 <xsl:param name="incurrent_length" select="0"/>
474 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
475 <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>
477 <xsl:when test="string($siblength) = """>
478 <xsl:value-of select="$incurrent_length + string-length()"/>
481 <xsl:value-of select="number($siblength)"/>
486 <xsl:value-of select="$incurrent_length + string-length()"/>