]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mml2mmlv1_0.xsl
':' are noc quoted. I tried to quote them, but everything else
[helm.git] / helm / style / mml2mmlv1_0.xsl
1 <?xml version="1.0"?>
2
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             -->
10 <!--                                                        -->
11 <!-- (C) Copyright 1999, 2000 Symbolic Computation          -->
12 <!--     Laboratory, University of Western Ontario.         -->
13 <!-- ====================================================== -->
14
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 <!-- ====================================================== -->
22
23 <!-- ====================================================== -->
24 <!--  June, 2000 - HELM group:                              -->
25 <!--  Added auxiliary function to insert:                    -->
26 <!--  1) backwards pointers: helm:xref                      -->
27 <!--  2) references to definitions: xlink:href              -->
28 <!--  Added call-templates to the functions:                -->
29 <!--  insert_xref, insert, insert1, insert2                 -->
30 <!-- ====================================================== -->
31
32
33 <!-- HELM: namespace helm added -->
34 <xsl:stylesheet id="mml2mml"
35                 version="1.0"
36                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37                 xmlns:m="http://www.w3.org/1998/Math/MathML"
38                 xmlns:xlink="http://www.w3.org/1999/xlink"
39                 xmlns:helm="http://www.cs.unibo.it/helm">
40
41 <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
42
43 <!-- ***************************************************** -->
44 <!--  Parameters affectin' stylesheet's run-time behavior  -->
45 <!-- ***************************************************** -->
46
47 <!-- SEM_SW: -1 - strip off all semantics
48              0  - pass semantics "as is" (default)
49              1  - add semantics at top level only
50              2  - add semantics at all levels
51              3  - semantics at top level with cross-references
52 -->
53 <!-- HELM: SEM_SW was 0 -->
54 <xsl:param name="SEM_SW" select="1"/>
55
56 <!-- Miscellaneous Variable Definitions -->
57
58 <xsl:variable name="NO" select="0"/>
59 <xsl:variable name="YES" select="1"/>
60 <xsl:variable name="PAR_NO" select="-7"/>
61 <xsl:variable name="PAR_YES" select="-5"/>
62 <xsl:variable name="PAR_SAME" select="-3"/>
63 <xsl:variable name="NO_PARAM" select="-1"/>
64
65 <!-- Operator Precedence Definitions -->
66
67 <xsl:variable name="NO_PREC" select="0"/>
68 <xsl:variable name="UNION_PREC" select="1"/>
69 <xsl:variable name="SETDIFF_PREC" select="1"/>
70 <xsl:variable name="INTERSECT_PREC" select="3"/>
71 <xsl:variable name="OR_PREC" select="5"/>
72 <xsl:variable name="XOR_PREC" select="5"/>
73 <xsl:variable name="AND_PREC" select="7"/>
74 <xsl:variable name="PLUS_PREC" select="9"/>
75 <xsl:variable name="MINUS_PREC" select="9"/>
76 <xsl:variable name="MUL_PREC" select="11"/>
77 <xsl:variable name="DIV_PREC" select="11"/>
78 <xsl:variable name="NEG_PREC" select="13"/>
79 <xsl:variable name="FUNCTION_PREC" select="99"/>
80
81 <!-- HELM: auxiliary functions for backwards pointers and refs -->
82
83 <xsl:template name = "insert_xref">
84  <xsl:if test="@helm:xref">
85   <xsl:attribute name="helm:xref">
86    <xsl:value-of select="@helm:xref"/>
87   </xsl:attribute>
88  </xsl:if>
89 </xsl:template>
90
91 <xsl:template name = "insert">
92  <xsl:if test="@definitionURL">
93   <xsl:attribute name="xlink:href">
94    <xsl:value-of select="@definitionURL"/>
95   </xsl:attribute>
96  </xsl:if>
97  <xsl:if test="@helm:xref">
98   <xsl:attribute name="helm:xref">
99    <xsl:value-of select="@helm:xref"/>
100   </xsl:attribute>
101  </xsl:if>
102 </xsl:template>
103
104 <!-- HELM: for use inside m:apply -->
105 <xsl:template name = "insert1">
106  <xsl:if test="*[1]/@definitionURL">
107   <xsl:attribute name="xlink:href">
108    <xsl:value-of select="*[1]/@definitionURL"/>
109   </xsl:attribute>
110  </xsl:if>
111  <xsl:if test="*[1]/@helm:xref">
112   <xsl:attribute name="helm:xref">
113    <xsl:value-of select="*[1]/@helm:xref"/>
114   </xsl:attribute>
115  </xsl:if>
116 </xsl:template>
117
118 <!-- HELM: for use inside "for-each" -->
119 <xsl:template name = "insert2">
120  <xsl:if test="../*[1]/@definitionURL">
121   <xsl:attribute name="xlink:href">
122    <xsl:value-of select="../*[1]/@definitionURL"/>
123   </xsl:attribute>
124  </xsl:if>
125  <xsl:if test="../*[1]/@helm:xref">
126   <xsl:attribute name="helm:xref">
127    <xsl:value-of select="../*[1]/@helm:xref"/>
128   </xsl:attribute>
129  </xsl:if>
130 </xsl:template>
131
132 <!-- THE TOPMOST ELEMENT: MATH -->
133
134 <xsl:template match = "m:math">
135   <xsl:choose>
136     <xsl:when test="$SEM_SW>0">
137 <!-- HELM: deleted math (we have already inserted at object level) -->
138      <!--<m:math>-->
139       <m:semantics>
140           <xsl:apply-templates mode = "semantics"/>
141        <m:annotation-xml encoding="MathML">
142           <xsl:copy-of select = "*"/>
143        </m:annotation-xml>
144       </m:semantics>
145      <!--</m:math>-->
146     </xsl:when>
147     <xsl:otherwise>
148       <!--<m:math>-->
149         <xsl:apply-templates mode = "semantics"/>
150       <!--</m:math>-->  
151     </xsl:otherwise>
152   </xsl:choose>
153 </xsl:template>
154
155 <!-- SEMANTICS -->
156
157 <xsl:template match = "m:*" mode = "semantics">
158   <xsl:param name="IN_PREC" select="$NO_PREC"/>
159   <xsl:param name="PARAM" select="$NO_PARAM"/>
160   <xsl:param name="PAREN" select="$PAR_NO"/>
161   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
162   <xsl:choose>
163     <xsl:when test="$SEM_SW=-1 and self::m:semantics">
164       <xsl:apply-templates select="*[1]">
165         <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
166         <xsl:with-param name="PARAM" select="$PARAM"/>
167         <xsl:with-param name="PAREN" select="$PAREN"/>
168         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
169       </xsl:apply-templates>
170     </xsl:when>
171     <xsl:when test="$SEM_SW=0 and self::m:semantics">
172       <m:semantics>
173         <xsl:apply-templates select="*[1]">
174           <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
175           <xsl:with-param name="PARAM" select="$PARAM"/>
176           <xsl:with-param name="PAREN" select="$PAREN"/>
177           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
178         </xsl:apply-templates>
179         <xsl:copy-of select="m:annotation-xml"/>
180       </m:semantics>
181     </xsl:when>
182     <xsl:when test="$SEM_SW=2">
183       <m:semantics>
184         <xsl:choose>
185           <xsl:when test="self::m:semantics">
186             <xsl:apply-templates select="*[1]">
187               <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
188               <xsl:with-param name="PARAM" select="$PARAM"/>
189               <xsl:with-param name="PAREN" select="$PAREN"/>
190               <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
191             </xsl:apply-templates>
192             <xsl:copy-of select="m:annotation-xml"/>
193           </xsl:when>
194           <xsl:otherwise>
195             <xsl:apply-templates select=".">
196               <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
197               <xsl:with-param name="PARAM" select="$PARAM"/>
198               <xsl:with-param name="PAREN" select="$PAREN"/>
199               <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
200             </xsl:apply-templates>
201             <m:annotation-xml encoding="MathML">
202               <xsl:copy-of select="."/>
203             </m:annotation-xml>
204           </xsl:otherwise>
205         </xsl:choose>
206       </m:semantics>
207     </xsl:when>
208     <xsl:when test="$SEM_SW=3 and @id">
209       <m:mrow idref="{@id}">
210         <xsl:apply-templates select=".">
211           <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
212           <xsl:with-param name="PARAM" select="$PARAM"/>
213           <xsl:with-param name="PAREN" select="$PAREN"/>
214           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
215         </xsl:apply-templates>
216       </m:mrow>
217     </xsl:when>
218     <xsl:otherwise>
219       <xsl:apply-templates select=".">
220         <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
221         <xsl:with-param name="PARAM" select="$PARAM"/>
222         <xsl:with-param name="PAREN" select="$PAREN"/>
223         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
224       </xsl:apply-templates>
225     </xsl:otherwise>
226   </xsl:choose>
227 </xsl:template>
228
229 <xsl:template match = "m:semantics">
230   <xsl:apply-templates select="*[1]" mode = "semantics"/>
231 </xsl:template>
232
233
234 <!-- BASIC ELEMENTS -->
235
236 <!-- HELM: cn could not contain MAthMl presentation -->
237 <xsl:template match = "m:cn">
238   <xsl:param name="IN_PREC" select="$NO_PREC"/>
239   <xsl:param name="PAREN" select="$PAR_NO"/>
240   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
241 <!-- HELM: added -->
242 <xsl:choose>
243   <xsl:when test="child::text()">
244 <!-- HELM -->
245   <xsl:choose>
246     <xsl:when test=". &lt; 0 and $IN_PREC &gt; 0 and $PAREN=$PAR_NO and $PAR_NO_IGNORE=$NO">
247       <m:mfenced separators="">
248         <xsl:apply-templates select="." mode="cn"/>
249       </m:mfenced>
250     </xsl:when>
251     <xsl:otherwise>
252       <xsl:apply-templates select="." mode="cn"/>
253     </xsl:otherwise>
254   </xsl:choose>
255 <!-- HELM: added -->
256 </xsl:when>
257   <xsl:otherwise>
258    <xsl:copy-of select="*"/> 
259   </xsl:otherwise>
260  </xsl:choose>
261 <!-- HELM -->
262 </xsl:template>
263
264 <xsl:template match = "m:cn" mode="cn">
265   <xsl:choose>
266     <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
267       <m:msub>
268         <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
269         <m:mn> <xsl:value-of select="@base"/> </m:mn>
270       </m:msub>
271     </xsl:when>
272     <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
273       <m:mfenced separators="">
274         <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
275         <xsl:if test="text()[2] &lt; 0">
276           <m:mo>-</m:mo>
277           <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
278         </xsl:if>
279         <xsl:if test="not(text()[2] &lt; 0)">
280           <m:mo>+</m:mo>
281           <xsl:apply-templates select="text()[2]" mode = "semantics"/>
282         </xsl:if>
283         <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
284         <m:mo>i</m:mo>
285       </m:mfenced>
286     </xsl:when>
287     <xsl:when test="@type='complex' and @base and child::m:sep[1]">
288       <m:msub>
289         <m:mfenced separators="">
290           <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
291           <xsl:if test="text()[2] &lt; 0">
292             <m:mo>-</m:mo>
293             <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
294           </xsl:if>
295           <xsl:if test="not(text()[2] &lt; 0)">
296             <m:mo>+</m:mo>
297             <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
298           </xsl:if>
299           <m:mo> <mchar name="InvisibleTimes"/> </m:mo>
300           <m:mo>i</m:mo>
301         </m:mfenced>
302         <m:mn> <xsl:value-of select="@base"/> </m:mn>
303       </m:msub>
304     </xsl:when>
305     <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
306       <m:mrow>
307         <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
308         <m:mo>/</m:mo>
309         <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
310       </m:mrow>
311     </xsl:when>
312     <xsl:when test="@type='rational' and @base and child::m:sep[1]">
313       <m:msub>
314         <m:mfenced separators="">
315           <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
316           <m:mo>/</m:mo>
317           <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
318         </m:mfenced>
319         <m:mn> <xsl:value-of select="@base"/> </m:mn>
320       </m:msub>
321     </xsl:when>
322     <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
323       <m:mrow>
324         <m:mo>Polar</m:mo>
325         <m:mfenced separators=",">
326           <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
327           <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
328         </m:mfenced>
329       </m:mrow>
330     </xsl:when>
331     <xsl:when test="@type='polar' and @base and child::m:sep[1]">
332       <m:msub>
333         <m:mrow>
334           <m:mo>Polar</m:mo>
335           <m:mfenced separators=",">
336             <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
337             <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
338           </m:mfenced>
339         </m:mrow>
340         <m:mn> <xsl:value-of select="@base"/> </m:mn>
341       </m:msub>
342    </xsl:when>
343     <xsl:otherwise>
344       <m:mn> 
345        <xsl:call-template name="insert"/>
346        <xsl:apply-templates mode = "semantics"/> 
347       </m:mn>
348     </xsl:otherwise>
349   </xsl:choose>
350 </xsl:template>
351
352 <xsl:template match = "m:ci">
353   <xsl:choose>
354     <xsl:when test="@type='vector' or @type=matrix or @type=set">
355       <m:mi fontweight="bold"> <xsl:apply-templates mode = "semantics"/> </m:mi>
356     </xsl:when>
357     <xsl:otherwise>
358 <!-- HELM: ci could not contain MathML presentation 
359      <m:mi> 
360       <xsl:call-template name="insert"/>
361       <xsl:apply-templates mode = "semantics"/> 
362      </m:mi>
363 -->
364  <xsl:choose>
365   <!-- HELM: or the opposite test <xsl:when test="*[1]"> -->
366   <xsl:when test="child::text()">
367    <m:mi> 
368     <xsl:call-template name="insert"/>
369     <xsl:apply-templates mode = "semantics"/> 
370    </m:mi>
371   </xsl:when>
372   <xsl:otherwise>
373    <m:mrow>
374     <xsl:call-template name="insert"/>
375     <xsl:copy-of select="*"/>
376    </m:mrow>
377   </xsl:otherwise>
378  </xsl:choose>
379     </xsl:otherwise>
380   </xsl:choose>
381 </xsl:template>
382
383
384 <xsl:template match = "m:csymbol">
385    <xsl:choose>
386     <xsl:when test="*[1]">
387      <xsl:copy-of select = "*"/>
388     </xsl:when>
389    <xsl:otherwise>
390     <m:mo> <xsl:apply-templates mode = "semantics"/> </m:mo>
391    </xsl:otherwise>
392   </xsl:choose>
393 </xsl:template>
394
395
396 <!-- BASIC CONTENT ELEMENTS -->
397
398 <xsl:template match = "m:apply[m:fn[1]]">
399   <m:mrow>
400     <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
401     <m:mfenced separators=",">
402       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
403     </m:mfenced>
404   </m:mrow>
405 </xsl:template>
406
407 <xsl:template match = "m:fn">
408   <xsl:apply-templates select = "*[1]" mode = "semantics">
409     <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
410   </xsl:apply-templates>
411 </xsl:template>
412
413 <xsl:template match = "m:interval">
414   <xsl:choose>
415     <xsl:when test="@closure='closed'">
416       <m:mfenced open="[" close="]" separators=",">
417         <xsl:apply-templates mode = "semantics"/>
418       </m:mfenced>
419     </xsl:when>
420     <xsl:when test="@closure='open'">
421       <m:mfenced separators=",">
422         <xsl:apply-templates mode = "semantics"/>
423       </m:mfenced>
424     </xsl:when>
425     <xsl:when test="@closure='open-closed'">
426       <m:mfenced open="(" close="]" separators=",">
427         <xsl:apply-templates mode = "semantics"/>
428       </m:mfenced>
429     </xsl:when>
430     <xsl:when test="@closure='closed-open'">
431       <m:mfenced open="[" close=")" separators=",">
432         <xsl:apply-templates mode = "semantics"/>
433       </m:mfenced>
434     </xsl:when>
435     <xsl:otherwise>
436       <m:mfenced open="[" close="]" separators=",">
437         <xsl:apply-templates mode = "semantics"/>
438       </m:mfenced>
439     </xsl:otherwise>
440   </xsl:choose>
441 </xsl:template>
442
443 <xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
444   <m:mrow>
445     <xsl:apply-templates select = "*[1]" mode = "semantics"/>
446     <m:mfenced separators=",">
447       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
448     </m:mfenced>
449  </m:mrow>
450 </xsl:template>
451
452 <!-- HELM: these "semantical" Transformations are REALLY questionable.
453      Andrea -->
454
455 <xsl:template match = "m:apply[*[1][self::m:inverse]]">
456   <xsl:choose>
457     <xsl:when test="*[2]=m:exp">
458       <m:mo>ln</m:mo>
459     </xsl:when>
460     <xsl:when test="*[2]=m:ln | m:log">
461       <m:mo>exp</m:mo>
462     </xsl:when>
463     <xsl:when test="*[2]=m:sin">
464       <m:mo>arcsin</m:mo>
465     </xsl:when>
466     <xsl:when test="*[2]=m:cos">
467       <m:mo>arccos</m:mo>
468     </xsl:when>
469     <xsl:when test="*[2]=m:tan">
470       <m:mo>arctan</m:mo>
471     </xsl:when>
472     <xsl:when test="*[2]=m:sec">
473       <m:mo>arcsec</m:mo>
474     </xsl:when>
475     <xsl:when test="*[2]=m:csc">
476       <m:mo>arccsc</m:mo>
477     </xsl:when>
478     <xsl:when test="*[2]=m:cot">
479       <m:mo>arccot</m:mo>
480     </xsl:when>
481     <xsl:when test="*[2]=m:sinh">
482       <m:mo>arcsinh</m:mo>
483     </xsl:when>
484     <xsl:when test="*[2]=m:cosh">
485       <m:mo>arccosh</m:mo>
486     </xsl:when>
487     <xsl:when test="*[2]=m:tanh">
488       <m:mo>arctanh</m:mo>
489     </xsl:when>
490     <xsl:when test="*[2]=m:sech">
491       <m:mo>arcsech</m:mo>
492     </xsl:when>
493     <xsl:when test="*[2]=m:csch">
494       <m:mo>arccsch</m:mo>
495     </xsl:when>
496     <xsl:when test="*[2]=m:coth">
497       <m:mo>arccoth</m:mo>
498     </xsl:when>
499     <xsl:when test="*[2]=m:arcsin">
500       <m:mo>sin</m:mo>
501     </xsl:when>
502     <xsl:when test="*[2]=m:arccos">
503       <m:mo>cos</m:mo>
504     </xsl:when>
505     <xsl:when test="*[2]=m:arctan">
506       <m:mo>tan</m:mo>
507     </xsl:when>
508     <xsl:otherwise>
509       <m:msup>
510         <xsl:apply-templates select = "*[2]" mode = "semantics"/>
511         <m:mfenced>
512           <m:mn>-1</m:mn>
513         </m:mfenced>
514       </m:msup>
515     </xsl:otherwise>
516   </xsl:choose>
517 </xsl:template>
518
519 <xsl:template match = "m:sep"/>
520
521 <xsl:template match = "m:condition">
522   <xsl:choose>
523     <xsl:when test="parent::m:apply[m:forall[1]]"/>
524     <xsl:otherwise>
525       <xsl:if test="not(*[2])">
526         <xsl:apply-templates mode = "semantics"/>
527       </xsl:if>
528       <xsl:if test="*[2]">
529         <m:mrow>
530           <xsl:apply-templates mode = "semantics"/>
531         </m:mrow>
532       </xsl:if>
533     </xsl:otherwise>
534   </xsl:choose>
535 </xsl:template>
536
537 <xsl:template match = "m:declare"/>
538
539 <xsl:template match = "m:lambda">
540   <m:mrow>
541     <m:mo> &#x039b; </m:mo>
542     <m:mfenced separators=",">
543       <xsl:for-each select = "*">
544         <xsl:choose>
545           <xsl:when test="self::m:ci or self::m:cn">
546             <xsl:apply-templates select = "." mode="semantics"/>
547           </xsl:when>
548           <xsl:otherwise>
549             <m:mrow>
550               <xsl:apply-templates select = "." mode="semantics"/>
551             </m:mrow>
552           </xsl:otherwise>
553         </xsl:choose>
554       </xsl:for-each>
555     </m:mfenced>
556   </m:mrow>
557 </xsl:template>
558
559 <xsl:template match = "m:apply[m:*[1][self::m:apply[m:compose[1]]]]">
560   <m:mrow>
561     <xsl:apply-templates select = "*[1]" mode = "semantics"/>
562     <m:mfenced separators=",">
563       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
564     </m:mfenced>
565  </m:mrow>
566 </xsl:template>
567
568 <xsl:template match = "m:apply[*[1][self::m:compose]]">
569   <m:mfenced separators="">
570     <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] | self::m:fn]" mode="semantics"/>
571     <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] | self::m:fn]">
572       <m:mo> <xsl:call-template name="insert2"/> <mchar name="SmallCircle"/> </m:mo>
573       <xsl:apply-templates select = "." mode="semantics"/>
574     </xsl:for-each>
575   </m:mfenced>
576 </xsl:template>
577
578 <xsl:template match = "m:ident">
579   <m:mo>id</m:mo>
580 </xsl:template>
581
582
583 <!-- ARITHMETIC, ALGEBRA & LOGIC -->
584
585 <xsl:template match = "m:apply[m:quotient[1]]">
586   <m:mfenced open="&#x230a;" close="&#x230b;" separators="">
587     <xsl:call-template name="insert_xref"/>
588     <xsl:apply-templates select="*[2]" mode = "semantics">
589       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
590     </xsl:apply-templates>
591     <m:mo><xsl:call-template name="insert1"/>/</m:mo>
592     <xsl:apply-templates select="*[3]" mode = "semantics">
593       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
594       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
595     </xsl:apply-templates>
596   </m:mfenced>
597 </xsl:template>
598
599 <xsl:template match = "m:apply[*[1][self::m:exp]]">
600   <m:msup>
601     <m:mo>e</m:mo>
602     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
603   </m:msup>
604 </xsl:template>
605
606 <xsl:template match = "m:apply[m:factorial[1]]">
607   <m:mrow>
608     <xsl:call-template name="insert_xref"/>
609     <xsl:apply-templates select = "*[2]" mode = "semantics">
610       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
611       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
612     </xsl:apply-templates>
613     <m:mo><xsl:call-template name="insert1"/>!</m:mo>
614   </m:mrow>
615 </xsl:template>
616
617 <xsl:template match = "m:apply[m:max[1] | m:min[1]]">
618   <m:mrow>
619     <xsl:call-template name="insert_xref"/>
620     <xsl:if test="*[2]=m:bvar">
621       <m:munder>
622         <xsl:if test="*[1]=m:max">
623           <m:mo><xsl:call-template name="insert1"/>max</m:mo>
624         </xsl:if>
625         <xsl:if test="*[1]=m:min">
626           <m:mo>min</m:mo>
627         </xsl:if>
628         <xsl:apply-templates select="*[2]" mode = "semantics"/>
629       </m:munder>
630       <xsl:if test="*[3]=m:condition">
631         <m:mfenced open="{{" close="}}" separators="">
632           <m:mfenced open="" close="" separators=",">
633             <xsl:for-each select = "*[position()>3]">
634               <xsl:apply-templates select = "." mode="semantics"/>
635             </xsl:for-each>
636           </m:mfenced>
637           <m:mo>|</m:mo>
638           <xsl:apply-templates select="*[3]" mode = "semantics"/>
639         </m:mfenced>
640       </xsl:if>
641       <xsl:if test="not(*[3]=m:condition)">
642         <m:mfenced open="{{" close="}}" separators=",">
643           <xsl:for-each select = "*[position()>2]">
644             <xsl:apply-templates select = "." mode="semantics"/>
645           </xsl:for-each>
646         </m:mfenced>
647       </xsl:if>
648     </xsl:if>
649     <xsl:if test="*[2]=m:condition">
650       <xsl:if test="*[1]=m:max">
651         <m:mo>max</m:mo>
652       </xsl:if>
653       <xsl:if test="*[1]=m:min">
654         <m:mo>min</m:mo>
655       </xsl:if>
656       <m:mfenced open="{{" close="}}" separators="">
657         <xsl:if test="*[3]">
658           <m:mfenced open="" close="" separators=",">
659             <xsl:for-each select = "*[position()>2]">
660               <xsl:apply-templates select = "." mode="semantics"/>
661             </xsl:for-each>
662           </m:mfenced>
663           <m:mo>|</m:mo>
664         </xsl:if>
665         <xsl:apply-templates select="*[2]" mode = "semantics"/>
666       </m:mfenced>
667     </xsl:if>
668     <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
669       <xsl:if test="*[1]=m:max">
670         <m:mo>max</m:mo>
671       </xsl:if>
672       <xsl:if test="*[1]=m:min">
673         <m:mo><xsl:call-template name="insert1"/>min</m:mo>
674       </xsl:if>
675       <m:mfenced open="{{" close="}}" separators=",">
676         <xsl:for-each select = "*[position()>1]">
677           <xsl:apply-templates select = "." mode="semantics"/>
678         </xsl:for-each>
679       </m:mfenced>
680     </xsl:if>
681   </m:mrow>
682 </xsl:template>
683
684 <xsl:template match = "m:apply[m:minus[1]]">
685   <xsl:param name="IN_PREC" select="$NO_PREC"/>
686   <xsl:param name="PARAM" select="$NO_PARAM"/>
687   <xsl:param name="PAREN" select="$PAR_NO"/>
688   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
689   <xsl:choose>
690     <xsl:when test="$IN_PREC &gt; $MINUS_PREC or $IN_PREC=$MINUS_PREC and $PARAM=$PAR_SAME">
691       <m:mfenced separators="">
692         <xsl:call-template name="insert_xref"/>
693         <xsl:apply-templates select="." mode="minus">
694           <xsl:with-param name="PARAM" select="$PARAM"/>
695           <xsl:with-param name="PAREN" select="$PAR_YES"/>
696           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
697         </xsl:apply-templates>
698       </m:mfenced>
699     </xsl:when>
700     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
701       <xsl:apply-templates select="." mode="minus">
702         <xsl:with-param name="PARAM" select="$PARAM"/>
703         <xsl:with-param name="PAREN" select="$PAREN"/>
704         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
705       </xsl:apply-templates>
706     </xsl:when>
707     <xsl:otherwise>
708       <m:mrow>
709         <xsl:call-template name="insert_xref"/>
710         <xsl:apply-templates select="." mode="minus">
711           <xsl:with-param name="PARAM" select="$PARAM"/>
712           <xsl:with-param name="PAREN" select="$PAREN"/>
713           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
714         </xsl:apply-templates>
715       </m:mrow>
716     </xsl:otherwise>
717   </xsl:choose>
718 </xsl:template>
719
720 <xsl:template match = "m:apply[m:minus[1]]" mode="minus">
721   <xsl:param name="PARAM" select="$NO_PARAM"/>
722   <xsl:param name="PAREN" select="$PAR_NO"/>
723   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
724   <xsl:if test="not(*[3])">
725     <m:mo><xsl:call-template name="insert1"/>-</m:mo>
726     <xsl:apply-templates select="*[2]" mode = "semantics">
727       <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
728       <xsl:with-param name="PAREN" select="$PAREN"/>
729       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
730     </xsl:apply-templates>
731   </xsl:if>
732   <xsl:if test="*[3]">
733     <xsl:apply-templates select="*[2]" mode = "semantics">
734       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
735       <xsl:with-param name="PARAM" select="$PARAM"/>
736       <xsl:with-param name="PAREN" select="$PAREN"/>
737       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
738     </xsl:apply-templates>
739     <m:mo><xsl:call-template name="insert1"/>-</m:mo>
740     <xsl:apply-templates select="*[3]" mode = "semantics">
741       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
742       <xsl:with-param name="PARAM" select="$PAR_SAME"/>
743       <xsl:with-param name="PAREN" select="$PAREN"/>
744       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
745     </xsl:apply-templates>
746   </xsl:if>
747 </xsl:template>
748
749 <xsl:template match = "m:apply[m:plus[1]]">
750   <xsl:param name="IN_PREC" select="$NO_PREC"/>
751   <xsl:param name="PARAM" select="$NO_PARAM"/>
752   <xsl:param name="PAREN" select="$PAR_NO"/>
753   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
754   <xsl:choose>
755     <xsl:when test="$IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and $PARAM=$PAR_SAME">
756       <m:mfenced separators="">
757         <xsl:call-template name="insert_xref"/>
758         <xsl:apply-templates select="." mode="plus">
759           <xsl:with-param name="PARAM" select="$IN_PREC"/>
760           <xsl:with-param name="PAREN" select="$PAR_YES"/>
761           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
762         </xsl:apply-templates>
763       </m:mfenced>
764     </xsl:when>
765     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
766       <xsl:apply-templates select="." mode="plus">
767         <xsl:with-param name="PARAM" select="$PARAM"/>
768         <xsl:with-param name="PAREN" select="$PAREN"/>
769         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
770       </xsl:apply-templates>
771     </xsl:when>
772     <xsl:otherwise>
773       <m:mrow>
774         <xsl:call-template name="insert_xref"/>
775         <xsl:apply-templates select="." mode="plus">
776           <xsl:with-param name="PARAM" select="$IN_PREC"/>
777           <xsl:with-param name="PAREN" select="$PAREN"/>
778           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
779         </xsl:apply-templates>
780       </m:mrow>
781     </xsl:otherwise>
782   </xsl:choose>
783 </xsl:template>
784
785 <xsl:template match = "m:apply[m:plus[1]]" mode="plus">
786   <xsl:param name="PARAM" select="$NO_PARAM"/>
787   <xsl:param name="PAREN" select="$PAR_NO"/>
788   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
789   <xsl:if test="*[2]">
790     <xsl:apply-templates select="*[2]" mode = "semantics">
791       <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
792       <xsl:with-param name="PARAM" select="$PARAM"/>
793       <xsl:with-param name="PAREN" select="$PAREN"/>
794       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
795     </xsl:apply-templates>
796     <xsl:for-each select = "*[position()>2]">
797       <xsl:choose>
798         <xsl:when test=". &lt; 0">
799           <m:mo>-</m:mo>
800           <m:mn> <xsl:value-of select="-."/> </m:mn>
801         </xsl:when>
802         <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
803           <xsl:apply-templates select="." mode = "semantics">
804             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
805             <xsl:with-param name="PAREN" select="$PAREN"/>
806             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
807           </xsl:apply-templates>
808         </xsl:when>
809         <xsl:otherwise>
810           <m:mo><xsl:call-template name="insert2"/>+</m:mo>
811           <xsl:apply-templates select="." mode = "semantics">
812             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
813             <xsl:with-param name="PAREN" select="$PAREN"/>
814             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
815           </xsl:apply-templates>
816         </xsl:otherwise>
817       </xsl:choose>
818     </xsl:for-each>
819   </xsl:if>
820 </xsl:template>
821
822 <xsl:template match = "m:apply[m:power[1]]">
823   <xsl:choose>
824     <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]]">
825       <xsl:apply-templates select="*[2]" mode = "semantics"/>
826     </xsl:when>
827     <xsl:otherwise>
828       <m:msup>
829         <xsl:apply-templates select = "*[2]" mode = "semantics">
830           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
831           <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
832         </xsl:apply-templates>
833         <xsl:apply-templates select = "*[3]" mode = "semantics"/>
834       </m:msup>
835     </xsl:otherwise>
836   </xsl:choose>
837 </xsl:template>
838
839 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
840   <xsl:param name="IN_PREC" select="$NO_PREC"/>
841   <xsl:param name="PARAM" select="$NO_PARAM"/>
842   <xsl:param name="PAREN" select="$PAR_NO"/>
843   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
844   <xsl:choose>
845     <xsl:when test="$IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and $PARAM=$PAR_SAME">
846       <m:mfenced separators="">
847         <xsl:call-template name="insert_xref"/>
848         <xsl:apply-templates select="." mode="remdiv">
849           <xsl:with-param name="PARAM" select="$IN_PREC"/>
850           <xsl:with-param name="PAREN" select="$PAR_YES"/>
851           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
852         </xsl:apply-templates>
853       </m:mfenced>
854     </xsl:when>
855     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
856       <xsl:apply-templates select="." mode="remdiv">
857         <xsl:with-param name="PARAM" select="$PARAM"/>
858         <xsl:with-param name="PAREN" select="$PAREN"/>
859         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
860       </xsl:apply-templates>
861     </xsl:when>
862     <xsl:otherwise>
863       <m:mrow>
864         <xsl:call-template name="insert_xref"/>
865         <xsl:apply-templates select="." mode="remdiv">
866           <xsl:with-param name="PARAM" select="$IN_PREC"/>
867           <xsl:with-param name="PAREN" select="$PAREN"/>
868           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
869         </xsl:apply-templates>
870       </m:mrow>
871     </xsl:otherwise>
872   </xsl:choose>
873 </xsl:template>
874
875 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
876   <xsl:param name="PARAM" select="$NO_PARAM"/>
877   <xsl:param name="PAREN" select="$PAR_NO"/>
878   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
879   <xsl:apply-templates select = "*[2]" mode = "semantics">
880     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
881       <xsl:with-param name="PARAM" select="$PARAM"/>
882       <xsl:with-param name="PAREN" select="$PAREN"/>
883       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
884   </xsl:apply-templates>
885   <xsl:if test="m:rem">
886     <m:mo><xsl:call-template name="insert1"/>%</m:mo>
887   </xsl:if>
888   <xsl:if test="m:divide">
889     <m:mo><xsl:call-template name="insert1"/>/</m:mo>
890   </xsl:if>
891   <xsl:apply-templates select = "*[3]" mode = "semantics">
892     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
893     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
894     <xsl:with-param name="PAREN" select="$PAREN"/>
895     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
896   </xsl:apply-templates>
897 </xsl:template>
898
899 <xsl:template match = "m:apply[m:times[1]]">
900   <xsl:param name="IN_PREC" select="$NO_PREC"/>
901   <xsl:param name="PARAM" select="$NO_PARAM"/>
902   <xsl:param name="PAREN" select="$PAR_NO"/>
903   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
904   <xsl:choose>
905     <xsl:when test="$IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and $PARAM=$PAR_SAME">
906       <m:mfenced separators="">
907         <xsl:call-template name="insert_xref"/>
908         <xsl:apply-templates select="." mode="times">
909           <xsl:with-param name="PARAM" select="$IN_PREC"/>
910           <xsl:with-param name="PAREN" select="$PAR_YES"/>
911           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
912         </xsl:apply-templates>
913       </m:mfenced>
914     </xsl:when>
915     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
916       <xsl:apply-templates select="." mode="times">
917         <xsl:with-param name="PARAM" select="$PARAM"/>
918         <xsl:with-param name="PAREN" select="$PAREN"/>
919         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
920       </xsl:apply-templates>
921     </xsl:when>
922     <xsl:otherwise>
923       <m:mrow>
924          <xsl:call-template name="insert_xref"/>
925         <xsl:apply-templates select="." mode="times">
926           <xsl:with-param name="PARAM" select="$IN_PREC"/>
927           <xsl:with-param name="PAREN" select="$PAREN"/>
928           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
929         </xsl:apply-templates>
930       </m:mrow>
931     </xsl:otherwise>
932   </xsl:choose>
933 </xsl:template>
934
935 <xsl:template match = "m:apply[m:times[1]]" mode="times">
936   <xsl:param name="PARAM" select="$NO_PARAM"/>
937   <xsl:param name="PAREN" select="$PAR_NO"/>
938   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
939   <xsl:apply-templates select="*[2]" mode = "semantics">
940     <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
941     <xsl:with-param name="PARAM" select="$PARAM"/>
942     <xsl:with-param name="PAREN" select="$PAREN"/>
943     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
944   </xsl:apply-templates>
945   <xsl:if test="*[3]">
946     <xsl:for-each select = "*[position()>2]">
947 <!-- HELM: to distinguish between * and the application -->
948 <!--      <m:mo><xsl:call-template name="insert2"/>
949                 <mchar name="InvisibleTimes"/> </m:mo> -->
950       <m:mo><xsl:call-template name="insert2"/>*</m:mo>
951       <xsl:apply-templates select="." mode = "semantics">
952         <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
953         <xsl:with-param name="PAREN" select="$PAREN"/>
954         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
955       </xsl:apply-templates>
956     </xsl:for-each>
957   </xsl:if>
958 </xsl:template>
959
960
961 <xsl:template match = "m:apply[m:root[1]]">
962   <m:msqrt>
963     <xsl:call-template name="insert1"/>
964     <xsl:call-template name="insert_xref"/>
965     <xsl:if test="*[2]=m:degree">
966       <xsl:apply-templates select="*[3]" mode = "semantics"/>
967       <xsl:apply-templates select="*[2]" mode = "semantics"/>
968     </xsl:if>
969     <xsl:if test="not(*[2]=m:degree)">
970       <xsl:apply-templates select="*[2]" mode = "semantics"/>
971       <m:mn>2</m:mn>
972     </xsl:if>
973   </m:msqrt>
974 </xsl:template>
975
976 <xsl:template match = "m:apply[m:gcd[1]]">
977   <m:mrow>
978     <xsl:call-template name="insert_xref"/>
979     <xsl:if test="not(parent::m:apply[m:power[1]])">
980       <m:mo><xsl:call-template name="insert1"/>gcd</m:mo>
981     </xsl:if>
982     <xsl:if test="parent::m:apply[m:power[1]]">
983       <m:msup>
984         <m:mo><xsl:call-template name="insert1"/>gcd</m:mo>
985         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
986       </m:msup>
987     </xsl:if>
988     <m:mfenced separators=",">
989       <xsl:for-each select = "*[position()>1]">
990         <xsl:apply-templates select = "." mode="semantics"/>
991       </xsl:for-each>
992     </m:mfenced>
993   </m:mrow>
994 </xsl:template>
995
996 <xsl:template match = "m:apply[m:and[1]]">
997   <xsl:param name="IN_PREC" select="$NO_PREC"/>
998   <xsl:param name="PAREN" select="$PAR_NO"/>
999   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1000   <xsl:choose>
1001     <xsl:when test="$IN_PREC &gt; $AND_PREC">
1002       <m:mfenced separators="">
1003         <xsl:call-template name="insert_xref"/>
1004         <xsl:apply-templates select="." mode="and">
1005           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1006           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1007         </xsl:apply-templates>
1008       </m:mfenced>
1009     </xsl:when>
1010     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1011       <xsl:apply-templates select="." mode="and">
1012         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1013         <xsl:with-param name="PAREN" select="$PAREN"/>
1014         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1015       </xsl:apply-templates>
1016     </xsl:when>
1017     <xsl:otherwise>
1018       <m:mrow>
1019         <xsl:call-template name="insert_xref"/>
1020         <xsl:apply-templates select="." mode="and">
1021           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1022           <xsl:with-param name="PAREN" select="$PAREN"/>
1023           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1024         </xsl:apply-templates>
1025       </m:mrow>
1026     </xsl:otherwise>
1027   </xsl:choose>
1028 </xsl:template>
1029
1030 <xsl:template match = "m:apply[m:and[1]]" mode="and">
1031   <xsl:param name="PARAM" select="$NO_PARAM"/>
1032   <xsl:param name="PAREN" select="$PAR_NO"/>
1033   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1034   <xsl:apply-templates select="*[2]" mode = "semantics">
1035     <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1036     <xsl:with-param name="PARAM" select="$PARAM"/>
1037     <xsl:with-param name="PAREN" select="$PAREN"/>
1038     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1039   </xsl:apply-templates>
1040   <xsl:for-each select = "*[position()>2]">
1041     <m:mo><xsl:call-template name="insert2"/> <mchar name="wedge"/> </m:mo>
1042     <xsl:apply-templates select="." mode = "semantics">
1043       <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1044       <xsl:with-param name="PAREN" select="$PAREN"/>
1045       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1046     </xsl:apply-templates>
1047   </xsl:for-each>
1048 </xsl:template>
1049
1050 <xsl:template match = "m:apply[m:or[1]]">
1051   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1052   <xsl:param name="PAREN" select="$PAR_NO"/>
1053   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1054   <xsl:choose>
1055     <xsl:when test="$IN_PREC &gt; $OR_PREC">
1056       <m:mfenced separators="">
1057          <xsl:call-template name="insert_xref"/>
1058         <xsl:apply-templates select="." mode="or">
1059           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1060           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1061         </xsl:apply-templates>
1062       </m:mfenced>
1063     </xsl:when>
1064     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1065       <xsl:apply-templates select="." mode="or">
1066         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1067         <xsl:with-param name="PAREN" select="$PAREN"/>
1068         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1069       </xsl:apply-templates>
1070     </xsl:when>
1071     <xsl:otherwise>
1072       <m:mrow>
1073         <xsl:call-template name="insert_xref"/>
1074         <xsl:apply-templates select="." mode="or">
1075           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1076           <xsl:with-param name="PAREN" select="$PAREN"/>
1077           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1078         </xsl:apply-templates>
1079       </m:mrow>
1080     </xsl:otherwise>
1081   </xsl:choose>
1082 </xsl:template>
1083
1084 <xsl:template match = "m:apply[m:or[1]]" mode="or">
1085   <xsl:param name="PARAM" select="$NO_PARAM"/>
1086   <xsl:param name="PAREN" select="$PAR_NO"/>
1087   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1088   <xsl:apply-templates select="*[2]" mode = "semantics">
1089     <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1090     <xsl:with-param name="PARAM" select="$PARAM"/>
1091     <xsl:with-param name="PAREN" select="$PAREN"/>
1092     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1093   </xsl:apply-templates>
1094   <xsl:for-each select = "*[position()>2]">
1095     <m:mo><xsl:call-template name="insert2"/> <mchar name="vee"/> </m:mo>
1096     <xsl:apply-templates select="." mode = "semantics">
1097       <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1098       <xsl:with-param name="PAREN" select="$PAREN"/>
1099       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1100     </xsl:apply-templates>
1101   </xsl:for-each>
1102 </xsl:template>
1103
1104 <xsl:template match = "m:apply[m:xor[1]]">
1105   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1106   <xsl:param name="PAREN" select="$PAR_NO"/>
1107   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1108   <xsl:choose>
1109     <xsl:when test="$IN_PREC &gt; $XOR_PREC">
1110       <m:mfenced separators="">
1111         <xsl:call-template name="insert_xref"/>
1112         <xsl:apply-templates select="." mode="xor">
1113           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1114           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1115           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1116         </xsl:apply-templates>
1117       </m:mfenced>
1118     </xsl:when>
1119     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1120       <xsl:apply-templates select="." mode="xor">
1121         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1122         <xsl:with-param name="PAREN" select="$PAREN"/>
1123       </xsl:apply-templates>
1124     </xsl:when>
1125     <xsl:otherwise>
1126       <m:mrow>
1127         <xsl:call-template name="insert_xref"/>
1128         <xsl:apply-templates select="." mode="xor">
1129           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1130           <xsl:with-param name="PAREN" select="$PAREN"/>
1131           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1132         </xsl:apply-templates>
1133       </m:mrow>
1134     </xsl:otherwise>
1135   </xsl:choose>
1136 </xsl:template>
1137
1138 <xsl:template match = "m:apply[m:xor[1]]" mode="xor">
1139   <xsl:param name="PARAM" select="$NO_PARAM"/>
1140   <xsl:param name="PAREN" select="$PAR_NO"/>
1141   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1142   <xsl:apply-templates select="*[2]" mode = "semantics">
1143     <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1144     <xsl:with-param name="PARAM" select="$PARAM"/>
1145     <xsl:with-param name="PAREN" select="$PAREN"/>
1146     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1147   </xsl:apply-templates>
1148   <xsl:for-each select = "*[position()>2]">
1149     <m:mo><xsl:call-template name="insert2"/> <mchar name="xor"/> </m:mo>
1150     <xsl:apply-templates select="." mode = "semantics">
1151       <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1152       <xsl:with-param name="PAREN" select="$PAREN"/>
1153       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1154     </xsl:apply-templates>
1155   </xsl:for-each>
1156 </xsl:template>
1157
1158 <xsl:template match = "m:apply[m:not[1]]">
1159   <m:mrow>
1160     <xsl:call-template name="insert_xref"/>
1161 <!-- CSC, per estetica!
1162     <m:mo><xsl:call-template name="insert1"/>not</m:mo>
1163 -->
1164     <m:mo><xsl:call-template name="insert1"/><m:mchar name="not"/></m:mo>
1165     <xsl:apply-templates select = "*[2]" mode = "semantics">
1166       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1167     </xsl:apply-templates>
1168   </m:mrow>
1169 </xsl:template>
1170
1171 <xsl:template match = "m:apply[m:forall[1]]">
1172   <m:mrow>
1173     <xsl:call-template name="insert_xref"/>
1174     <m:mo><xsl:call-template name="insert1"/>for all</m:mo>
1175     <m:mfenced separators=",">
1176       <xsl:for-each select = "m:bvar">
1177         <xsl:apply-templates select = "." mode="semantics"/>
1178       </xsl:for-each>
1179     </m:mfenced>
1180     <xsl:if test="m:condition">
1181       <m:mo>:</m:mo>
1182       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1183       <m:mo>,</m:mo>
1184     </xsl:if>
1185     <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
1186   </m:mrow>
1187 </xsl:template>
1188
1189 <xsl:template match = "m:apply[m:exists[1]]">
1190   <m:mrow>
1191     <xsl:call-template name="insert_xref"/>
1192     <m:mo><xsl:call-template name="insert1"/> <mchar name="Exists"/> </m:mo>
1193     <m:mfenced separators=",">
1194       <xsl:for-each select = "m:bvar">
1195         <xsl:apply-templates select = "." mode="semantics"/>
1196       </xsl:for-each>
1197     </m:mfenced>
1198     <xsl:if test="m:condition">
1199       <m:mo>,</m:mo>
1200       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1201     </xsl:if>
1202     <m:mo>:</m:mo>
1203     <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and not(self::m:condition)]" mode = "semantics"/>
1204   </m:mrow>
1205 </xsl:template>
1206
1207 <xsl:template match = "m:apply[m:abs[1]]">
1208   <xsl:if test="not(parent::m:apply[m:power[1]])">
1209     <m:mfenced open="|" close="|" separators="">
1210       <xsl:call-template name="insert_xref"/>
1211       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1212     </m:mfenced>
1213   </xsl:if>
1214   <xsl:if test="parent::m:apply[m:power[1]]">
1215     <m:msup>
1216       <m:mfenced open="|" close="|" separators="">
1217         <xsl:call-template name="insert_xref"/>
1218         <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1219       </m:mfenced>
1220       <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1221     </m:msup>
1222   </xsl:if>
1223 </xsl:template>
1224
1225 <xsl:template match = "m:apply[m:conjugate[1]]">
1226   <m:mover>
1227     <m:mrow>
1228       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
1229     </m:mrow>
1230     <m:mo><xsl:call-template name="insert1"/> <mchar name="UnderBar"/> </m:mo>
1231   </m:mover>
1232 </xsl:template>
1233
1234 <xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
1235   <m:mrow>
1236     <xsl:call-template name="insert_xref"/>
1237     <xsl:choose>
1238       <xsl:when test="m:arg">
1239         <m:mo><xsl:call-template name="insert1"/>arg</m:mo>
1240       </xsl:when>
1241       <xsl:when test="m:real">
1242         <m:mo><xsl:call-template name="insert1"/>Real</m:mo>
1243       </xsl:when>
1244       <xsl:when test="m:imaginary">
1245         <m:mo><xsl:call-template name="insert1"/>Imaginary</m:mo>
1246       </xsl:when>
1247     </xsl:choose>
1248     <m:mfenced separators="">
1249       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1250     </m:mfenced>
1251   </m:mrow>
1252 </xsl:template>
1253
1254
1255 <!-- RELATIONS -->
1256
1257 <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]">
1258   <m:mrow>
1259     <xsl:call-template name="insert_xref"/>
1260     <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">
1261       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1262       <xsl:if test="*[1]=m:neq">
1263         <m:mo><xsl:call-template name="insert1"/> <mchar name="NotEqual"/> </m:mo>
1264       </xsl:if>
1265       <xsl:if test="*[1]=m:approx">
1266         <m:mo><xsl:call-template name="insert1"/> <mchar name="approxeq"/> </m:mo>
1267       </xsl:if>
1268       <xsl:if test="*[1]=m:tendsto">
1269         <m:mo><xsl:call-template name="insert1"/> <mchar name="RightArrow"/> </m:mo>
1270       </xsl:if>
1271       <xsl:if test="*[1]=m:implies">
1272         <m:mo><xsl:call-template name="insert1"/> <mchar name="DoubleRightArrow"/> </m:mo>
1273       </xsl:if>
1274       <xsl:if test="*[1]=m:in">
1275         <m:mo><xsl:call-template name="insert1"/>
1276         <mchar name="Element"/> 
1277        </m:mo>
1278       </xsl:if>
1279       <xsl:if test="*[1]=m:notin">
1280         <m:mo><xsl:call-template name="insert1"/> <mchar name="NotElement"/> </m:mo>
1281       </xsl:if>
1282       <xsl:if test="*[1]=m:notsubset">
1283         <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubset"/> </m:mo>
1284       </xsl:if>
1285       <xsl:if test="*[1]=m:notprsubset">
1286         <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubsetEqual"/> </m:mo>
1287       </xsl:if>
1288       <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1289       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
1290         <m:mo><xsl:call-template name="insert1"/>-</m:mo>
1291       </xsl:if>
1292       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
1293         <m:mo><xsl:call-template name="insert1"/>+</m:mo>
1294       </xsl:if>
1295     </xsl:if>
1296     <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">
1297       <xsl:apply-templates select = "*[2]" mode="semantics"/>
1298       <xsl:for-each select = "*[position()>2]">
1299         <xsl:if test="../*[self::m:subset][1]">
1300           <m:mo> <xsl:call-template name="insert2"/> <mchar name="SubsetEqual"/> </m:mo>
1301         </xsl:if>
1302         <xsl:if test="../*[self::m:prsubset][1]">
1303           <m:mo> <xsl:call-template name="insert2"/><mchar name="subset"/> </m:mo>
1304         </xsl:if>
1305         <xsl:if test="../*[self::m:eq][1]">
1306           <m:mo><xsl:call-template name="insert2"/>=</m:mo>
1307         </xsl:if>
1308         <xsl:if test="../*[self::m:gt][1]">
1309           <m:mo><xsl:call-template name="insert2"/>&gt;</m:mo>
1310         </xsl:if>
1311         <xsl:if test="../*[self::m:lt][1]">
1312           <m:mo><xsl:call-template name="insert2"/>&lt;</m:mo>
1313         </xsl:if>
1314         <xsl:if test="../*[self::m:geq][1]">
1315           <m:mo><xsl:call-template name="insert2"/> <mchar name="geq"/> </m:mo>
1316         </xsl:if>
1317         <xsl:if test="../*[self::m:leq][1]">
1318           <m:mo><xsl:call-template name="insert2"/> <mchar name="leq"/> </m:mo>
1319         </xsl:if>
1320         <xsl:if test="../*[self::m:equivalent][1]">
1321           <m:mo><xsl:call-template name="insert2"/> <mchar name="Congruent"/> </m:mo>
1322         </xsl:if>
1323         <xsl:apply-templates select = "." mode="semantics"/>
1324       </xsl:for-each>
1325     </xsl:if>
1326   </m:mrow>
1327 </xsl:template>
1328
1329
1330 <!-- CALCULUS -->
1331
1332 <xsl:template match = "m:apply[*[1][self::m:ln]]">
1333   <m:mrow>
1334     <xsl:call-template name="insert_xref"/>
1335     <xsl:choose>
1336       <xsl:when test="parent::m:apply[m:power[1]]">
1337         <m:msup>
1338           <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
1339           <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1340         </m:msup>
1341       </xsl:when>
1342       <xsl:otherwise>
1343         <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
1344       </xsl:otherwise>
1345     </xsl:choose>
1346     <xsl:apply-templates select = "*[2]" mode = "semantics">
1347       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1348     </xsl:apply-templates>
1349   </m:mrow>
1350 </xsl:template>
1351
1352 <xsl:template match = "m:apply[m:log[1]]">
1353   <m:mrow>
1354     <xsl:call-template name="insert_xref"/>
1355     <xsl:choose>
1356       <xsl:when test="parent::m:apply[m:power[1]]">
1357         <xsl:if test="not(*[2]=m:logbase)">
1358           <m:msup>
1359             <m:mo><xsl:call-template name="insert1"/>log</m:mo>
1360             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1361           </m:msup>
1362         </xsl:if>
1363         <xsl:if test="*[2]=m:logbase">
1364           <m:msubsup>
1365             <m:mo><xsl:call-template name="insert1"/>log</m:mo>
1366             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1367             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
1368           </m:msubsup>
1369         </xsl:if>
1370       </xsl:when>
1371       <xsl:otherwise>
1372         <xsl:if test="not(*[2]=m:logbase)">
1373           <m:mo><xsl:call-template name="insert1"/>log</m:mo>
1374         </xsl:if>
1375         <xsl:if test="*[2]=m:logbase">
1376           <m:msub>
1377             <m:mo><xsl:call-template name="insert1"/>log</m:mo>
1378             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
1379           </m:msub>
1380         </xsl:if>
1381       </xsl:otherwise>
1382     </xsl:choose>
1383     <xsl:if test="*[2]=m:logbase">
1384       <xsl:apply-templates select = "*[3]" mode = "semantics">
1385         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1386       </xsl:apply-templates>
1387     </xsl:if>
1388     <xsl:if test="not(*[2]=m:logbase)">
1389       <xsl:apply-templates select = "*[2]" mode = "semantics">
1390         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1391       </xsl:apply-templates>
1392     </xsl:if>
1393   </m:mrow>
1394 </xsl:template>
1395
1396 <xsl:template match = "m:apply[m:diff[1]]">
1397   <m:mrow>
1398     <xsl:call-template name="insert_xref"/>
1399     <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
1400       <m:mfrac><xsl:call-template name="insert1"/>
1401         <m:msup>
1402           <m:mo>d</m:mo>
1403           <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
1404         </m:msup>
1405         <m:mrow>
1406           <m:mo>d</m:mo>
1407           <m:msup>
1408             <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
1409             <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
1410           </m:msup>
1411         </m:mrow>
1412       </m:mfrac>
1413     </xsl:if>
1414     <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
1415       <m:mfrac><xsl:call-template name="insert1"/>
1416         <m:mo>d</m:mo>
1417         <m:mrow>
1418           <m:mo>d</m:mo>
1419           <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
1420         </m:mrow>
1421       </m:mfrac>
1422     </xsl:if>
1423     <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1424   </m:mrow>
1425 </xsl:template>
1426
1427 <xsl:template match = "m:apply[m:partialdiff[1]]">
1428   <m:mrow>
1429     <xsl:call-template name="insert_xref"/>
1430     <xsl:for-each select = "m:bvar">
1431       <xsl:if test="*[last()]=m:degree">
1432         <m:mfrac><xsl:call-template name="insert1"/>
1433           <m:msup>
1434              <m:mo>d</m:mo>
1435              <xsl:apply-templates select = "m:degree" mode = "semantics"/>
1436           </m:msup>
1437           <m:mrow>
1438             <m:mo>d</m:mo>
1439             <m:msup>
1440               <xsl:apply-templates select = "*[1]" mode = "semantics"/>
1441               <xsl:apply-templates select = "m:degree" mode = "semantics"/>
1442             </m:msup>
1443           </m:mrow>
1444         </m:mfrac>
1445       </xsl:if>
1446       <xsl:if test="not(*[last()]=m:degree)">
1447         <m:mfrac><xsl:call-template name="insert1"/>
1448           <m:mo>d</m:mo>
1449           <m:mrow>
1450             <m:mo>d</m:mo>
1451             <xsl:apply-templates select = "*[1]" mode = "semantics"/>
1452           </m:mrow>
1453         </m:mfrac>
1454       </xsl:if>
1455     </xsl:for-each>
1456     <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
1457   </m:mrow>
1458 </xsl:template>
1459
1460 <xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
1461   <xsl:apply-templates mode = "semantics"/>
1462 </xsl:template>
1463
1464 <xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
1465   <m:mrow>
1466     <xsl:call-template name="insert_xref"/>
1467     <xsl:if test="*[1]=m:divergence">
1468       <m:mo><xsl:call-template name="insert1"/>div</m:mo>
1469     </xsl:if>
1470     <xsl:if test="*[1]=m:grad">
1471     <m:mo><xsl:call-template name="insert1"/>grad</m:mo>
1472     </xsl:if>
1473     <xsl:if test="*[1]=m:curl">
1474     <m:mo><xsl:call-template name="insert1"/>curl</m:mo>
1475     </xsl:if>
1476     <xsl:choose>
1477       <xsl:when test="*[2]=m:ci">
1478         <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1479       </xsl:when>
1480       <xsl:otherwise>
1481         <m:mfenced separators="">
1482           <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1483         </m:mfenced>
1484       </xsl:otherwise>
1485     </xsl:choose>
1486   </m:mrow>
1487 </xsl:template>
1488
1489 <xsl:template match = "m:apply[m:laplacian[1]]">
1490   <m:mrow>
1491     <xsl:call-template name="insert_xref"/>
1492     <m:msup><xsl:call-template name="insert1"/>
1493       <m:mo> &#x0394; </m:mo>
1494       <m:mn>2</m:mn>
1495     </m:msup>
1496     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1497   </m:mrow>
1498 </xsl:template>
1499
1500
1501 <!-- SET THEORY -->
1502
1503 <xsl:template match = "m:set | m:list">
1504   <m:mfenced open="{{" close="}}" separators="">
1505     <xsl:call-template name="insert_xref"/>
1506     <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
1507       <xsl:apply-templates select="m:bvar" mode = "semantics"/>
1508       <m:mo>|</m:mo>
1509       <xsl:apply-templates select="m:condition" mode = "semantics"/>
1510     </xsl:if>
1511     <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
1512       <m:mfenced open="" close="" separators=",">
1513         <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
1514           <xsl:apply-templates select = "." mode="semantics"/>
1515         </xsl:for-each>
1516       </m:mfenced>
1517       <m:mo>|</m:mo>
1518       <xsl:apply-templates select="m:condition" mode = "semantics"/>
1519     </xsl:if>
1520     <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
1521       <m:mfenced open="" close="" separators=",">
1522         <xsl:for-each select = "*">
1523           <xsl:apply-templates select = "." mode="semantics"/>
1524         </xsl:for-each>
1525       </m:mfenced>
1526     </xsl:if>
1527   </m:mfenced>
1528 </xsl:template>
1529
1530 <xsl:template match = "m:apply[m:union[1]]">
1531   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1532   <xsl:param name="PARAM" select="$NO_PARAM"/>
1533   <xsl:param name="PAREN" select="$PAR_NO"/>
1534   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1535   <xsl:choose>
1536     <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC and $PARAM=$PAR_SAME">
1537       <m:mfenced separators="" helm:xref="{@helm:xref}">
1538         <xsl:call-template name="insert_xref"/>
1539         <xsl:apply-templates select="." mode="union">
1540           <xsl:with-param name="PARAM" select="$PARAM"/>
1541           <xsl:with-param name="PAREN" select="$PAREN"/>
1542           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1543         </xsl:apply-templates>
1544       </m:mfenced>
1545     </xsl:when>
1546     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1547       <xsl:apply-templates select="." mode="union">
1548         <xsl:with-param name="PARAM" select="$PARAM"/>
1549         <xsl:with-param name="PAREN" select="$PAREN"/>
1550         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1551       </xsl:apply-templates>
1552     </xsl:when>
1553     <xsl:otherwise>
1554       <m:mrow>
1555         <xsl:call-template name="insert_xref"/>
1556         <xsl:apply-templates select="." mode="union">
1557           <xsl:with-param name="PARAM" select="$PARAM"/>
1558           <xsl:with-param name="PAREN" select="$PAREN"/>
1559           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1560         </xsl:apply-templates>
1561       </m:mrow>
1562     </xsl:otherwise>
1563   </xsl:choose>
1564 </xsl:template>
1565
1566 <xsl:template match = "m:apply[m:union[1]]" mode="union">
1567   <xsl:param name="PARAM" select="$NO_PARAM"/>
1568   <xsl:param name="PAREN" select="$PAR_NO"/>
1569   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1570   <xsl:apply-templates select = "*[2]" mode="semantics">
1571     <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
1572     <xsl:with-param name="PARAM" select="$PARAM"/>
1573     <xsl:with-param name="PAREN" select="$PAREN"/>
1574     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1575   </xsl:apply-templates>
1576   <xsl:for-each select = "*[position()>2]">
1577     <m:mo><xsl:call-template name="insert2"/> <mchar name="Union"/> </m:mo>
1578     <xsl:apply-templates select = "." mode="semantics">
1579       <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
1580       <xsl:with-param name="PAREN" select="$PAREN"/>
1581       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1582     </xsl:apply-templates>
1583   </xsl:for-each>
1584 </xsl:template>
1585
1586 <xsl:template match = "m:apply[m:intersect[1]]">
1587   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1588   <xsl:param name="PARAM" select="$NO_PARAM"/>
1589   <xsl:param name="PAREN" select="$PAR_NO"/>
1590   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1591   <xsl:choose>
1592     <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC">
1593       <m:mfenced separators="" helm:xref="{@helm:xref}">
1594         <xsl:call-template name="insert_xref"/>
1595         <xsl:apply-templates select="." mode="intersect">
1596           <xsl:with-param name="PARAM" select="$PARAM"/>
1597           <xsl:with-param name="PAREN" select="$PAREN"/>
1598           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1599         </xsl:apply-templates>
1600       </m:mfenced>
1601     </xsl:when>
1602     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1603       <xsl:apply-templates select="." mode="intersect">
1604         <xsl:with-param name="PARAM" select="$PARAM"/>
1605         <xsl:with-param name="PAREN" select="$PAREN"/>
1606         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1607       </xsl:apply-templates>
1608     </xsl:when>
1609     <xsl:otherwise>
1610       <m:mrow>
1611         <xsl:call-template name="insert_xref"/>
1612         <xsl:apply-templates select="." mode="intersect">
1613           <xsl:with-param name="PARAM" select="$PARAM"/>
1614           <xsl:with-param name="PAREN" select="$PAREN"/>
1615           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1616         </xsl:apply-templates>
1617       </m:mrow>
1618     </xsl:otherwise>
1619   </xsl:choose>
1620 </xsl:template>
1621
1622 <xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
1623   <xsl:param name="PARAM" select="$NO_PARAM"/>
1624   <xsl:param name="PAREN" select="$PAR_NO"/>
1625   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1626   <xsl:apply-templates select = "*[2]" mode="semantics">
1627     <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
1628     <xsl:with-param name="PARAM" select="$PARAM"/>
1629     <xsl:with-param name="PAREN" select="$PAREN"/>
1630     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1631   </xsl:apply-templates>
1632   <xsl:for-each select = "*[position()>2]">
1633     <m:mo><xsl:call-template name="insert2"/> <mchar name="Intersection"/> </m:mo>
1634     <xsl:apply-templates select = "." mode="semantics">
1635       <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
1636       <xsl:with-param name="PAREN" select="$PAREN"/>
1637       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1638     </xsl:apply-templates>
1639   </xsl:for-each>
1640 </xsl:template>
1641
1642 <xsl:template match = "m:apply[m:setdiff[1]]">
1643   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1644   <xsl:param name="PARAM" select="$NO_PARAM"/>
1645   <xsl:param name="PAREN" select="$PAR_NO"/>
1646   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1647   <xsl:choose>
1648     <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC and $PARAM=$PAR_SAME">
1649       <m:mfenced separators="">
1650         <xsl:call-template name="insert_xref"/>
1651         <xsl:apply-templates select="." mode="setdiff">
1652           <xsl:with-param name="PARAM" select="$PARAM"/>
1653           <xsl:with-param name="PAREN" select="$PAREN"/>
1654           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1655         </xsl:apply-templates>
1656       </m:mfenced>
1657     </xsl:when>
1658     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC and not($SEM_SW=2)">
1659       <xsl:apply-templates select="." mode="setdiff">
1660         <xsl:with-param name="PARAM" select="$PARAM"/>
1661         <xsl:with-param name="PAREN" select="$PAREN"/>
1662         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1663       </xsl:apply-templates>
1664     </xsl:when>
1665     <xsl:otherwise>
1666       <m:mrow>
1667         <xsl:call-template name="insert_xref"/>
1668         <xsl:apply-templates select="." mode="setdiff">
1669           <xsl:with-param name="PARAM" select="$PARAM"/>
1670           <xsl:with-param name="PAREN" select="$PAREN"/>
1671           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1672         </xsl:apply-templates>
1673       </m:mrow>
1674     </xsl:otherwise>
1675   </xsl:choose>
1676 </xsl:template>
1677
1678 <xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
1679   <xsl:param name="PARAM" select="$NO_PARAM"/>
1680   <xsl:param name="PAREN" select="$PAR_NO"/>
1681   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1682   <xsl:apply-templates select = "*[2]" mode = "semantics">
1683     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
1684     <xsl:with-param name="PARAM" select="$PARAM"/>
1685     <xsl:with-param name="PAREN" select="$PAREN"/>
1686     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1687   </xsl:apply-templates>
1688   <m:mo><xsl:call-template name="insert1"/>\</m:mo>
1689   <xsl:apply-templates select = "*[3]" mode = "semantics">
1690     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
1691     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1692     <xsl:with-param name="PAREN" select="$PAREN"/>
1693     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1694   </xsl:apply-templates>
1695 </xsl:template>
1696
1697 <xsl:template match = "m:apply[m:card[1]]">
1698   <m:mfenced open="|" close="|" separators=",">
1699     <xsl:call-template name="insert_xref"/>
1700     <xsl:for-each select = "*[position()>1]">
1701       <xsl:apply-templates select = "." mode="semantics"/>
1702     </xsl:for-each>
1703   </m:mfenced>
1704 </xsl:template>
1705
1706
1707 <!-- SEQUENCES AND SERIES -->
1708
1709 <xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
1710   <m:mrow>
1711     <xsl:call-template name="insert_xref"/>
1712     <xsl:choose>
1713       <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
1714         <m:munderover>
1715           <xsl:if test="*[1]=m:sum">
1716             <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
1717           </xsl:if>
1718           <xsl:if test="*[1]=m:product">
1719             <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
1720           </xsl:if>
1721           <m:mrow>
1722             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1723             <m:mo>=</m:mo>
1724             <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
1725           </m:mrow>
1726           <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
1727         </m:munderover>
1728         <xsl:apply-templates select = "*[5]" mode = "semantics"/>
1729       </xsl:when>
1730       <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
1731         <m:munder>
1732           <xsl:if test="*[1]=m:sum">
1733             <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
1734           </xsl:if>
1735           <xsl:if test="*[1]=m:product">
1736             <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
1737           </xsl:if>
1738           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1739         </m:munder>
1740         <xsl:apply-templates select = "*[4]" mode = "semantics"/>
1741       </xsl:when>
1742     </xsl:choose>
1743   </m:mrow>
1744 </xsl:template>
1745
1746 <xsl:template match = "m:apply[m:limit[1]]">
1747   <m:mrow>
1748     <xsl:call-template name="insert_xref"/>
1749     <m:munder>
1750       <m:mo><xsl:call-template name="insert1"/>lim</m:mo>
1751       <m:mrow>
1752         <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
1753             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1754             <m:mo> <mchar name="RightArrow"/> </m:mo>
1755             <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1756         </xsl:if>
1757         <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
1758           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1759         </xsl:if>
1760       </m:mrow>
1761     </m:munder>
1762     <xsl:apply-templates select = "*[4]" mode = "semantics"/>
1763   </m:mrow>
1764 </xsl:template>
1765
1766
1767 <!-- TRIGONOMETRY -->
1768
1769 <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]]">
1770   <m:mrow>
1771     <xsl:call-template name="insert_xref"/>
1772     <xsl:if test="not(parent::m:apply[m:power[1]])">
1773       <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
1774     </xsl:if>
1775     <xsl:if test="parent::m:apply[m:power[1]]">
1776       <m:msup>
1777         <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
1778         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1779       </m:msup>
1780     </xsl:if>
1781     <xsl:apply-templates select = "*[2]" mode = "semantics">
1782       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1783       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1784     </xsl:apply-templates>
1785   </m:mrow>
1786 </xsl:template>
1787
1788 <xsl:template match = "m:*" mode = "trigonometry">
1789     <xsl:choose>
1790       <xsl:when test="self::m:sin">
1791         <m:mo>sin</m:mo>
1792       </xsl:when>
1793       <xsl:when test="self::m:cos">
1794         <m:mo>cos</m:mo>
1795       </xsl:when>
1796       <xsl:when test="self::m:tan">
1797         <m:mo>tan</m:mo>
1798       </xsl:when>
1799       <xsl:when test="self::m:sec">
1800         <m:mo>sec</m:mo>
1801       </xsl:when>
1802       <xsl:when test="self::m:csc">
1803         <m:mo>csc</m:mo>
1804       </xsl:when>
1805       <xsl:when test="self::m:cot">
1806         <m:mo>cot</m:mo>
1807       </xsl:when>
1808       <xsl:when test="self::m:sinh">
1809         <m:mo>sinh</m:mo>
1810       </xsl:when>
1811       <xsl:when test="self::m:cosh">
1812         <m:mo>cosh</m:mo>
1813       </xsl:when>
1814       <xsl:when test="self::m:tanh">
1815         <m:mo>tanh</m:mo>
1816       </xsl:when>
1817       <xsl:when test="self::m:sech">
1818         <m:mo>sech</m:mo>
1819       </xsl:when>
1820       <xsl:when test="self::m:csch">
1821         <m:mo>csch</m:mo>
1822       </xsl:when>
1823       <xsl:when test="self::m:coth">
1824         <m:mo>coth</m:mo>
1825       </xsl:when>
1826       <xsl:when test="self::m:arcsin">
1827         <m:mo>arcsin</m:mo>
1828       </xsl:when>
1829       <xsl:when test="self::m:arccos">
1830         <m:mo>arccos</m:mo>
1831       </xsl:when>
1832       <xsl:when test="self::m:arctan">
1833         <m:mo>arctan</m:mo>
1834       </xsl:when>
1835     </xsl:choose>
1836 </xsl:template>
1837
1838
1839 <!-- STATISTICS -->
1840
1841 <xsl:template match = "m:apply[m:mean[1]]">
1842   <m:mfenced open="&lt;" close="&gt;" separators=",">
1843     <xsl:call-template name="insert_xref"/>
1844     <xsl:for-each select = "*[position()>1]">
1845       <xsl:apply-templates select = "." mode="semantics"/>
1846     </xsl:for-each>
1847   </m:mfenced>
1848 </xsl:template>
1849
1850 <xsl:template match = "m:apply[m:sdev[1]]">
1851   <m:mrow>
1852     <xsl:call-template name="insert_xref"/>
1853     <m:mo><xsl:call-template name="insert1"/> &#x03c3; </m:mo>
1854     <m:mfenced separators=",">
1855       <xsl:for-each select = "*[position()>1]">
1856         <xsl:apply-templates select = "." mode="semantics"/>
1857       </xsl:for-each>
1858     </m:mfenced>
1859   </m:mrow>
1860 </xsl:template>
1861
1862 <xsl:template match = "m:apply[m:variance[1]]">
1863   <m:mrow>
1864     <xsl:call-template name="insert_xref"/>
1865     <m:mo><xsl:call-template name="insert1"/> &#x03c3; </m:mo>
1866     <m:msup>
1867       <m:mfenced separators=",">
1868         <xsl:for-each select = "*[position()>1]">
1869           <xsl:apply-templates select = "." mode="semantics"/>
1870         </xsl:for-each>
1871       </m:mfenced>
1872       <m:mn>2</m:mn>
1873     </m:msup>
1874   </m:mrow>
1875 </xsl:template>
1876
1877 <xsl:template match = "m:apply[m:median[1]]">
1878   <m:mrow>
1879     <xsl:call-template name="insert_xref"/>
1880     <m:mo><xsl:call-template name="insert1"/>median</m:mo>
1881     <m:mfenced separators=",">
1882       <xsl:for-each select = "*[position()>1]">
1883         <xsl:apply-templates select = "." mode="semantics"/>
1884       </xsl:for-each>
1885     </m:mfenced>
1886   </m:mrow>
1887 </xsl:template>
1888
1889 <xsl:template match = "m:apply[m:mode[1]]">
1890   <m:mrow>
1891     <xsl:call-template name="insert_xref"/>
1892     <m:mo><xsl:call-template name="insert1"/>mode</m:mo>
1893     <m:mfenced separators=",">
1894       <xsl:for-each select = "*[position()>1]">
1895         <xsl:apply-templates select = "." mode="semantics"/>
1896       </xsl:for-each>
1897     </m:mfenced>
1898   </m:mrow>
1899 </xsl:template>
1900
1901 <xsl:template match = "m:apply[m:moment[1]]">
1902   <xsl:call-template name="insert_xref"/>
1903   <m:mfenced open="&lt;" close="&gt;" separators="">
1904     <xsl:if test="*[2]=m:degree">
1905       <m:msup>
1906         <xsl:apply-templates select="*[3]" mode = "semantics"/>
1907         <xsl:apply-templates select="*[2]" mode = "semantics"/>
1908       </m:msup>
1909     </xsl:if>
1910     <xsl:if test="not(*[2]=m:degree)">
1911       <xsl:for-each select = "*[position()>1]">
1912         <xsl:apply-templates select = "." mode="semantics"/>
1913       </xsl:for-each>
1914     </xsl:if>
1915   </m:mfenced>
1916 </xsl:template>
1917
1918
1919 <!-- LINEAR ALGEBRA -->
1920
1921 <xsl:template match="m:vector">
1922   <m:mfenced separators="">
1923     <m:mtable>
1924       <xsl:for-each select="*">
1925         <m:mtd>
1926           <xsl:apply-templates select="." mode = "semantics"/>
1927         </m:mtd>
1928       </xsl:for-each>
1929     </m:mtable>
1930   </m:mfenced>
1931 </xsl:template>
1932
1933 <xsl:template match = "m:matrix">
1934   <m:mfenced separators="">
1935     <m:mtable>
1936       <xsl:apply-templates mode = "semantics"/>
1937     </m:mtable>
1938   </m:mfenced>
1939 </xsl:template>
1940
1941 <xsl:template match = "m:matrixrow">
1942   <m:mtr>
1943     <xsl:for-each select="*">
1944       <m:mtd>
1945         <xsl:apply-templates select="." mode = "semantics"/>
1946       </m:mtd>
1947     </xsl:for-each>
1948   </m:mtr>
1949 </xsl:template>
1950
1951 <xsl:template match = "m:apply[m:determinant[1]]">
1952   <m:mrow>
1953     <xsl:call-template name="insert_xref"/>
1954     <m:mo><xsl:call-template name="insert1"/>det</m:mo>
1955     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1956   </m:mrow>
1957 </xsl:template>
1958
1959 <xsl:template match = "m:apply[m:transpose[1]]">
1960   <m:msup>
1961     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1962     <m:mo>T</m:mo>
1963   </m:msup>
1964 </xsl:template>
1965
1966 <xsl:template match = "m:apply[m:selector[1]]">
1967   <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
1968       <xsl:variable name="m" select = "*[3]"/>
1969       <xsl:choose>
1970         <xsl:when test="*[4]=m:cn">
1971           <xsl:variable name="n" select = "*[4]"/>
1972           <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
1973         </xsl:when>
1974         <xsl:otherwise>
1975           <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
1976         </xsl:otherwise>
1977       </xsl:choose>
1978   </xsl:if>
1979   <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
1980     <xsl:variable name="m" select = "*[3]"/>
1981     <xsl:copy-of select = "*[2]/*[position()=$m]"/>
1982   </xsl:if>
1983 </xsl:template>
1984
1985 <xsl:template match = "m:apply[m:vectorproduct[1] | m:scalarproduct[1] | m:outerproduct[1]]">
1986   <m:mrow>
1987     <xsl:call-template name="insert_xref"/>
1988     <xsl:apply-templates select="*[2]" mode = "semantics"/>
1989     <xsl:choose>
1990       <xsl:when test="m:vectorproduct[1]">
1991         <m:mo><xsl:call-template name="insert1"/> <mchar name="Cross"/> </m:mo>
1992       </xsl:when>
1993       <xsl:when test="m:scalarproduct[1] | m:outerproduct[1]">
1994         <m:mo><xsl:call-template name="insert1"/>.</m:mo>
1995       </xsl:when>
1996     </xsl:choose>
1997     <xsl:apply-templates select="*[3]" mode = "semantics"/>
1998   </m:mrow>
1999 </xsl:template>
2000
2001 </xsl:stylesheet>
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017