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:eq|m:leq|m:lt|m:geq|m:gt">
169 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
171 <xsl:when test="$uri != ''">
173 <xsl:call-template name="mksymbol-init">
174 <xsl:with-param name="symbol" select="local-name(.)"/>
179 <xsl:call-template name="mksymbol-init">
180 <xsl:with-param name="symbol" select="local-name(.)"/>
186 <xsl:template mode="inline" match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
187 |m:geq|m:gt|m:plus|m:times|m:divide]">
188 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
189 <xsl:text>(</xsl:text>
190 <xsl:apply-templates mode="inline" select="*[2]"/>
192 <xsl:when test="$uri != ''">
194 <xsl:call-template name="mksymbol-init">
195 <xsl:with-param name="symbol" select="local-name(*[1])"/>
200 <xsl:call-template name="mksymbol-init">
201 <xsl:with-param name="symbol" select="local-name(*[1])"/>
205 <xsl:apply-templates mode="inline" select="*[3]"/>
206 <xsl:text>)</xsl:text>
209 <!-- INLINE MODE - MINUS (can be unary!) -->
211 <xsl:template mode="inline" match="m:apply[m:minus]">
212 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
214 <xsl:when test="count(child::*)=2">
216 <xsl:when test="$uri != ''">
218 <xsl:call-template name="mksymbol-init">
219 <xsl:with-param name="symbol" select="'minus'"/>
224 <xsl:call-template name="mksymbol-init">
225 <xsl:with-param name="symbol" select="'minus'"/>
229 <xsl:apply-templates mode="inline" select="*[2]"/>
232 <xsl:text>(</xsl:text>
233 <xsl:apply-templates mode="inline" select="*[2]"/>
235 <xsl:when test="$uri != ''">
237 <xsl:call-template name="mksymbol-init">
238 <xsl:with-param name="symbol" select="'minus'"/>
243 <xsl:call-template name="mksymbol-init">
244 <xsl:with-param name="symbol" select="'minus'"/>
248 <xsl:apply-templates mode="inline" select="*[3]"/>
249 <xsl:text>)</xsl:text>
254 <!-- INLINE MODE NOT -->
256 <xsl:template mode="inline" match="m:apply[m:not]">
257 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
259 <xsl:when test="$uri != ''">
261 <xsl:call-template name="mksymbol-init">
262 <xsl:with-param name="symbol" select="'not'"/>
267 <xsl:call-template name="mksymbol-init">
268 <xsl:with-param name="symbol" select="'not'"/>
272 <xsl:apply-templates mode="inline" select="*[2]"/>
275 <!-- INLINE MODE EXISTS -->
277 <xsl:template mode="inline" match="m:apply[m:exists]">
278 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
280 <xsl:when test="$uri != ''">
282 <xsl:call-template name="mksymbol-init">
283 <xsl:with-param name="symbol" select="'exists'"/>
288 <xsl:call-template name="mksymbol-init">
289 <xsl:with-param name="symbol" select="'exists'"/>
293 <xsl:apply-templates select="m:bvar/m:ci"/>
294 <xsl:text>:</xsl:text>
295 <xsl:apply-templates mode="inline" select="m:condition"/>
296 <xsl:text>.</xsl:text>
297 <xsl:apply-templates mode="inline" select="*[last()]"/>
300 <!-- COUNTING MODE -->
302 <!-- BASIC OPERATORS -->
304 <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
305 |m:geq|m:gt|m:plus|m:times|m:divide]">
306 <xsl:param name="current_indent" select="0"/>
307 <xsl:param name="width" select="$framewidth"/>
308 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
309 <xsl:variable name="charlength">
310 <xsl:apply-templates select="*[1]" mode="charcount"/>
313 <xsl:when test="$charlength > $framewidth">
314 <xsl:text>(</xsl:text>
315 <xsl:apply-templates select="*[2]">
316 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
317 </xsl:apply-templates>
319 <xsl:call-template name="make_indent">
320 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
323 <xsl:when test="$uri != ''">
325 <xsl:call-template name="mksymbol-init">
326 <xsl:with-param name="symbol" select="local-name(*[1])"/>
331 <xsl:call-template name="mksymbol-init">
332 <xsl:with-param name="symbol" select="local-name(*[1])"/>
336 <xsl:apply-templates select="*[3]">
337 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
338 </xsl:apply-templates>
339 <xsl:text>)</xsl:text>
342 <xsl:apply-templates mode="inline" select="."/>
347 <!-- MINUS (can be unary!) -->
349 <xsl:template match="m:apply[m:minus]">
350 <xsl:param name="current_indent" select="0"/>
351 <xsl:param name="width" select="$framewidth"/>
352 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
354 <xsl:when test="count(child::*)=2">
356 <xsl:when test="$uri != ''">
358 <xsl:call-template name="mksymbol-init">
359 <xsl:with-param name="symbol" select="'minus'"/>
364 <xsl:call-template name="mksymbol-init">
365 <xsl:with-param name="symbol" select="'minus'"/>
369 <xsl:apply-templates select="*[2]">
370 <xsl:with-param name="current_indent" select="$current_indent + 1"/>
371 </xsl:apply-templates>
374 <xsl:variable name="charlength">
375 <xsl:apply-templates select="*[1]" mode="charcount"/>
378 <xsl:when test="$charlength > $framewidth">
379 <xsl:text>(</xsl:text>
380 <xsl:apply-templates select="*[2]">
381 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
382 </xsl:apply-templates>
384 <xsl:call-template name="make_indent">
385 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
388 <xsl:when test="$uri != ''">
390 <xsl:call-template name="mksymbol-init">
391 <xsl:with-param name="symbol" select="'minus'"/>
396 <xsl:call-template name="mksymbol-init">
397 <xsl:with-param name="symbol" select="'minus'"/>
401 <xsl:apply-templates select="*[3]">
402 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
403 </xsl:apply-templates>
404 <xsl:text>)</xsl:text>
407 <xsl:apply-templates mode="inline" select="."/>
416 <xsl:template match="m:apply[m:not]">
417 <xsl:param name="current_indent" select="0"/>
418 <xsl:param name="width" select="$framewidth"/>
419 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
421 <xsl:when test="$uri != ''">
423 <xsl:call-template name="mksymbol-init">
424 <xsl:with-param name="symbol" select="'not'"/>
429 <xsl:call-template name="mksymbol-init">
430 <xsl:with-param name="symbol" select="'not'"/>
434 <xsl:apply-templates select="*[2]"/>
439 <xsl:template match="m:apply[m:exists]">
440 <xsl:param name="current_indent" select="0"/>
441 <xsl:param name="width" select="$framewidth"/>
442 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
443 <xsl:variable name="charlength">
444 <xsl:apply-templates select="m:exists" mode="charcount"/>
447 <xsl:when test="$charlength > $framewidth">
449 <xsl:when test="$uri != ''">
451 <xsl:call-template name="mksymbol-init">
452 <xsl:with-param name="symbol" select="'exists'"/>
457 <xsl:call-template name="mksymbol-init">
458 <xsl:with-param name="symbol" select="'exists'"/>
462 <xsl:apply-templates select="m:bvar/m:ci"/>
463 <xsl:text>:</xsl:text>
464 <xsl:apply-templates select="m:condition">
465 <xsl:with-param name="current_indent" select="$current_indent + 2 +
466 string-length(bvar/ci)"/>
467 </xsl:apply-templates>
469 <xsl:call-template name="make_indent">
470 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
472 <xsl:text>.</xsl:text>
473 <xsl:apply-templates select="*[last()]">
474 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
475 </xsl:apply-templates>
478 <xsl:apply-templates mode="inline" select="."/>
488 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
489 |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
490 <xsl:param name="incurrent_length" select="0"/>
492 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
493 <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>
495 <xsl:when test="string($siblength) = """>
496 <xsl:value-of select="$incurrent_length + string-length()"/>
499 <xsl:value-of select="number($siblength)"/>
504 <xsl:value-of select="$incurrent_length + string-length()"/>