3 <!-- ====================================================== -->
4 <!-- XSL Transform of MathML content to MathML presentation -->
5 <!-- By Igor Rodionov, Computer Science Department of -->
6 <!-- the University of Western Ontario, London, Canada -->
7 <!-- Complies with the W3C Working Draft from Dec.3, 1999 -->
8 <!-- Version x.xx from Feb. 18, 2000 -->
9 <!-- Comments to: igor@csd.uwo.ca -->
11 <!-- (C) Copyright 1999, 2000 Symbolic Computation -->
12 <!-- Laboratory, University of Western Ontario. -->
13 <!-- ====================================================== -->
15 <!-- ====================================================== -->
16 <!-- May 11, 2000 - HELM group: -->
17 <!-- Added the namespace prefix to all the output elements -->
18 <!-- Changed the mml prefix into m -->
19 <!-- Swapped math element out of the semantic element -->
20 <!-- Added the declaration of the xlink namespace -->
21 <!-- ====================================================== -->
23 <xsl:stylesheet id="mml2mml"
25 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26 xmlns:m="http://www.w3.org/1998/Math/MathML"
27 xmlns:xlink="http://www.w3.org/1999/xlink">
29 <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
31 <!-- ***************************************************** -->
32 <!-- Parameters affectin' stylesheet's run-time behavior -->
33 <!-- ***************************************************** -->
35 <!-- SEM_SW: -1 - strip off all semantics
36 0 - pass semantics "as is" (default)
37 1 - add semantics at top level only
38 2 - add semantics at all levels
39 3 - semantics at top level with cross-references
41 <!-- HELM: SEM_SW was 0 -->
42 <xsl:param name="SEM_SW" select="1"/>
44 <!-- Miscellaneous Variable Definitions -->
46 <xsl:variable name="NO" select="0"/>
47 <xsl:variable name="YES" select="1"/>
48 <xsl:variable name="PAR_NO" select="-7"/>
49 <xsl:variable name="PAR_YES" select="-5"/>
50 <xsl:variable name="PAR_SAME" select="-3"/>
51 <xsl:variable name="NO_PARAM" select="-1"/>
53 <!-- Operator Precedence Definitions -->
55 <xsl:variable name="NO_PREC" select="0"/>
56 <xsl:variable name="UNION_PREC" select="1"/>
57 <xsl:variable name="SETDIFF_PREC" select="1"/>
58 <xsl:variable name="INTERSECT_PREC" select="3"/>
59 <xsl:variable name="OR_PREC" select="5"/>
60 <xsl:variable name="XOR_PREC" select="5"/>
61 <xsl:variable name="AND_PREC" select="7"/>
62 <xsl:variable name="PLUS_PREC" select="9"/>
63 <xsl:variable name="MINUS_PREC" select="9"/>
64 <xsl:variable name="MUL_PREC" select="11"/>
65 <xsl:variable name="DIV_PREC" select="11"/>
66 <xsl:variable name="NEG_PREC" select="13"/>
67 <xsl:variable name="FUNCTION_PREC" select="99"/>
70 <!-- THE TOPMOST ELEMENT: MATH -->
72 <xsl:template match = "m:math">
74 <xsl:when test="$SEM_SW>0">
75 <!-- HELM: deleted math (we have already inserted at object level) -->
78 <xsl:apply-templates mode = "semantics"/>
79 <m:annotation-xml encoding="MathML">
80 <xsl:copy-of select = "*"/>
87 <xsl:apply-templates mode = "semantics"/>
95 <xsl:template match = "m:*" mode = "semantics">
96 <xsl:param name="IN_PREC" select="$NO_PREC"/>
97 <xsl:param name="PARAM" select="$NO_PARAM"/>
98 <xsl:param name="PAREN" select="$PAR_NO"/>
99 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
101 <xsl:when test="$SEM_SW=-1 and self::m:semantics">
102 <xsl:apply-templates select="*[1]">
103 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
104 <xsl:with-param name="PARAM" select="$PARAM"/>
105 <xsl:with-param name="PAREN" select="$PAREN"/>
106 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
107 </xsl:apply-templates>
109 <xsl:when test="$SEM_SW=0 and self::m:semantics">
111 <xsl:apply-templates select="*[1]">
112 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
113 <xsl:with-param name="PARAM" select="$PARAM"/>
114 <xsl:with-param name="PAREN" select="$PAREN"/>
115 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
116 </xsl:apply-templates>
117 <xsl:copy-of select="m:annotation-xml"/>
120 <xsl:when test="$SEM_SW=2">
123 <xsl:when test="self::m:semantics">
124 <xsl:apply-templates select="*[1]">
125 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
126 <xsl:with-param name="PARAM" select="$PARAM"/>
127 <xsl:with-param name="PAREN" select="$PAREN"/>
128 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
129 </xsl:apply-templates>
130 <xsl:copy-of select="m:annotation-xml"/>
133 <xsl:apply-templates select=".">
134 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
135 <xsl:with-param name="PARAM" select="$PARAM"/>
136 <xsl:with-param name="PAREN" select="$PAREN"/>
137 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
138 </xsl:apply-templates>
139 <m:annotation-xml encoding="MathML">
140 <xsl:copy-of select="."/>
146 <xsl:when test="$SEM_SW=3 and @id">
147 <m:mrow idref="{@id}">
148 <xsl:apply-templates select=".">
149 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
150 <xsl:with-param name="PARAM" select="$PARAM"/>
151 <xsl:with-param name="PAREN" select="$PAREN"/>
152 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
153 </xsl:apply-templates>
157 <xsl:apply-templates select=".">
158 <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
159 <xsl:with-param name="PARAM" select="$PARAM"/>
160 <xsl:with-param name="PAREN" select="$PAREN"/>
161 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
162 </xsl:apply-templates>
167 <xsl:template match = "m:semantics">
168 <xsl:apply-templates select="*[1]" mode = "semantics"/>
172 <!-- BASIC ELEMENTS -->
174 <xsl:template match = "m:cn">
175 <xsl:param name="IN_PREC" select="$NO_PREC"/>
176 <xsl:param name="PAREN" select="$PAR_NO"/>
177 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
179 <xsl:when test=". < 0 and $IN_PREC > 0 and $PAREN=$PAR_NO and $PAR_NO_IGNORE=$NO">
180 <m:mfenced separators="">
181 <xsl:apply-templates select="." mode="cn"/>
185 <xsl:apply-templates select="." mode="cn"/>
190 <xsl:template match = "m:cn" mode="cn">
192 <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
194 <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
195 <m:mn> <xsl:value-of select="@base"/> </m:mn>
198 <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
199 <m:mfenced separators="">
200 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
201 <xsl:if test="text()[2] < 0">
203 <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
205 <xsl:if test="not(text()[2] < 0)">
207 <xsl:apply-templates select="text()[2]" mode = "semantics"/>
209 <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
213 <xsl:when test="@type='complex' and @base and child::m:sep[1]">
215 <m:mfenced separators="">
216 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
217 <xsl:if test="text()[2] < 0">
219 <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
221 <xsl:if test="not(text()[2] < 0)">
223 <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
225 <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
228 <m:mn> <xsl:value-of select="@base"/> </m:mn>
231 <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
233 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
235 <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
238 <xsl:when test="@type='rational' and @base and child::m:sep[1]">
240 <m:mfenced separators="">
241 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
243 <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
245 <m:mn> <xsl:value-of select="@base"/> </m:mn>
248 <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
251 <m:mfenced separators=",">
252 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
253 <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
257 <xsl:when test="@type='polar' and @base and child::m:sep[1]">
261 <m:mfenced separators=",">
262 <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
263 <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
266 <m:mn> <xsl:value-of select="@base"/> </m:mn>
270 <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
275 <xsl:template match = "m:ci">
277 <xsl:when test="@type='vector' or @type=matrix or @type=set">
278 <m:mi fontweight="bold"> <xsl:apply-templates mode = "semantics"/> </m:mi>
281 <!-- HELM: aggiunta choose temporanea per HREF invece di:
282 <m:mi> <xsl:apply-templates mode = "semantics"/> </m:mi>-->
284 <xsl:when test="string(@definitionURL) = """>
285 <m:mi> <xsl:apply-templates mode = "semantics"/> </m:mi>
288 <m:mi xlink:href="{@definitionURL}"> <xsl:apply-templates mode = "semantics"/> </m:mi>
295 <xsl:template match = "m:csymbol">
297 <xsl:when test="*[1]">
298 <xsl:copy-of select = "*"/>
301 <m:mo> <xsl:apply-templates mode = "semantics"/> </m:mo>
307 <!-- BASIC CONTENT ELEMENTS -->
309 <xsl:template match = "m:apply[m:fn[1]]">
311 <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
312 <m:mfenced separators=",">
313 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
318 <xsl:template match = "m:fn">
319 <xsl:apply-templates select = "*[1]" mode = "semantics">
320 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
321 </xsl:apply-templates>
324 <xsl:template match = "m:interval">
326 <xsl:when test="@closure='closed'">
327 <m:mfenced open="[" close="]" separators=",">
328 <xsl:apply-templates mode = "semantics"/>
331 <xsl:when test="@closure='open'">
332 <m:mfenced separators=",">
333 <xsl:apply-templates mode = "semantics"/>
336 <xsl:when test="@closure='open-closed'">
337 <m:mfenced open="(" close="]" separators=",">
338 <xsl:apply-templates mode = "semantics"/>
341 <xsl:when test="@closure='closed-open'">
342 <m:mfenced open="[" close=")" separators=",">
343 <xsl:apply-templates mode = "semantics"/>
347 <m:mfenced open="[" close="]" separators=",">
348 <xsl:apply-templates mode = "semantics"/>
354 <xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
356 <xsl:apply-templates select = "*[1]" mode = "semantics"/>
357 <m:mfenced separators=",">
358 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
363 <xsl:template match = "m:apply[*[1][self::m:inverse]]">
365 <xsl:when test="*[2]=m:exp">
368 <xsl:when test="*[2]=m:ln | m:log">
371 <xsl:when test="*[2]=m:sin">
374 <xsl:when test="*[2]=m:cos">
377 <xsl:when test="*[2]=m:tan">
380 <xsl:when test="*[2]=m:sec">
383 <xsl:when test="*[2]=m:csc">
386 <xsl:when test="*[2]=m:cot">
389 <xsl:when test="*[2]=m:sinh">
392 <xsl:when test="*[2]=m:cosh">
395 <xsl:when test="*[2]=m:tanh">
398 <xsl:when test="*[2]=m:sech">
401 <xsl:when test="*[2]=m:csch">
404 <xsl:when test="*[2]=m:coth">
407 <xsl:when test="*[2]=m:arcsin">
410 <xsl:when test="*[2]=m:arccos">
413 <xsl:when test="*[2]=m:arctan">
418 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
427 <xsl:template match = "m:sep"/>
429 <xsl:template match = "m:condition">
431 <xsl:when test="parent::m:apply[m:forall[1]]"/>
433 <xsl:if test="not(*[2])">
434 <xsl:apply-templates mode = "semantics"/>
438 <xsl:apply-templates mode = "semantics"/>
445 <xsl:template match = "m:declare"/>
447 <xsl:template match = "m:lambda">
449 <m:mo> Λ </m:mo>
450 <m:mfenced separators=",">
451 <xsl:for-each select = "*">
453 <xsl:when test="self::m:ci or self::m:cn">
454 <xsl:apply-templates select = "." mode="semantics"/>
458 <xsl:apply-templates select = "." mode="semantics"/>
467 <xsl:template match = "m:apply[m:*[1][self::m:apply[m:compose[1]]]]">
469 <xsl:apply-templates select = "*[1]" mode = "semantics"/>
470 <m:mfenced separators=",">
471 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
476 <xsl:template match = "m:apply[*[1][self::m:compose]]">
477 <m:mfenced separators="">
478 <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] | self::m:fn]" mode="semantics"/>
479 <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] | self::m:fn]">
480 <m:mo> <mchar name="SmallCircle"/> </m:mo>
481 <xsl:apply-templates select = "." mode="semantics"/>
486 <xsl:template match = "m:ident">
491 <!-- ARITHMETIC, ALGEBRA & LOGIC -->
493 <xsl:template match = "m:apply[m:quotient[1]]">
494 <m:mfenced open="⌊" close="⌋" separators="">
495 <xsl:apply-templates select="*[2]" mode = "semantics">
496 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
497 </xsl:apply-templates>
499 <xsl:apply-templates select="*[3]" mode = "semantics">
500 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
501 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
502 </xsl:apply-templates>
506 <xsl:template match = "m:apply[*[1][self::m:exp]]">
509 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
513 <xsl:template match = "m:apply[m:factorial[1]]">
515 <xsl:apply-templates select = "*[2]" mode = "semantics">
516 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
517 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
518 </xsl:apply-templates>
523 <xsl:template match = "m:apply[m:max[1] | m:min[1]]">
525 <xsl:if test="*[2]=m:bvar">
527 <xsl:if test="*[1]=m:max">
530 <xsl:if test="*[1]=m:min">
533 <xsl:apply-templates select="*[2]" mode = "semantics"/>
535 <xsl:if test="*[3]=m:condition">
536 <m:mfenced open="{{" close="}}" separators="">
537 <m:mfenced open="" close="" separators=",">
538 <xsl:for-each select = "*[position()>3]">
539 <xsl:apply-templates select = "." mode="semantics"/>
543 <xsl:apply-templates select="*[3]" mode = "semantics"/>
546 <xsl:if test="not(*[3]=m:condition)">
547 <m:mfenced open="{{" close="}}" separators=",">
548 <xsl:for-each select = "*[position()>2]">
549 <xsl:apply-templates select = "." mode="semantics"/>
554 <xsl:if test="*[2]=m:condition">
555 <xsl:if test="*[1]=m:max">
558 <xsl:if test="*[1]=m:min">
561 <m:mfenced open="{{" close="}}" separators="">
563 <m:mfenced open="" close="" separators=",">
564 <xsl:for-each select = "*[position()>2]">
565 <xsl:apply-templates select = "." mode="semantics"/>
570 <xsl:apply-templates select="*[2]" mode = "semantics"/>
573 <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
574 <xsl:if test="*[1]=m:max">
577 <xsl:if test="*[1]=m:min">
580 <m:mfenced open="{{" close="}}" separators=",">
581 <xsl:for-each select = "*[position()>1]">
582 <xsl:apply-templates select = "." mode="semantics"/>
589 <xsl:template match = "m:apply[m:minus[1]]">
590 <xsl:param name="IN_PREC" select="$NO_PREC"/>
591 <xsl:param name="PARAM" select="$NO_PARAM"/>
592 <xsl:param name="PAREN" select="$PAR_NO"/>
593 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
595 <xsl:when test="$IN_PREC > $MINUS_PREC or $IN_PREC=$MINUS_PREC and $PARAM=$PAR_SAME">
596 <m:mfenced separators="">
597 <xsl:apply-templates select="." mode="minus">
598 <xsl:with-param name="PARAM" select="$PARAM"/>
599 <xsl:with-param name="PAREN" select="$PAR_YES"/>
600 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
601 </xsl:apply-templates>
604 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
605 <xsl:apply-templates select="." mode="minus">
606 <xsl:with-param name="PARAM" select="$PARAM"/>
607 <xsl:with-param name="PAREN" select="$PAREN"/>
608 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
609 </xsl:apply-templates>
613 <xsl:apply-templates select="." mode="minus">
614 <xsl:with-param name="PARAM" select="$PARAM"/>
615 <xsl:with-param name="PAREN" select="$PAREN"/>
616 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
617 </xsl:apply-templates>
623 <xsl:template match = "m:apply[m:minus[1]]" mode="minus">
624 <xsl:param name="PARAM" select="$NO_PARAM"/>
625 <xsl:param name="PAREN" select="$PAR_NO"/>
626 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
627 <xsl:if test="not(*[3])">
629 <xsl:apply-templates select="*[2]" mode = "semantics">
630 <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
631 <xsl:with-param name="PAREN" select="$PAREN"/>
632 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
633 </xsl:apply-templates>
636 <xsl:apply-templates select="*[2]" mode = "semantics">
637 <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
638 <xsl:with-param name="PARAM" select="$PARAM"/>
639 <xsl:with-param name="PAREN" select="$PAREN"/>
640 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
641 </xsl:apply-templates>
643 <xsl:apply-templates select="*[3]" mode = "semantics">
644 <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
645 <xsl:with-param name="PARAM" select="$PAR_SAME"/>
646 <xsl:with-param name="PAREN" select="$PAREN"/>
647 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
648 </xsl:apply-templates>
652 <xsl:template match = "m:apply[m:plus[1]]">
653 <xsl:param name="IN_PREC" select="$NO_PREC"/>
654 <xsl:param name="PARAM" select="$NO_PARAM"/>
655 <xsl:param name="PAREN" select="$PAR_NO"/>
656 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
658 <xsl:when test="$IN_PREC > $PLUS_PREC or $IN_PREC=$PLUS_PREC and $PARAM=$PAR_SAME">
659 <m:mfenced separators="">
660 <xsl:apply-templates select="." mode="plus">
661 <xsl:with-param name="PARAM" select="$IN_PREC"/>
662 <xsl:with-param name="PAREN" select="$PAR_YES"/>
663 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
664 </xsl:apply-templates>
667 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
668 <xsl:apply-templates select="." mode="plus">
669 <xsl:with-param name="PARAM" select="$PARAM"/>
670 <xsl:with-param name="PAREN" select="$PAREN"/>
671 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
672 </xsl:apply-templates>
676 <xsl:apply-templates select="." mode="plus">
677 <xsl:with-param name="PARAM" select="$IN_PREC"/>
678 <xsl:with-param name="PAREN" select="$PAREN"/>
679 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
680 </xsl:apply-templates>
686 <xsl:template match = "m:apply[m:plus[1]]" mode="plus">
687 <xsl:param name="PARAM" select="$NO_PARAM"/>
688 <xsl:param name="PAREN" select="$PAR_NO"/>
689 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
691 <xsl:apply-templates select="*[2]" mode = "semantics">
692 <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
693 <xsl:with-param name="PARAM" select="$PARAM"/>
694 <xsl:with-param name="PAREN" select="$PAREN"/>
695 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
696 </xsl:apply-templates>
697 <xsl:for-each select = "*[position()>2]">
699 <xsl:when test=". < 0">
701 <m:mn> <xsl:value-of select="-."/> </m:mn>
703 <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
704 <xsl:apply-templates select="." mode = "semantics">
705 <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
706 <xsl:with-param name="PAREN" select="$PAREN"/>
707 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
708 </xsl:apply-templates>
712 <xsl:apply-templates select="." mode = "semantics">
713 <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
714 <xsl:with-param name="PAREN" select="$PAREN"/>
715 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
716 </xsl:apply-templates>
723 <xsl:template match = "m:apply[m:power[1]]">
725 <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] | m:gcd[1] | m:sin[1] | m:cos[1] | m:tan[1] | m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] | m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] | m:coth[1] | m:arcsin[1] | m:arccos[1] | m:arctan[1]]">
726 <xsl:apply-templates select="*[2]" mode = "semantics"/>
730 <xsl:apply-templates select = "*[2]" mode = "semantics">
731 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
732 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
733 </xsl:apply-templates>
734 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
740 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
741 <xsl:param name="IN_PREC" select="$NO_PREC"/>
742 <xsl:param name="PARAM" select="$NO_PARAM"/>
743 <xsl:param name="PAREN" select="$PAR_NO"/>
744 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
746 <xsl:when test="$IN_PREC > $DIV_PREC or $IN_PREC=$DIV_PREC and $PARAM=$PAR_SAME">
747 <m:mfenced separators="">
748 <xsl:apply-templates select="." mode="remdiv">
749 <xsl:with-param name="PARAM" select="$IN_PREC"/>
750 <xsl:with-param name="PAREN" select="$PAR_YES"/>
751 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
752 </xsl:apply-templates>
755 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
756 <xsl:apply-templates select="." mode="remdiv">
757 <xsl:with-param name="PARAM" select="$PARAM"/>
758 <xsl:with-param name="PAREN" select="$PAREN"/>
759 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
760 </xsl:apply-templates>
764 <xsl:apply-templates select="." mode="remdiv">
765 <xsl:with-param name="PARAM" select="$IN_PREC"/>
766 <xsl:with-param name="PAREN" select="$PAREN"/>
767 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
768 </xsl:apply-templates>
774 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
775 <xsl:param name="PARAM" select="$NO_PARAM"/>
776 <xsl:param name="PAREN" select="$PAR_NO"/>
777 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
778 <xsl:apply-templates select = "*[2]" mode = "semantics">
779 <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
780 <xsl:with-param name="PARAM" select="$PARAM"/>
781 <xsl:with-param name="PAREN" select="$PAREN"/>
782 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
783 </xsl:apply-templates>
784 <xsl:if test="m:rem">
787 <xsl:if test="m:divide">
790 <xsl:apply-templates select = "*[3]" mode = "semantics">
791 <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
792 <xsl:with-param name="PARAM" select="$PAR_SAME"/>
793 <xsl:with-param name="PAREN" select="$PAREN"/>
794 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
795 </xsl:apply-templates>
798 <xsl:template match = "m:apply[m:times[1]]">
799 <xsl:param name="IN_PREC" select="$NO_PREC"/>
800 <xsl:param name="PARAM" select="$NO_PARAM"/>
801 <xsl:param name="PAREN" select="$PAR_NO"/>
802 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
804 <xsl:when test="$IN_PREC > $MUL_PREC or $IN_PREC=$MUL_PREC and $PARAM=$PAR_SAME">
805 <m:mfenced separators="">
806 <xsl:apply-templates select="." mode="times">
807 <xsl:with-param name="PARAM" select="$IN_PREC"/>
808 <xsl:with-param name="PAREN" select="$PAR_YES"/>
809 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
810 </xsl:apply-templates>
813 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
814 <xsl:apply-templates select="." mode="times">
815 <xsl:with-param name="PARAM" select="$PARAM"/>
816 <xsl:with-param name="PAREN" select="$PAREN"/>
817 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
818 </xsl:apply-templates>
822 <xsl:apply-templates select="." mode="times">
823 <xsl:with-param name="PARAM" select="$IN_PREC"/>
824 <xsl:with-param name="PAREN" select="$PAREN"/>
825 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
826 </xsl:apply-templates>
832 <xsl:template match = "m:apply[m:times[1]]" mode="times">
833 <xsl:param name="PARAM" select="$NO_PARAM"/>
834 <xsl:param name="PAREN" select="$PAR_NO"/>
835 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
836 <xsl:apply-templates select="*[2]" mode = "semantics">
837 <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
838 <xsl:with-param name="PARAM" select="$PARAM"/>
839 <xsl:with-param name="PAREN" select="$PAREN"/>
840 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
841 </xsl:apply-templates>
843 <xsl:for-each select = "*[position()>2]">
844 <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
845 <xsl:apply-templates select="." mode = "semantics">
846 <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
847 <xsl:with-param name="PAREN" select="$PAREN"/>
848 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
849 </xsl:apply-templates>
854 <xsl:template match = "m:apply[m:root[1]]">
856 <xsl:if test="*[2]=m:degree">
857 <xsl:apply-templates select="*[3]" mode = "semantics"/>
858 <xsl:apply-templates select="*[2]" mode = "semantics"/>
860 <xsl:if test="not(*[2]=m:degree)">
861 <xsl:apply-templates select="*[2]" mode = "semantics"/>
867 <xsl:template match = "m:apply[m:gcd[1]]">
869 <xsl:if test="not(parent::m:apply[m:power[1]])">
872 <xsl:if test="parent::m:apply[m:power[1]]">
875 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
878 <m:mfenced separators=",">
879 <xsl:for-each select = "*[position()>1]">
880 <xsl:apply-templates select = "." mode="semantics"/>
886 <xsl:template match = "m:apply[m:and[1]]">
887 <xsl:param name="IN_PREC" select="$NO_PREC"/>
888 <xsl:param name="PAREN" select="$PAR_NO"/>
889 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
891 <xsl:when test="$IN_PREC > $AND_PREC">
892 <m:mfenced separators="">
893 <xsl:apply-templates select="." mode="and">
894 <xsl:with-param name="PARAM" select="$IN_PREC"/>
895 <xsl:with-param name="PAREN" select="$PAR_YES"/>
896 </xsl:apply-templates>
899 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
900 <xsl:apply-templates select="." mode="and">
901 <xsl:with-param name="PARAM" select="$IN_PREC"/>
902 <xsl:with-param name="PAREN" select="$PAREN"/>
903 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
904 </xsl:apply-templates>
908 <xsl:apply-templates select="." mode="and">
909 <xsl:with-param name="PARAM" select="$IN_PREC"/>
910 <xsl:with-param name="PAREN" select="$PAREN"/>
911 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
912 </xsl:apply-templates>
918 <xsl:template match = "m:apply[m:and[1]]" mode="and">
919 <xsl:param name="PARAM" select="$NO_PARAM"/>
920 <xsl:param name="PAREN" select="$PAR_NO"/>
921 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
922 <xsl:apply-templates select="*[2]" mode = "semantics">
923 <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
924 <xsl:with-param name="PARAM" select="$PARAM"/>
925 <xsl:with-param name="PAREN" select="$PAREN"/>
926 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
927 </xsl:apply-templates>
928 <xsl:for-each select = "*[position()>2]">
929 <m:mo> <mchar name="wedge"/> </m:mo>
930 <xsl:apply-templates select="." mode = "semantics">
931 <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
932 <xsl:with-param name="PAREN" select="$PAREN"/>
933 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
934 </xsl:apply-templates>
938 <xsl:template match = "m:apply[m:or[1]]">
939 <xsl:param name="IN_PREC" select="$NO_PREC"/>
940 <xsl:param name="PAREN" select="$PAR_NO"/>
941 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
943 <xsl:when test="$IN_PREC > $OR_PREC">
944 <m:mfenced separators="">
945 <xsl:apply-templates select="." mode="or">
946 <xsl:with-param name="PARAM" select="$IN_PREC"/>
947 <xsl:with-param name="PAREN" select="$PAR_YES"/>
948 </xsl:apply-templates>
951 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
952 <xsl:apply-templates select="." mode="or">
953 <xsl:with-param name="PARAM" select="$IN_PREC"/>
954 <xsl:with-param name="PAREN" select="$PAREN"/>
955 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
956 </xsl:apply-templates>
960 <xsl:apply-templates select="." mode="or">
961 <xsl:with-param name="PARAM" select="$IN_PREC"/>
962 <xsl:with-param name="PAREN" select="$PAREN"/>
963 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
964 </xsl:apply-templates>
970 <xsl:template match = "m:apply[m:or[1]]" mode="or">
971 <xsl:param name="PARAM" select="$NO_PARAM"/>
972 <xsl:param name="PAREN" select="$PAR_NO"/>
973 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
974 <xsl:apply-templates select="*[2]" mode = "semantics">
975 <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
976 <xsl:with-param name="PARAM" select="$PARAM"/>
977 <xsl:with-param name="PAREN" select="$PAREN"/>
978 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
979 </xsl:apply-templates>
980 <xsl:for-each select = "*[position()>2]">
981 <m:mo> <mchar name="vee"/> </m:mo>
982 <xsl:apply-templates select="." mode = "semantics">
983 <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
984 <xsl:with-param name="PAREN" select="$PAREN"/>
985 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
986 </xsl:apply-templates>
990 <xsl:template match = "m:apply[m:xor[1]]">
991 <xsl:param name="IN_PREC" select="$NO_PREC"/>
992 <xsl:param name="PAREN" select="$PAR_NO"/>
993 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
995 <xsl:when test="$IN_PREC > $XOR_PREC">
996 <m:mfenced separators="">
997 <xsl:apply-templates select="." mode="xor">
998 <xsl:with-param name="PARAM" select="$IN_PREC"/>
999 <xsl:with-param name="PAREN" select="$PAR_YES"/>
1000 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1001 </xsl:apply-templates>
1004 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
1005 <xsl:apply-templates select="." mode="xor">
1006 <xsl:with-param name="PARAM" select="$IN_PREC"/>
1007 <xsl:with-param name="PAREN" select="$PAREN"/>
1008 </xsl:apply-templates>
1012 <xsl:apply-templates select="." mode="xor">
1013 <xsl:with-param name="PARAM" select="$IN_PREC"/>
1014 <xsl:with-param name="PAREN" select="$PAREN"/>
1015 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1016 </xsl:apply-templates>
1022 <xsl:template match = "m:apply[m:xor[1]]" mode="xor">
1023 <xsl:param name="PARAM" select="$NO_PARAM"/>
1024 <xsl:param name="PAREN" select="$PAR_NO"/>
1025 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1026 <xsl:apply-templates select="*[2]" mode = "semantics">
1027 <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1028 <xsl:with-param name="PARAM" select="$PARAM"/>
1029 <xsl:with-param name="PAREN" select="$PAREN"/>
1030 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1031 </xsl:apply-templates>
1032 <xsl:for-each select = "*[position()>2]">
1033 <m:mo> <mchar name="xor"/> </m:mo>
1034 <xsl:apply-templates select="." mode = "semantics">
1035 <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1036 <xsl:with-param name="PAREN" select="$PAREN"/>
1037 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1038 </xsl:apply-templates>
1042 <xsl:template match = "m:apply[m:not[1]]">
1045 <xsl:apply-templates select = "*[2]" mode = "semantics">
1046 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1047 </xsl:apply-templates>
1051 <xsl:template match = "m:apply[m:forall[1]]">
1053 <m:mo>for all</m:mo>
1054 <m:mfenced separators=",">
1055 <xsl:for-each select = "m:bvar">
1056 <xsl:apply-templates select = "." mode="semantics"/>
1059 <xsl:if test="m:condition">
1061 <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1064 <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
1068 <xsl:template match = "m:apply[m:exists[1]]">
1070 <m:mo> <mchar name="Exists"/> </m:mo>
1071 <m:mfenced separators=",">
1072 <xsl:for-each select = "m:bvar">
1073 <xsl:apply-templates select = "." mode="semantics"/>
1076 <xsl:if test="m:condition">
1078 <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1081 <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
1085 <xsl:template match = "m:apply[m:abs[1]]">
1086 <xsl:if test="not(parent::m:apply[m:power[1]])">
1087 <m:mfenced open="|" close="|" separators="">
1088 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1091 <xsl:if test="parent::m:apply[m:power[1]]">
1093 <m:mfenced open="|" close="|" separators="">
1094 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1096 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1101 <xsl:template match = "m:apply[m:conjugate[1]]">
1104 <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1106 <m:mo> <mchar name="UnderBar"/> </m:mo>
1110 <xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
1113 <xsl:when test="m:arg">
1116 <xsl:when test="m:real">
1119 <xsl:when test="m:imaginary">
1120 <m:mo>Imaginary</m:mo>
1123 <m:mfenced separators="">
1124 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1132 <xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies | m:in | m:notin | m:notsubset | m:notprsubset | m:subset | m:prsubset | m:eq | m:gt | m:lt | m:geq | m:leq | m:equivalent]">
1134 <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:tendsto or *[1]=m:implies or *[1]=m:in or *[1]=m:notin or *[1]=m:notsubset or *[1]=m:notprsubset">
1135 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1136 <xsl:if test="*[1]=m:neq">
1137 <m:mo> <mchar name="NotEqual"/> </m:mo>
1139 <xsl:if test="*[1]=m:approx">
1140 <m:mo> <mchar name="approxeq"/> </m:mo>
1142 <xsl:if test="*[1]=m:tendsto">
1143 <m:mo> <mchar name="RightArrow"/> </m:mo>
1145 <xsl:if test="*[1]=m:implies">
1146 <m:mo> <mchar name="DoubleRightArrow"/> </m:mo>
1148 <xsl:if test="*[1]=m:in">
1149 <m:mo> <mchar name="Element"/> </m:mo>
1151 <xsl:if test="*[1]=m:notin">
1152 <m:mo> <mchar name="NotElement"/> </m:mo>
1154 <xsl:if test="*[1]=m:notsubset">
1155 <m:mo> <mchar name="NotSubset"/> </m:mo>
1157 <xsl:if test="*[1]=m:notprsubset">
1158 <m:mo> <mchar name="NotSubsetEqual"/> </m:mo>
1160 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1161 <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
1164 <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
1168 <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
1169 <xsl:apply-templates select = "*[2]" mode="semantics"/>
1170 <xsl:for-each select = "*[position()>2]">
1171 <xsl:if test="../*[self::m:subset][1]">
1172 <m:mo> <mchar name="SubsetEqual"/> </m:mo>
1174 <xsl:if test="../*[self::m:prsubset][1]">
1175 <m:mo> <mchar name="subset"/> </m:mo>
1177 <xsl:if test="../*[self::m:eq][1]">
1180 <xsl:if test="../*[self::m:gt][1]">
1183 <xsl:if test="../*[self::m:lt][1]">
1186 <xsl:if test="../*[self::m:geq][1]">
1187 <m:mo> <mchar name="geq"/> </m:mo>
1189 <xsl:if test="../*[self::m:leq][1]">
1190 <m:mo> <mchar name="leq"/> </m:mo>
1192 <xsl:if test="../*[self::m:equivalent][1]">
1193 <m:mo> <mchar name="Congruent"/> </m:mo>
1195 <xsl:apply-templates select = "." mode="semantics"/>
1204 <xsl:template match = "m:apply[*[1][self::m:ln]]">
1207 <xsl:when test="parent::m:apply[m:power[1]]">
1210 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1217 <xsl:apply-templates select = "*[2]" mode = "semantics">
1218 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1219 </xsl:apply-templates>
1223 <xsl:template match = "m:apply[m:log[1]]">
1226 <xsl:when test="parent::m:apply[m:power[1]]">
1227 <xsl:if test="not(*[2]=m:logbase)">
1230 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1233 <xsl:if test="*[2]=m:logbase">
1236 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1237 <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
1242 <xsl:if test="not(*[2]=m:logbase)">
1245 <xsl:if test="*[2]=m:logbase">
1248 <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
1253 <xsl:if test="*[2]=m:logbase">
1254 <xsl:apply-templates select = "*[3]" mode = "semantics">
1255 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1256 </xsl:apply-templates>
1258 <xsl:if test="not(*[2]=m:logbase)">
1259 <xsl:apply-templates select = "*[2]" mode = "semantics">
1260 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1261 </xsl:apply-templates>
1266 <xsl:template match = "m:apply[m:diff[1]]">
1268 <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
1272 <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
1277 <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
1278 <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
1283 <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
1288 <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
1292 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1296 <xsl:template match = "m:apply[m:partialdiff[1]]">
1298 <xsl:for-each select = "m:bvar">
1299 <xsl:if test="*[last()]=m:degree">
1303 <xsl:apply-templates select = "m:degree" mode = "semantics"/>
1308 <xsl:apply-templates select = "*[1]" mode = "semantics"/>
1309 <xsl:apply-templates select = "m:degree" mode = "semantics"/>
1314 <xsl:if test="not(*[last()]=m:degree)">
1319 <xsl:apply-templates select = "*[1]" mode = "semantics"/>
1324 <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
1328 <xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
1329 <xsl:apply-templates mode = "semantics"/>
1332 <xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
1334 <xsl:if test="*[1]=m:divergence">
1337 <xsl:if test="*[1]=m:grad">
1340 <xsl:if test="*[1]=m:curl">
1344 <xsl:when test="*[2]=m:ci">
1345 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1348 <m:mfenced separators="">
1349 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1356 <xsl:template match = "m:apply[m:laplacian[1]]">
1359 <m:mo> Δ </m:mo>
1362 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1369 <xsl:template match = "m:set | m:list">
1370 <m:mfenced open="{{" close="}}" separators="">
1371 <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
1372 <xsl:apply-templates select="m:bvar" mode = "semantics"/>
1374 <xsl:apply-templates select="m:condition" mode = "semantics"/>
1376 <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
1377 <m:mfenced open="" close="" separators=",">
1378 <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
1379 <xsl:apply-templates select = "." mode="semantics"/>
1383 <xsl:apply-templates select="m:condition" mode = "semantics"/>
1385 <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
1386 <m:mfenced open="" close="" separators=",">
1387 <xsl:for-each select = "*">
1388 <xsl:apply-templates select = "." mode="semantics"/>
1395 <xsl:template match = "m:apply[m:union[1]]">
1396 <xsl:param name="IN_PREC" select="$NO_PREC"/>
1397 <xsl:param name="PARAM" select="$NO_PARAM"/>
1398 <xsl:param name="PAREN" select="$PAR_NO"/>
1399 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1401 <xsl:when test="$IN_PREC > $UNION_PREC or $IN_PREC=$UNION_PREC and $PARAM=$PAR_SAME">
1402 <m:mfenced separators="">
1403 <xsl:apply-templates select="." mode="union">
1404 <xsl:with-param name="PARAM" select="$PARAM"/>
1405 <xsl:with-param name="PAREN" select="$PAREN"/>
1406 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1407 </xsl:apply-templates>
1410 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
1411 <xsl:apply-templates select="." mode="union">
1412 <xsl:with-param name="PARAM" select="$PARAM"/>
1413 <xsl:with-param name="PAREN" select="$PAREN"/>
1414 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1415 </xsl:apply-templates>
1419 <xsl:apply-templates select="." mode="union">
1420 <xsl:with-param name="PARAM" select="$PARAM"/>
1421 <xsl:with-param name="PAREN" select="$PAREN"/>
1422 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1423 </xsl:apply-templates>
1429 <xsl:template match = "m:apply[m:union[1]]" mode="union">
1430 <xsl:param name="PARAM" select="$NO_PARAM"/>
1431 <xsl:param name="PAREN" select="$PAR_NO"/>
1432 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1433 <xsl:apply-templates select = "*[2]" mode="semantics">
1434 <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
1435 <xsl:with-param name="PARAM" select="$PARAM"/>
1436 <xsl:with-param name="PAREN" select="$PAREN"/>
1437 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1438 </xsl:apply-templates>
1439 <xsl:for-each select = "*[position()>2]">
1440 <m:mo> <mchar name="Union"/> </m:mo>
1441 <xsl:apply-templates select = "." mode="semantics">
1442 <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
1443 <xsl:with-param name="PAREN" select="$PAREN"/>
1444 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1445 </xsl:apply-templates>
1449 <xsl:template match = "m:apply[m:intersect[1]]">
1450 <xsl:param name="IN_PREC" select="$NO_PREC"/>
1451 <xsl:param name="PARAM" select="$NO_PARAM"/>
1452 <xsl:param name="PAREN" select="$PAR_NO"/>
1453 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1455 <xsl:when test="$IN_PREC > $INTERSECT_PREC">
1456 <m:mfenced separators="">
1457 <xsl:apply-templates select="." mode="intersect">
1458 <xsl:with-param name="PARAM" select="$PARAM"/>
1459 <xsl:with-param name="PAREN" select="$PAREN"/>
1460 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1461 </xsl:apply-templates>
1464 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
1465 <xsl:apply-templates select="." mode="intersect">
1466 <xsl:with-param name="PARAM" select="$PARAM"/>
1467 <xsl:with-param name="PAREN" select="$PAREN"/>
1468 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1469 </xsl:apply-templates>
1473 <xsl:apply-templates select="." mode="intersect">
1474 <xsl:with-param name="PARAM" select="$PARAM"/>
1475 <xsl:with-param name="PAREN" select="$PAREN"/>
1476 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1477 </xsl:apply-templates>
1483 <xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
1484 <xsl:param name="PARAM" select="$NO_PARAM"/>
1485 <xsl:param name="PAREN" select="$PAR_NO"/>
1486 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1487 <xsl:apply-templates select = "*[2]" mode="semantics">
1488 <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
1489 <xsl:with-param name="PARAM" select="$PARAM"/>
1490 <xsl:with-param name="PAREN" select="$PAREN"/>
1491 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1492 </xsl:apply-templates>
1493 <xsl:for-each select = "*[position()>2]">
1494 <m:mo> <mchar name="Intersection"/> </m:mo>
1495 <xsl:apply-templates select = "." mode="semantics">
1496 <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
1497 <xsl:with-param name="PAREN" select="$PAREN"/>
1498 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1499 </xsl:apply-templates>
1503 <xsl:template match = "m:apply[m:setdiff[1]]">
1504 <xsl:param name="IN_PREC" select="$NO_PREC"/>
1505 <xsl:param name="PARAM" select="$NO_PARAM"/>
1506 <xsl:param name="PAREN" select="$PAR_NO"/>
1507 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1509 <xsl:when test="$IN_PREC > $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC and $PARAM=$PAR_SAME">
1510 <m:mfenced separators="">
1511 <xsl:apply-templates select="." mode="setdiff">
1512 <xsl:with-param name="PARAM" select="$PARAM"/>
1513 <xsl:with-param name="PAREN" select="$PAREN"/>
1514 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1515 </xsl:apply-templates>
1518 <xsl:when test="$IN_PREC > $NO_PREC and $IN_PREC < $FUNCTION_PREC and not($SEM_SW=2)">
1519 <xsl:apply-templates select="." mode="setdiff">
1520 <xsl:with-param name="PARAM" select="$PARAM"/>
1521 <xsl:with-param name="PAREN" select="$PAREN"/>
1522 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1523 </xsl:apply-templates>
1527 <xsl:apply-templates select="." mode="setdiff">
1528 <xsl:with-param name="PARAM" select="$PARAM"/>
1529 <xsl:with-param name="PAREN" select="$PAREN"/>
1530 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1531 </xsl:apply-templates>
1537 <xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
1538 <xsl:param name="PARAM" select="$NO_PARAM"/>
1539 <xsl:param name="PAREN" select="$PAR_NO"/>
1540 <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1541 <xsl:apply-templates select = "*[2]" mode = "semantics">
1542 <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
1543 <xsl:with-param name="PARAM" select="$PARAM"/>
1544 <xsl:with-param name="PAREN" select="$PAREN"/>
1545 <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1546 </xsl:apply-templates>
1548 <xsl:apply-templates select = "*[3]" mode = "semantics">
1549 <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
1550 <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1551 <xsl:with-param name="PAREN" select="$PAREN"/>
1552 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1553 </xsl:apply-templates>
1556 <xsl:template match = "m:apply[m:card[1]]">
1557 <m:mfenced open="|" close="|" separators=",">
1558 <xsl:for-each select = "*[position()>1]">
1559 <xsl:apply-templates select = "." mode="semantics"/>
1565 <!-- SEQUENCES AND SERIES -->
1567 <xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
1570 <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
1572 <xsl:if test="*[1]=m:sum">
1573 <m:mo> <mchar name="Sum"/> </m:mo>
1575 <xsl:if test="*[1]=m:product">
1576 <m:mo> <mchar name="Product"/> </m:mo>
1579 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1581 <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
1583 <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
1585 <xsl:apply-templates select = "*[5]" mode = "semantics"/>
1587 <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
1589 <xsl:if test="*[1]=m:sum">
1590 <m:mo> <mchar name="Sum"/> </m:mo>
1592 <xsl:if test="*[1]=m:product">
1593 <m:mo> <mchar name="Product"/> </m:mo>
1595 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1597 <xsl:apply-templates select = "*[4]" mode = "semantics"/>
1603 <xsl:template match = "m:apply[m:limit[1]]">
1608 <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
1609 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1610 <m:mo> <mchar name="RightArrow"/> </m:mo>
1611 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1613 <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
1614 <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1618 <xsl:apply-templates select = "*[4]" mode = "semantics"/>
1623 <!-- TRIGONOMETRY -->
1625 <xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos | self::m:tan | self::m:sec | self::m:csc | self::m:cot | self::m:sinh | self::m:cosh | self::m:tanh | self::m:sech | self::m:csch | self::m:coth | self::m:arcsin | self::m:arccos | self::m:arctan]]">
1627 <xsl:if test="not(parent::m:apply[m:power[1]])">
1628 <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
1630 <xsl:if test="parent::m:apply[m:power[1]]">
1632 <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
1633 <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1636 <xsl:apply-templates select = "*[2]" mode = "semantics">
1637 <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1638 <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1639 </xsl:apply-templates>
1643 <xsl:template match = "m:*" mode = "trigonometry">
1645 <xsl:when test="self::m:sin">
1648 <xsl:when test="self::m:cos">
1651 <xsl:when test="self::m:tan">
1654 <xsl:when test="self::m:sec">
1657 <xsl:when test="self::m:csc">
1660 <xsl:when test="self::m:cot">
1663 <xsl:when test="self::m:sinh">
1666 <xsl:when test="self::m:cosh">
1669 <xsl:when test="self::m:tanh">
1672 <xsl:when test="self::m:sech">
1675 <xsl:when test="self::m:csch">
1678 <xsl:when test="self::m:coth">
1681 <xsl:when test="self::m:arcsin">
1684 <xsl:when test="self::m:arccos">
1687 <xsl:when test="self::m:arctan">
1696 <xsl:template match = "m:apply[m:mean[1]]">
1697 <m:mfenced open="<" close=">" separators=",">
1698 <xsl:for-each select = "*[position()>1]">
1699 <xsl:apply-templates select = "." mode="semantics"/>
1704 <xsl:template match = "m:apply[m:sdev[1]]">
1706 <m:mo> σ </m:mo>
1707 <m:mfenced separators=",">
1708 <xsl:for-each select = "*[position()>1]">
1709 <xsl:apply-templates select = "." mode="semantics"/>
1715 <xsl:template match = "m:apply[m:variance[1]]">
1717 <m:mo> σ </m:mo>
1719 <m:mfenced separators=",">
1720 <xsl:for-each select = "*[position()>1]">
1721 <xsl:apply-templates select = "." mode="semantics"/>
1729 <xsl:template match = "m:apply[m:median[1]]">
1732 <m:mfenced separators=",">
1733 <xsl:for-each select = "*[position()>1]">
1734 <xsl:apply-templates select = "." mode="semantics"/>
1740 <xsl:template match = "m:apply[m:mode[1]]">
1743 <m:mfenced separators=",">
1744 <xsl:for-each select = "*[position()>1]">
1745 <xsl:apply-templates select = "." mode="semantics"/>
1751 <xsl:template match = "m:apply[m:moment[1]]">
1752 <m:mfenced open="<" close=">" separators="">
1753 <xsl:if test="*[2]=m:degree">
1755 <xsl:apply-templates select="*[3]" mode = "semantics"/>
1756 <xsl:apply-templates select="*[2]" mode = "semantics"/>
1759 <xsl:if test="not(*[2]=m:degree)">
1760 <xsl:for-each select = "*[position()>1]">
1761 <xsl:apply-templates select = "." mode="semantics"/>
1768 <!-- LINEAR ALGEBRA -->
1770 <xsl:template match="m:vector">
1771 <m:mfenced separators="">
1773 <xsl:for-each select="*">
1775 <xsl:apply-templates select="." mode = "semantics"/>
1782 <xsl:template match = "m:matrix">
1783 <m:mfenced separators="">
1785 <xsl:apply-templates mode = "semantics"/>
1790 <xsl:template match = "m:matrixrow">
1792 <xsl:for-each select="*">
1794 <xsl:apply-templates select="." mode = "semantics"/>
1800 <xsl:template match = "m:apply[m:determinant[1]]">
1803 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1807 <xsl:template match = "m:apply[m:transpose[1]]">
1809 <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1814 <xsl:template match = "m:apply[m:selector[1]]">
1815 <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
1816 <xsl:variable name="m" select = "*[3]"/>
1818 <xsl:when test="*[4]=m:cn">
1819 <xsl:variable name="n" select = "*[4]"/>
1820 <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
1823 <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
1827 <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
1828 <xsl:variable name="m" select = "*[3]"/>
1829 <xsl:copy-of select = "*[2]/*[position()=$m]"/>
1833 <xsl:template match = "m:apply[m:vectorproduct[1] | m:scalarproduct[1] | m:outerproduct[1]]">
1835 <xsl:apply-templates select="*[2]" mode = "semantics"/>
1837 <xsl:when test="m:vectorproduct[1]">
1838 <m:mo> <mchar name="Cross"/> </m:mo>
1840 <xsl:when test="m:scalarproduct[1] | m:outerproduct[1]">
1844 <xsl:apply-templates select="*[3]" mode = "semantics"/>