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 = 'minus'">
67 <xsl:value-of select="'-'"/>
69 <xsl:when test="$symbol = 'not'">
70 <xsl:value-of select="'Ø'"/>
72 <xsl:when test="$symbol = 'exists'">
73 <xsl:value-of select="'$'"/>
76 <xsl:text>???</xsl:text>
80 <FONT FACE="symbol" color="'blue'">
81 <xsl:value-of select="$fontsymbol"/>
85 <xsl:variable name="unicodesymbol">
87 <xsl:when test="$symbol = 'and'">
88 <xsl:value-of select="'∧'"/>
90 <xsl:when test="$symbol = 'or'">
91 <xsl:value-of select="'∨'"/>
93 <xsl:when test="$symbol = 'eq'">
94 <xsl:value-of select="'='"/>
96 <xsl:when test="$symbol = 'neq'">
97 <xsl:value-of select="'≠'"/>
99 <xsl:when test="$symbol = 'leq'">
100 <xsl:value-of select="'≤'"/>
102 <xsl:when test="$symbol = 'lt'">
103 <xsl:value-of select="'< '"/>
105 <xsl:when test="$symbol = 'geq'">
106 <xsl:value-of select="'≥'"/>
108 <xsl:when test="$symbol = 'gt'">
109 <xsl:value-of select="'>'"/>
111 <xsl:when test="$symbol = 'plus'">
112 <xsl:value-of select="'+'"/>
114 <xsl:when test="$symbol = 'times'">
115 <xsl:value-of select="'∗'"/>
117 <xsl:when test="$symbol = 'minus'">
118 <xsl:value-of select="'−'"/>
120 <xsl:when test="$symbol = 'not'">
121 <xsl:value-of select="'¬'"/>
123 <xsl:when test="$symbol = 'exists'">
124 <xsl:value-of select="'∃'"/>
127 <xsl:text>???</xsl:text>
131 <FONT color="'blue'">
132 <xsl:value-of select="$unicodesymbol"/>
139 <!--***********************************************************************-->
140 <!-- INIT style for HTML -->
141 <!-- HELM Group: Asperti, Padovani, Sacerdoti, Schena -->
142 <!--***********************************************************************-->
144 <!-- INLINE MODE : BASIC OPERATORS -->
146 <xsl:template mode="inline" match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
147 |m:geq|m:gt|m:plus|m:times]">
148 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
149 <xsl:text>(</xsl:text>
150 <xsl:apply-templates mode="inline" select="*[2]"/>
152 <xsl:when test="$uri != ''">
154 <xsl:call-template name="mksymbol-init">
155 <xsl:with-param name="symbol" select="local-name(*[1])"/>
160 <xsl:call-template name="mksymbol-init">
161 <xsl:with-param name="symbol" select="local-name(*[1])"/>
165 <xsl:apply-templates mode="inline" select="*[3]"/>
166 <xsl:text>)</xsl:text>
169 <!-- INLINE MODE - MINUS (can be unary!) -->
171 <xsl:template mode="inline" match="m:apply[m:minus]">
172 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
174 <xsl:when test="count(child::*)=2">
176 <xsl:when test="$uri != ''">
178 <xsl:call-template name="mksymbol-init">
179 <xsl:with-param name="symbol" select="'minus'"/>
184 <xsl:call-template name="mksymbol-init">
185 <xsl:with-param name="symbol" select="'minus'"/>
189 <xsl:apply-templates mode="inline" select="*[2]"/>
192 <xsl:text>(</xsl:text>
193 <xsl:apply-templates mode="inline" select="*[2]"/>
195 <xsl:when test="$uri != ''">
197 <xsl:call-template name="mksymbol-init">
198 <xsl:with-param name="symbol" select="'minus'"/>
203 <xsl:call-template name="mksymbol-init">
204 <xsl:with-param name="symbol" select="'minus'"/>
208 <xsl:apply-templates mode="inline" select="*[3]"/>
209 <xsl:text>)</xsl:text>
214 <!-- INLINE MODE NOT -->
216 <xsl:template mode="inline" match="m:apply[m:not]">
217 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
219 <xsl:when test="$uri != ''">
221 <xsl:call-template name="mksymbol-init">
222 <xsl:with-param name="symbol" select="'not'"/>
227 <xsl:call-template name="mksymbol-init">
228 <xsl:with-param name="symbol" select="'not'"/>
232 <xsl:apply-templates mode="inline" select="*[2]"/>
235 <!-- INLINE MODE EXISTS -->
237 <xsl:template mode="inline" match="m:apply[m:exists]">
238 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
240 <xsl:when test="$uri != ''">
242 <xsl:call-template name="mksymbol-init">
243 <xsl:with-param name="symbol" select="'exists'"/>
248 <xsl:call-template name="mksymbol-init">
249 <xsl:with-param name="symbol" select="'exists'"/>
253 <xsl:apply-templates select="m:bvar/m:ci"/>
254 <xsl:text>:</xsl:text>
255 <xsl:apply-templates mode="inline" select="m:condition"/>
256 <xsl:text>.</xsl:text>
257 <xsl:apply-templates mode="inline" select="*[last()]"/>
260 <!-- COUNTING MODE -->
262 <!-- BASIC OPERATORS -->
264 <xsl:template match="m:apply[m:and|m:or|m:eq|m:neq|m:leq|m:lt
265 |m:geq|m:gt|m:plus|m:times]">
266 <xsl:param name="current_indent" select="0"/>
267 <xsl:param name="width" select="$framewidth"/>
268 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
269 <xsl:variable name="charlength">
270 <xsl:apply-templates select="*[1]" mode="charcount"/>
273 <xsl:when test="$charlength > $framewidth">
274 <xsl:text>(</xsl:text>
275 <xsl:apply-templates select="*[2]">
276 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
277 </xsl:apply-templates>
279 <xsl:call-template name="make_indent">
280 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
283 <xsl:when test="$uri != ''">
285 <xsl:call-template name="mksymbol-init">
286 <xsl:with-param name="symbol" select="local-name(*[1])"/>
291 <xsl:call-template name="mksymbol-init">
292 <xsl:with-param name="symbol" select="local-name(*[1])"/>
296 <xsl:apply-templates select="*[3]">
297 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
298 </xsl:apply-templates>
299 <xsl:text>)</xsl:text>
302 <xsl:apply-templates mode="inline" select="."/>
307 <!-- MINUS (can be unary!) -->
309 <xsl:template match="m:apply[m:minus]">
310 <xsl:param name="current_indent" select="0"/>
311 <xsl:param name="width" select="$framewidth"/>
312 <xsl:variable name="uri"><xsl:value-of select="*[1]/@definitionURL"/></xsl:variable>
314 <xsl:when test="count(child::*)=2">
316 <xsl:when test="$uri != ''">
318 <xsl:call-template name="mksymbol-init">
319 <xsl:with-param name="symbol" select="'minus'"/>
324 <xsl:call-template name="mksymbol-init">
325 <xsl:with-param name="symbol" select="'minus'"/>
329 <xsl:apply-templates select="*[2]">
330 <xsl:with-param name="current_indent" select="$current_indent + 1"/>
331 </xsl:apply-templates>
334 <xsl:variable name="charlength">
335 <xsl:apply-templates select="*[1]" mode="charcount"/>
338 <xsl:when test="$charlength > $framewidth">
339 <xsl:text>(</xsl:text>
340 <xsl:apply-templates select="*[2]">
341 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
342 </xsl:apply-templates>
344 <xsl:call-template name="make_indent">
345 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
348 <xsl:when test="$uri != ''">
350 <xsl:call-template name="mksymbol-init">
351 <xsl:with-param name="symbol" select="'minus'"/>
356 <xsl:call-template name="mksymbol-init">
357 <xsl:with-param name="symbol" select="'minus'"/>
361 <xsl:apply-templates select="*[3]">
362 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
363 </xsl:apply-templates>
364 <xsl:text>)</xsl:text>
367 <xsl:apply-templates mode="inline" select="."/>
376 <xsl:template match="m:apply[m:not]">
377 <xsl:param name="current_indent" select="0"/>
378 <xsl:param name="width" select="$framewidth"/>
379 <xsl:variable name="uri"><xsl:value-of select="m:not/@definitionURL"/></xsl:variable>
381 <xsl:when test="$uri != ''">
383 <xsl:call-template name="mksymbol-init">
384 <xsl:with-param name="symbol" select="'not'"/>
389 <xsl:call-template name="mksymbol-init">
390 <xsl:with-param name="symbol" select="'not'"/>
394 <xsl:apply-templates select="*[2]"/>
399 <xsl:template match="m:apply[m:exists]">
400 <xsl:param name="current_indent" select="0"/>
401 <xsl:param name="width" select="$framewidth"/>
402 <xsl:variable name="uri"><xsl:value-of select="m:exists/@definitionURL"/></xsl:variable>
403 <xsl:variable name="charlength">
404 <xsl:apply-templates select="m:exists" mode="charcount"/>
407 <xsl:when test="$charlength > $framewidth">
409 <xsl:when test="$uri != ''">
411 <xsl:call-template name="mksymbol-init">
412 <xsl:with-param name="symbol" select="'exists'"/>
417 <xsl:call-template name="mksymbol-init">
418 <xsl:with-param name="symbol" select="'exists'"/>
422 <xsl:apply-templates select="m:bvar/m:ci"/>
423 <xsl:text>:</xsl:text>
424 <xsl:apply-templates select="m:condition">
425 <xsl:with-param name="current_indent" select="$current_indent + 2 +
426 string-length(bvar/ci)"/>
427 </xsl:apply-templates>
429 <xsl:call-template name="make_indent">
430 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
432 <xsl:text>.</xsl:text>
433 <xsl:apply-templates select="*[last()]">
434 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
435 </xsl:apply-templates>
438 <xsl:apply-templates mode="inline" select="."/>
448 <xsl:template match="m:cn|m:and|m:or|m:not|m:exists|m:eq|m:neq
449 |m:lt|m:leq|m:gt|m:geq|m:plus|m:minus|m:times" mode="charcount">
450 <xsl:param name="incurrent_length" select="0"/>
452 <xsl:when test="$framewidth >= ($incurrent_length + string-length())">
453 <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>
455 <xsl:when test="string($siblength) = """>
456 <xsl:value-of select="$incurrent_length + string-length()"/>
459 <xsl:value-of select="number($siblength)"/>
464 <xsl:value-of select="$incurrent_length + string-length()"/>