2 <!-- Copyright (C) 2000, HELM Team -->
3 <!-- This file is part of HELM, an Hypertextual, Electronic -->
4 <!-- Library of Mathematics, developed at the Computer Science -->
5 <!-- Department, University of Bologna, Italy. -->
6 <!-- HELM is free software; you can redistribute it and/or -->
7 <!-- modify it under the terms of the GNU General Public License -->
8 <!-- as published by the Free Software Foundation; either version 2 -->
9 <!-- of the License, or (at your option) any later version. -->
10 <!-- HELM is distributed in the hope that it will be useful, -->
11 <!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
12 <!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
13 <!-- GNU General Public License for more details. -->
14 <!-- You should have received a copy of the GNU General Public License -->
15 <!-- along with HELM; if not, write to the Free Software -->
16 <!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
17 <!-- MA 02111-1307, USA. -->
18 <!-- For details, see the HELM World-Wide-Web page, -->
19 <!-- http://cs.unibo.it/helm/. -->
20 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:i="http://www.cs.unibo.it/helm/InputNotationalElements" xmlns:o="http://www.cs.unibo.it/helm/OutputNotationalElements" version="1.0">
23 <xsl:variable name="leq">
25 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">£</xsl:when>
26 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">≤</xsl:when>
27 <xsl:otherwise>???</xsl:otherwise>
31 <xsl:variable name="lt">
33 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'"><</xsl:when>
34 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">< </xsl:when>
35 <xsl:otherwise>???</xsl:otherwise>
39 <xsl:variable name="geq">
41 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">³</xsl:when>
42 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">≥</xsl:when>
43 <xsl:otherwise>???</xsl:otherwise>
47 <xsl:variable name="gt">
49 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">></xsl:when>
50 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">></xsl:when>
51 <xsl:otherwise>???</xsl:otherwise>
55 <xsl:variable name="plus">
57 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">+</xsl:when>
58 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">+</xsl:when>
59 <xsl:otherwise>???</xsl:otherwise>
63 <xsl:variable name="minus">
65 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">-</xsl:when>
66 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">-</xsl:when>
67 <xsl:otherwise>???</xsl:otherwise>
71 <xsl:variable name="times">
73 <xsl:when test="$UNICODEvsSYMBOL = 'symbol'">*</xsl:when>
74 <xsl:when test="$UNICODEvsSYMBOL = 'unicode'">∗</xsl:when>
75 <xsl:otherwise>???</xsl:otherwise>
79 <xsl:variable name="min" select="'min'"/>
81 <xsl:variable name="abs" select="'|'"/>
83 <xsl:template match="m:apply[m:leq[count(*) = 0] and count(*) = 3]">
84 <xsl:param name="current_indent" select="0"/>
85 <xsl:param name="width" select="$framewidth"/>
86 <xsl:variable name="charlength">
87 <xsl:apply-templates select="." mode="root_charcount"/>
90 <xsl:when test="$width >= $charlength">
91 <xsl:apply-templates select="." mode="inline"/>
94 <xsl:text>(</xsl:text>
95 <xsl:apply-templates select="*[2]">
96 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
97 </xsl:apply-templates>
99 <xsl:call-template name="make_indent">
100 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
102 <a href="{m:leq/@definitionURL}">
104 <xsl:when test="boolean($leq)">
105 <xsl:call-template name="mksymbol">
106 <xsl:with-param name="symbol" select="$leq"/>
109 <xsl:otherwise>leq</xsl:otherwise>
112 <xsl:apply-templates select="*[3]">
113 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
114 </xsl:apply-templates>
115 <xsl:text>)</xsl:text>
119 <!-- LESS EQUAL (INLINE MODE) -->
120 <xsl:template match="m:apply[m:leq[count(*) = 0] and count(*) = 3]" mode="inline">
121 <xsl:text>(</xsl:text>
122 <xsl:apply-templates select="*[2]" mode="inline"/>
123 <a href="{m:leq/@definitionURL}">
125 <xsl:when test="boolean($leq)">
126 <xsl:call-template name="mksymbol">
127 <xsl:with-param name="symbol" select="$leq"/>
130 <xsl:otherwise>leq</xsl:otherwise>
133 <xsl:apply-templates select="*[3]" mode="inline"/>
134 <xsl:text>)</xsl:text>
136 <!-- LESS EQUAL (CHARCOUNT MODE) -->
137 <xsl:template match="m:apply[m:leq[count(*) = 0] and count(*) = 3]" mode="root_charcount">
138 <xsl:param name="incurrent_length" select="0"/>
139 <xsl:value-of select="$incurrent_length + 3"/>
142 <xsl:template match="m:apply[m:lt[count(*) = 0] and count(*) = 3]">
143 <xsl:param name="current_indent" select="0"/>
144 <xsl:param name="width" select="$framewidth"/>
145 <xsl:variable name="charlength">
146 <xsl:apply-templates select="." mode="root_charcount"/>
149 <xsl:when test="$width >= $charlength">
150 <xsl:apply-templates select="." mode="inline"/>
153 <xsl:text>(</xsl:text>
154 <xsl:apply-templates select="*[2]">
155 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
156 </xsl:apply-templates>
158 <xsl:call-template name="make_indent">
159 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
161 <a href="{m:lt/@definitionURL}">
163 <xsl:when test="boolean($lt)">
164 <xsl:call-template name="mksymbol">
165 <xsl:with-param name="symbol" select="$lt"/>
168 <xsl:otherwise>lt</xsl:otherwise>
171 <xsl:apply-templates select="*[3]">
172 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
173 </xsl:apply-templates>
174 <xsl:text>)</xsl:text>
178 <!-- LESS THAN (INLINE MODE) -->
179 <xsl:template match="m:apply[m:lt[count(*) = 0] and count(*) = 3]" mode="inline">
180 <xsl:text>(</xsl:text>
181 <xsl:apply-templates select="*[2]" mode="inline"/>
182 <a href="{m:lt/@definitionURL}">
184 <xsl:when test="boolean($lt)">
185 <xsl:call-template name="mksymbol">
186 <xsl:with-param name="symbol" select="$lt"/>
189 <xsl:otherwise>lt</xsl:otherwise>
192 <xsl:apply-templates select="*[3]" mode="inline"/>
193 <xsl:text>)</xsl:text>
195 <!-- LESS THAN (CHARCOUNT MODE) -->
196 <xsl:template match="m:apply[m:lt[count(*) = 0] and count(*) = 3]" mode="root_charcount">
197 <xsl:param name="incurrent_length" select="0"/>
198 <xsl:value-of select="$incurrent_length + 3"/>
200 <!-- GREATER EQUAL -->
201 <xsl:template match="m:apply[m:geq[count(*) = 0] and count(*) = 3]">
202 <xsl:param name="current_indent" select="0"/>
203 <xsl:param name="width" select="$framewidth"/>
204 <xsl:variable name="charlength">
205 <xsl:apply-templates select="." mode="root_charcount"/>
208 <xsl:when test="$width >= $charlength">
209 <xsl:apply-templates select="." mode="inline"/>
212 <xsl:text>(</xsl:text>
213 <xsl:apply-templates select="*[2]">
214 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
215 </xsl:apply-templates>
217 <xsl:call-template name="make_indent">
218 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
220 <a href="{m:geq/@definitionURL}">
222 <xsl:when test="boolean($geq)">
223 <xsl:call-template name="mksymbol">
224 <xsl:with-param name="symbol" select="$geq"/>
227 <xsl:otherwise>geq</xsl:otherwise>
230 <xsl:apply-templates select="*[3]">
231 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
232 </xsl:apply-templates>
233 <xsl:text>)</xsl:text>
237 <!-- GREATER EQUAL (INLINE MODE) -->
238 <xsl:template match="m:apply[m:geq[count(*) = 0] and count(*) = 3]" mode="inline">
239 <xsl:text>(</xsl:text>
240 <xsl:apply-templates select="*[2]" mode="inline"/>
241 <a href="{m:geq/@definitionURL}">
243 <xsl:when test="boolean($geq)">
244 <xsl:call-template name="mksymbol">
245 <xsl:with-param name="symbol" select="$geq"/>
248 <xsl:otherwise>geq</xsl:otherwise>
251 <xsl:apply-templates select="*[3]" mode="inline"/>
252 <xsl:text>)</xsl:text>
254 <!-- GREATER EQUAL (CHARCOUNT MODE) -->
255 <xsl:template match="m:apply[m:geq[count(*) = 0] and count(*) = 3]" mode="root_charcount">
256 <xsl:param name="incurrent_length" select="0"/>
257 <xsl:value-of select="$incurrent_length + 3"/>
259 <!-- GREATER THAN -->
260 <xsl:template match="m:apply[m:gt[count(*) = 0] and count(*) = 3]">
261 <xsl:param name="current_indent" select="0"/>
262 <xsl:param name="width" select="$framewidth"/>
263 <xsl:variable name="charlength">
264 <xsl:apply-templates select="." mode="root_charcount"/>
267 <xsl:when test="$width >= $charlength">
268 <xsl:apply-templates select="." mode="inline"/>
271 <xsl:text>(</xsl:text>
272 <xsl:apply-templates select="*[2]">
273 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
274 </xsl:apply-templates>
276 <xsl:call-template name="make_indent">
277 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
279 <a href="{m:gt/@definitionURL}">
281 <xsl:when test="boolean($gt)">
282 <xsl:call-template name="mksymbol">
283 <xsl:with-param name="symbol" select="$gt"/>
286 <xsl:otherwise>gt</xsl:otherwise>
289 <xsl:apply-templates select="*[3]">
290 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
291 </xsl:apply-templates>
292 <xsl:text>)</xsl:text>
296 <!-- GREATER THAN (INLINE MODE) -->
297 <xsl:template match="m:apply[m:gt[count(*) = 0] and count(*) = 3]" mode="inline">
298 <xsl:text>(</xsl:text>
299 <xsl:apply-templates select="*[2]" mode="inline"/>
300 <a href="{m:gt/@definitionURL}">
302 <xsl:when test="boolean($gt)">
303 <xsl:call-template name="mksymbol">
304 <xsl:with-param name="symbol" select="$gt"/>
307 <xsl:otherwise>gt</xsl:otherwise>
310 <xsl:apply-templates select="*[3]" mode="inline"/>
311 <xsl:text>)</xsl:text>
313 <!-- GREATER THAN (CHARCOUNT MODE) -->
314 <xsl:template match="m:apply[m:gt[count(*) = 0] and count(*) = 3]" mode="root_charcount">
315 <xsl:param name="incurrent_length" select="0"/>
316 <xsl:value-of select="$incurrent_length + 3"/>
319 <xsl:template match="m:apply[m:plus[count(*) = 0] and count(*) = 3]">
320 <xsl:param name="current_indent" select="0"/>
321 <xsl:param name="width" select="$framewidth"/>
322 <xsl:variable name="charlength">
323 <xsl:apply-templates select="." mode="root_charcount"/>
326 <xsl:when test="$width >= $charlength">
327 <xsl:apply-templates select="." mode="inline"/>
330 <xsl:text>(</xsl:text>
331 <xsl:apply-templates select="*[2]">
332 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
333 </xsl:apply-templates>
335 <xsl:call-template name="make_indent">
336 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
338 <a href="{m:plus/@definitionURL}">
340 <xsl:when test="boolean($plus)">
341 <xsl:call-template name="mksymbol">
342 <xsl:with-param name="symbol" select="$plus"/>
345 <xsl:otherwise>plus</xsl:otherwise>
348 <xsl:apply-templates select="*[3]">
349 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
350 </xsl:apply-templates>
351 <xsl:text>)</xsl:text>
355 <!-- PLUS (INLINE MODE) -->
356 <xsl:template match="m:apply[m:plus[count(*) = 0] and count(*) = 3]" mode="inline">
357 <xsl:text>(</xsl:text>
358 <xsl:apply-templates select="*[2]" mode="inline"/>
359 <a href="{m:plus/@definitionURL}">
361 <xsl:when test="boolean($plus)">
362 <xsl:call-template name="mksymbol">
363 <xsl:with-param name="symbol" select="$plus"/>
366 <xsl:otherwise>plus</xsl:otherwise>
369 <xsl:apply-templates select="*[3]" mode="inline"/>
370 <xsl:text>)</xsl:text>
372 <!-- PLUS (CHARCOUNT MODE) -->
373 <xsl:template match="m:apply[m:plus[count(*) = 0] and count(*) = 3]" mode="root_charcount">
374 <xsl:param name="incurrent_length" select="0"/>
375 <xsl:value-of select="$incurrent_length + 3"/>
378 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 3]">
379 <xsl:param name="current_indent" select="0"/>
380 <xsl:param name="width" select="$framewidth"/>
381 <xsl:variable name="charlength">
382 <xsl:apply-templates select="." mode="root_charcount"/>
385 <xsl:when test="$width >= $charlength">
386 <xsl:apply-templates select="." mode="inline"/>
389 <xsl:text>(</xsl:text>
390 <xsl:apply-templates select="*[2]">
391 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
392 </xsl:apply-templates>
394 <xsl:call-template name="make_indent">
395 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
397 <a href="{m:minus/@definitionURL}">
399 <xsl:when test="boolean($minus)">
400 <xsl:call-template name="mksymbol">
401 <xsl:with-param name="symbol" select="$minus"/>
404 <xsl:otherwise>minus</xsl:otherwise>
407 <xsl:apply-templates select="*[3]">
408 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
409 </xsl:apply-templates>
410 <xsl:text>)</xsl:text>
414 <!-- MINUS (INLINE MODE) -->
415 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 3]" mode="inline">
416 <xsl:text>(</xsl:text>
417 <xsl:apply-templates select="*[2]" mode="inline"/>
418 <a href="{m:minus/@definitionURL}">
420 <xsl:when test="boolean($minus)">
421 <xsl:call-template name="mksymbol">
422 <xsl:with-param name="symbol" select="$minus"/>
425 <xsl:otherwise>minus</xsl:otherwise>
428 <xsl:apply-templates select="*[3]" mode="inline"/>
429 <xsl:text>)</xsl:text>
431 <!-- MINUS (CHARCOUNT MODE) -->
432 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 3]" mode="root_charcount">
433 <xsl:param name="incurrent_length" select="0"/>
434 <xsl:value-of select="$incurrent_length + 3"/>
437 <xsl:template match="m:apply[m:times[count(*) = 0] and count(*) = 3]">
438 <xsl:param name="current_indent" select="0"/>
439 <xsl:param name="width" select="$framewidth"/>
440 <xsl:variable name="charlength">
441 <xsl:apply-templates select="." mode="root_charcount"/>
444 <xsl:when test="$width >= $charlength">
445 <xsl:apply-templates select="." mode="inline"/>
448 <xsl:text>(</xsl:text>
449 <xsl:apply-templates select="*[2]">
450 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
451 </xsl:apply-templates>
453 <xsl:call-template name="make_indent">
454 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
456 <a href="{m:times/@definitionURL}">
458 <xsl:when test="boolean($times)">
459 <xsl:call-template name="mksymbol">
460 <xsl:with-param name="symbol" select="$times"/>
463 <xsl:otherwise>times</xsl:otherwise>
466 <xsl:apply-templates select="*[3]">
467 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
468 </xsl:apply-templates>
469 <xsl:text>)</xsl:text>
473 <!-- TIMES (INLINE MODE) -->
474 <xsl:template match="m:apply[m:times[count(*) = 0] and count(*) = 3]" mode="inline">
475 <xsl:text>(</xsl:text>
476 <xsl:apply-templates select="*[2]" mode="inline"/>
477 <a href="{m:times/@definitionURL}">
479 <xsl:when test="boolean($times)">
480 <xsl:call-template name="mksymbol">
481 <xsl:with-param name="symbol" select="$times"/>
484 <xsl:otherwise>times</xsl:otherwise>
487 <xsl:apply-templates select="*[3]" mode="inline"/>
488 <xsl:text>)</xsl:text>
490 <!-- TIMES (CHARCOUNT MODE) -->
491 <xsl:template match="m:apply[m:times[count(*) = 0] and count(*) = 3]" mode="root_charcount">
492 <xsl:param name="incurrent_length" select="0"/>
493 <xsl:value-of select="$incurrent_length + 3"/>
496 <xsl:template match="m:apply[m:min[count(*) = 0] and count(*) = 3]">
497 <xsl:param name="current_indent" select="0"/>
498 <xsl:param name="width" select="$framewidth"/>
499 <xsl:variable name="charlength">
500 <xsl:apply-templates select="." mode="root_charcount"/>
503 <xsl:when test="$width >= $charlength">
504 <xsl:apply-templates select="." mode="inline"/>
507 <a href="{m:min/@definitionURL}">
509 <xsl:when test="boolean($min)">
510 <xsl:call-template name="mksymbol">
511 <xsl:with-param name="symbol" select="$min"/>
514 <xsl:otherwise>min</xsl:otherwise>
517 <xsl:text>{</xsl:text>
518 <xsl:apply-templates select="*[2]">
519 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
520 </xsl:apply-templates>
521 <xsl:text>,</xsl:text>
523 <xsl:call-template name="make_indent">
524 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
526 <xsl:apply-templates select="*[3]">
527 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
528 </xsl:apply-templates>
529 <xsl:text>}</xsl:text>
533 <!-- MIN (INLINE MODE) -->
534 <xsl:template match="m:apply[m:min[count(*) = 0] and count(*) = 3]" mode="inline">
535 <a href="{m:min/@definitionURL}">
537 <xsl:when test="boolean($min)">
538 <xsl:call-template name="mksymbol">
539 <xsl:with-param name="symbol" select="$min"/>
542 <xsl:otherwise>min</xsl:otherwise>
545 <xsl:text>{</xsl:text>
546 <xsl:apply-templates select="*[2]" mode="inline"/>
547 <xsl:text>,</xsl:text>
548 <xsl:apply-templates select="*[3]" mode="inline"/>
549 <xsl:text>}</xsl:text>
551 <!-- MIN (CHARCOUNT MODE) -->
552 <xsl:template match="m:apply[m:min[count(*) = 0] and count(*) = 3]" mode="root_charcount">
553 <xsl:param name="incurrent_length" select="0"/>
554 <xsl:value-of select="$incurrent_length + 4"/>
557 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 2]">
558 <xsl:param name="current_indent" select="0"/>
559 <xsl:param name="width" select="$framewidth"/>
560 <a href="{m:minus/@definitionURL}">
562 <xsl:when test="boolean($minus)">
563 <xsl:call-template name="mksymbol">
564 <xsl:with-param name="symbol" select="$minus"/>
567 <xsl:otherwise>minus</xsl:otherwise>
570 <xsl:apply-templates select="*[2]">
571 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
572 </xsl:apply-templates>
574 <!-- MINUS (INLINE MODE) -->
575 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 2]" mode="inline">
576 <a href="{m:minus/@definitionURL}">
578 <xsl:when test="boolean($minus)">
579 <xsl:call-template name="mksymbol">
580 <xsl:with-param name="symbol" select="$minus"/>
583 <xsl:otherwise>minus</xsl:otherwise>
586 <xsl:apply-templates select="*[2]" mode="inline"/>
588 <!-- MINUS (CHARCOUNT MODE) -->
589 <xsl:template match="m:apply[m:minus[count(*) = 0] and count(*) = 2]" mode="root_charcount">
590 <xsl:param name="incurrent_length" select="0"/>
591 <xsl:value-of select="$incurrent_length + 1"/>
593 <!-- ABSOLUTE VALUE -->
594 <xsl:template match="m:apply[m:abs[count(*) = 0] and count(*) = 2]">
595 <xsl:param name="current_indent" select="0"/>
596 <xsl:param name="width" select="$framewidth"/>
597 <a href="{m:abs/@definitionURL}">
599 <xsl:when test="boolean($abs)">
600 <xsl:call-template name="mksymbol">
601 <xsl:with-param name="symbol" select="$abs"/>
604 <xsl:otherwise>abs</xsl:otherwise>
607 <xsl:apply-templates select="*[2]">
608 <xsl:with-param name="current_indent" select="$current_indent + 2"/>
609 </xsl:apply-templates>
610 <a href="{m:abs/@definitionURL}">
612 <xsl:when test="boolean($abs)">
613 <xsl:call-template name="mksymbol">
614 <xsl:with-param name="symbol" select="$abs"/>
617 <xsl:otherwise>abs</xsl:otherwise>
621 <!-- ABSOLUTE VALUE (INLINE MODE) -->
622 <xsl:template match="m:apply[m:abs[count(*) = 0] and count(*) = 2]" mode="inline">
623 <a href="{m:abs/@definitionURL}">
625 <xsl:when test="boolean($abs)">
626 <xsl:call-template name="mksymbol">
627 <xsl:with-param name="symbol" select="$abs"/>
630 <xsl:otherwise>abs</xsl:otherwise>
633 <xsl:apply-templates select="*[2]" mode="inline"/>
634 <a href="{m:abs/@definitionURL}">
636 <xsl:when test="boolean($abs)">
637 <xsl:call-template name="mksymbol">
638 <xsl:with-param name="symbol" select="$abs"/>
641 <xsl:otherwise>abs</xsl:otherwise>
645 <!-- ABSOLUTE VALUE (CHARCOUNT MODE) -->
646 <xsl:template match="m:apply[m:abs[count(*) = 0] and count(*) = 2]" mode="root_charcount">
647 <xsl:param name="incurrent_length" select="0"/>
648 <xsl:value-of select="$incurrent_length + 2"/>