]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mmlctop.xsl
0a0e454d99d4b7e615c26d5e5a1ed4543f5e3763
[helm.git] / helm / style / mmlctop.xsl
1 <?xml version="1.0"?>
2
3 <!-- ******************************************************** -->
4 <!--   XSL Transform of MathML content to MathML presentation -->
5 <!--                                                          -->
6 <!--   Authors Igor Rodionov <igor@csd.uwo.ca>,               -->
7 <!--           Stephen Watt  <watt@csd.uwo.ca>.               -->  
8 <!--                                                          -->
9 <!--   (C) Copyright 2000  Symbolic Computation Laboratory,   -->
10 <!--                       University of Western Ontario,     -->
11 <!--                       London, Canada N6A 5B7.            -->
12 <!--                                                          -->
13 <!-- ******************************************************** -->
14 <!--   Updated Nov. 2001 by:                                  -->
15 <!--           S. Huerter <huerter@csd.uwo.ca>.               -->
16 <!--                                                          -->
17 <!--   Complies with the W3C MathML 2.0 Recommendation of     -->
18 <!--   21 February 2001.                                      -->
19 <!-- ******************************************************** -->
20
21 <!-- ====================================================== -->
22 <!--  April, 10 2002 - HELM group:                          -->
23 <!--  Added the namespace prefix to all the output elements -->
24 <!--  Changed the mml prefix into m                         -->
25 <!--  Added xref to every mo element                        -->
26 <!--  New csymbol template                                  -->
27 <!--  reln is not supported                                 -->
28 <!--  First draft: April 10 2002, Irene Schena              -->
29 <!-- ====================================================== -->
30
31 <xsl:stylesheet id="mmlctop.xsl"
32                 version="1.0"
33                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34                 xmlns:m="http://www.w3.org/1998/Math/MathML">
35
36 <!-- HELM: we don't have a default namespace.
37      Removed xmlns="http://www.w3.org/1998/Math/MathML" -->
38
39 <!-- HELM: was
40 <xsl:output method="xml" indent="yes"/>
41 -->
42 <xsl:output method="xml"/>
43
44 <xsl:strip-space elements="apply semantics annotation-xml
45         csymbol fn cn ci interval matrix matrixrow vector
46         lambda bvar condition logbase degree set list
47         lowlimit uplimit"/>
48
49
50 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
51 <!--         Parameters, variables and constants           -->
52 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
53
54 <!-- ~~~~~~~~ Semantics related *constants*: ~~~~~~~~ -->
55
56 <!-- Strip off semantics -->
57 <xsl:variable name="SEM_STRIP" select="-1"/>
58
59 <!-- Pass semantics "as is" -->
60 <xsl:variable name="SEM_PASS" select="0"/>
61
62 <!-- Add semantics at top level only -->
63 <xsl:variable name="SEM_TOP" select="1"/>
64
65 <!-- Add semantics at all levels -->
66 <xsl:variable name="SEM_ALL" select="2"/>
67
68 <!-- Semantics at top level only, with id refs -->
69 <!-- NOTE: ids have to be already present in the
70            input for this feature to work. -->
71 <xsl:variable name="SEM_XREF" select="3"/>
72
73 <!-- No semantics at top level, with id refs -->
74 <!-- NOTE: ids have to be already present in the
75            input for this feature to work. -->
76 <xsl:variable name="SEM_XREF_EXT" select="4"/>
77
78
79 <!-- ~~~~~~~~~~ Stylesheet *parameter*: SEM_SW ~~~~~~~~~~~~~~ -->
80 <!-- Assumes one of the above values; SEM_PASS is the default -->
81 <!-- The default can be overridden by specifying different    -->
82 <!-- value on the command line when the stylesheet is invoked -->
83
84 <!-- HELM: $SEM_SW was SEM_PASS (error!) -->
85 <xsl:param name="SEM_SW" select="$SEM_XREF"/>
86
87
88 <!-- ~~~~~~ Operator precedence definitions ~~~~~~ -->
89 <xsl:variable name="UNION_OP" select="2"/>
90 <xsl:variable name="INTERSECT_OP" select="6"/>
91 <xsl:variable name="SETDIFF_OP" select="4"/>
92 <xsl:variable name="NO_PREC" select="0"/>
93 <xsl:variable name="UNION_PREC" select="1"/>
94 <xsl:variable name="SETDIFF_PREC" select="1"/>
95 <xsl:variable name="INTERSECT_PREC" select="3"/>
96 <xsl:variable name="CARTPROD_PREC" select="3"/>
97 <xsl:variable name="OR_PREC" select="5"/>
98 <xsl:variable name="XOR_PREC" select="5"/>
99 <xsl:variable name="AND_PREC" select="7"/>
100 <xsl:variable name="PLUS_PREC" select="9"/>
101 <xsl:variable name="MINUS_PREC" select="9"/>
102 <xsl:variable name="MUL_PREC" select="11"/>
103 <xsl:variable name="DIV_PREC" select="11"/>
104 <xsl:variable name="NEG_PREC" select="13"/>
105 <xsl:variable name="FUNCTION_PREC" select="99"/>
106
107 <!-- ~~~~~ Miscellaneous constant definitions ~~~~~ -->
108
109 <xsl:variable name="YES" select="1"/>
110 <xsl:variable name="NO" select="0"/>
111 <xsl:variable name="NO_PARAM" select="-1"/>
112 <xsl:variable name="PAR_SAME" select="-3"/>
113 <xsl:variable name="PAR_YES" select="-5"/>
114 <xsl:variable name="PAR_NO" select="-7"/>
115 <xsl:variable name="DOESNT_MATTER" select="-9"/>
116
117 <!-- +++++++++++++++++ INDEX OF TEMPLATES +++++++++++++++++++ -->
118
119 <!-- All templates are subdivided into the following categories
120      (listed in the order of appearance in the stylesheet):
121
122 THE TOPMOST ELEMENT: MATH
123  math
124
125 SEMANTICS HANDLING
126  semantics
127
128 BASIC CONTAINER ELEMENTS
129  cn, ci, csymbol
130
131 BASIC CONTENT ELEMENTS
132  fn, interval, inverse, sep, condition, declare, lambda, compose, ident
133
134      *NEW: apply, piecewise, domain, codomain, image
135
136 ARITHMETIC, ALGEBRA & LOGIC
137  quotient, exp, factorial, max, min, minus, plus, power, rem, divide,
138  times, root, gcd, and, or, xor, not, forall, exists, abs, conjugate,
139  arg, real, imaginary
140
141      *NEW: floor, ceiling, lcm
142
143 RELATIONS
144  neq, approx, tendsto, implies, in, notin, notsubset, notprsubset,
145  subset, prsubset, eq, gt, lt, geq, leq, equivalent
146
147 CALCULUS
148  ln, log, diff, partialdiff, lowlimit, uplimit, bvar, degree,
149  logbase, divergence, grad, curl, laplacian
150
151 SET THEORY
152  set, list, union, intersect, setdiff, card
153
154      *NEW: cartesianproduct
155
156 SEQUENCES AND SERIES
157  sum, product, limit
158
159      *NEW: int
160
161 TRIGONOMETRY
162  sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth,
163  arcsin, arccos, arctan
164
165      *NEW: arcsec, arccsc, arccot, arcsinh, arccosh, arctanh,
166            arcsech, arccsch, arccoth, 
167
168 STATISTICS
169  mean, sdev, variance, median, mode, moment
170
171 LINEAR ALGEBRA
172  vector, matrix, matrixrow, determinant, transpose, selector,
173  vectorproduct, scalarproduct, outerproduct
174 -->
175
176
177 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
178 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
179 <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
180
181
182 <!-- ***************** THE TOPMOST ELEMENT: MATH ***************** -->
183
184 <xsl:template match = "m:math">
185 <!-- HELM:  <m:math> -->
186   <xsl:choose>
187     <xsl:when test="$SEM_SW=$SEM_TOP or $SEM_SW=$SEM_ALL and *[2] or $SEM_SW=$SEM_XREF">             <m:semantics>                                                       
188     <m:mrow>                                                         
189           <xsl:apply-templates mode = "semantics"/>
190         </m:mrow>
191         <m:annotation-xml encoding="MathML">
192           <xsl:copy-of select="*"/>
193         </m:annotation-xml>
194       </m:semantics>
195     </xsl:when>
196     <xsl:otherwise>
197       <m:mrow>
198         <xsl:apply-templates mode = "semantics"/>
199       </m:mrow>  
200     </xsl:otherwise>
201   </xsl:choose>
202 <!-- HELM: </m:math> -->
203 </xsl:template>
204
205
206 <!-- ***************** SEMANTICS HANDLING ***************** -->
207
208 <!-- This template is called recursively.  At each level   -->
209 <!-- in the source tree it decides whether to strip off,   -->
210 <!-- pass or add semantics at that level (depending on the -->
211 <!-- value of SEM_SW parameter).  Then the actual template -->
212 <!-- is applied to the node.                               -->
213
214 <xsl:template match = "m:*" mode = "semantics">
215   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
216   <xsl:param name="IN_PREC" select="$NO_PREC"/>
217   <xsl:param name="PARAM" select="$NO_PARAM"/>
218   <xsl:param name="PAREN" select="$PAR_NO"/>
219   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
220   <xsl:choose>
221     <xsl:when test="$SEM_SW=$SEM_STRIP and self::m:semantics">
222       <xsl:apply-templates select="m:annotation-xml[@encoding='MathML']">
223         <xsl:with-param name="IN_OP" select="$IN_OP"/>
224         <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
225         <xsl:with-param name="PARAM" select="$PARAM"/>
226         <xsl:with-param name="PAREN" select="$PAREN"/>
227         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
228       </xsl:apply-templates>
229     </xsl:when>
230     <xsl:when test="($SEM_SW=$SEM_PASS or $SEM_SW=$SEM_TOP) and self::m:semantics">
231       <m:semantics>
232         <xsl:apply-templates select="*[1]">   
233         <xsl:with-param name="IN_OP" select="$IN_OP"/>
234         <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
235         <xsl:with-param name="PARAM" select="$PARAM"/>
236         <xsl:with-param name="PAREN" select="$PAREN"/>
237         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
238       </xsl:apply-templates>
239         <xsl:copy-of select="m:annotation-xml"/>
240       </m:semantics>
241     </xsl:when>
242     <xsl:when test="$SEM_SW=$SEM_ALL">
243       <m:semantics>
244         <xsl:choose>
245           <xsl:when test="self::m:semantics">
246             <xsl:apply-templates select="*[1]">
247               <xsl:with-param name="IN_OP" select="$IN_OP"/>
248               <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
249               <xsl:with-param name="PARAM" select="$PARAM"/>
250               <xsl:with-param name="PAREN" select="$PAREN"/>
251               <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
252             </xsl:apply-templates>
253             <xsl:copy-of select="m:annotation-xml"/>
254           </xsl:when>
255           <xsl:otherwise>
256             <xsl:apply-templates select=".">
257               <xsl:with-param name="IN_OP" select="$IN_OP"/>
258               <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
259               <xsl:with-param name="PARAM" select="$PARAM"/>
260               <xsl:with-param name="PAREN" select="$PAREN"/>
261               <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
262             </xsl:apply-templates>
263             <m:annotation-xml encoding="MathML">
264               <xsl:copy-of select="."/>
265             </m:annotation-xml>
266           </xsl:otherwise>
267         </xsl:choose>
268       </m:semantics>
269     </xsl:when>
270     <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
271       <xsl:choose>
272 <!-- HELM: syntax error, was sematics -->
273         <xsl:when test="self::m:semantics">
274           <xsl:copy>
275             <xsl:copy-of select="@*"/>
276             <xsl:attribute name="xref">
277               <xsl:value-of select="@id"/>
278             </xsl:attribute>
279             <xsl:copy-of select="*[1]"/>
280             <xsl:copy-of select="m:annotation-xml"/>
281           </xsl:copy>
282         </xsl:when>
283         <xsl:otherwise>
284           <xsl:apply-templates select=".">
285             <xsl:with-param name="IN_OP" select="$IN_OP"/>
286             <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
287             <xsl:with-param name="PARAM" select="$PARAM"/>
288             <xsl:with-param name="PAREN" select="$PAREN"/>
289             <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
290           </xsl:apply-templates>
291         </xsl:otherwise>
292       </xsl:choose>
293     </xsl:when>
294     <xsl:otherwise>
295       <xsl:choose>
296         <xsl:when test="self::m:semantics">
297           <xsl:copy-of select="."/>
298         </xsl:when>
299         <xsl:otherwise>
300           <xsl:apply-templates select=".">
301             <xsl:with-param name="IN_OP" select="$IN_OP"/>
302             <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
303             <xsl:with-param name="PARAM" select="$PARAM"/>
304             <xsl:with-param name="PAREN" select="$PAREN"/>
305             <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
306           </xsl:apply-templates>
307         </xsl:otherwise>
308       </xsl:choose>
309     </xsl:otherwise>
310   </xsl:choose>
311 </xsl:template>
312
313 <xsl:template match = "m:semantics">
314   <xsl:apply-templates select="." mode = "semantics"/>
315 </xsl:template>
316
317
318 <!-- ***************** BASIC CONTAINER ELEMENTS ***************** -->
319
320 <xsl:template match = "m:cn">
321   <xsl:param name="IN_PREC" select="$NO_PREC"/>
322   <xsl:param name="PAREN" select="$PAR_NO"/>
323   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
324   <xsl:choose>
325     <xsl:when test=". &lt; 0 and $IN_PREC &gt; $NO_PREC and $PAREN=$PAR_NO
326                                                    and $PAR_NO_IGNORE=$NO">
327       <m:mfenced separators="">
328         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
329           <xsl:attribute name="xref">
330             <xsl:value-of select="@id"/>
331           </xsl:attribute>
332         </xsl:if>
333         <xsl:apply-templates select="." mode="cn"/>
334       </m:mfenced>
335     </xsl:when>
336     <xsl:otherwise>
337       <xsl:choose>
338         <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
339           <xsl:apply-templates select="." mode="cnid"/>
340         </xsl:when>
341         <xsl:otherwise>
342           <xsl:apply-templates select="." mode="cn"/>
343         </xsl:otherwise>
344       </xsl:choose>
345     </xsl:otherwise>
346   </xsl:choose>
347 </xsl:template>
348
349 <!-- HELM: the entity &#x2062; is not defined -->
350 <xsl:template match = "m:cn" mode="cn">
351   <xsl:choose>
352     <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
353       <m:msub>
354         <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
355         <m:mn> <xsl:value-of select="@base"/> </m:mn>
356       </m:msub>
357     </xsl:when>
358     <xsl:when test="@type='e-notation' and not(@base) and child::m:sep[1]">
359         <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
360         <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
361         <m:mo>e</m:mo>
362         <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
363         <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
364   </xsl:when>
365     <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
366       <m:mfenced separators="">
367         <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
368         <xsl:if test="text()[2] &lt; 0">
369           <m:mo>-</m:mo>
370           <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
371         </xsl:if>
372         <xsl:if test="not(text()[2] &lt; 0)">
373           <m:mo>+</m:mo>
374           <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
375         </xsl:if>
376         <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
377         <m:mo>i</m:mo>
378       </m:mfenced>
379     </xsl:when>
380     <xsl:when test="@type='complex' and @base and child::m:sep[1]">
381       <m:msub>
382         <m:mfenced separators="">
383           <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
384           <xsl:if test="text()[2] &lt; 0">
385             <m:mo>-</m:mo>
386             <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
387           </xsl:if>
388           <xsl:if test="not(text()[2] &lt; 0)">
389             <m:mo>+</m:mo>
390             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
391           </xsl:if>
392           <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
393           <m:mo>i</m:mo>
394         </m:mfenced>
395         <m:mn> <xsl:value-of select="@base"/> </m:mn>
396       </m:msub>
397     </xsl:when>
398     <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
399       <m:mfrac>
400         <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
401         <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
402       </m:mfrac>
403     </xsl:when>
404     <xsl:when test="@type='rational' and @base and child::m:sep[1]">
405       <m:msub>
406         <m:mfenced>
407           <m:mfrac>
408             <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
409             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
410           </m:mfrac>
411         </m:mfenced>
412         <m:mn> <xsl:value-of select="@base"/> </m:mn>
413       </m:msub>
414     </xsl:when>
415     <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
416       <m:mrow>
417         <m:mo>Polar</m:mo>
418         <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
419         <m:mfenced separators=",">
420           <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
421           <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
422         </m:mfenced>
423       </m:mrow>
424     </xsl:when>
425     <xsl:when test="@type='polar' and @base and child::m:sep[1]">
426       <m:msub>
427         <m:mrow>
428           <m:mo>Polar</m:mo>
429           <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
430           <m:mfenced separators=",">
431             <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
432             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
433           </m:mfenced>
434         </m:mrow>
435         <m:mn> <xsl:value-of select="@base"/> </m:mn>
436       </m:msub>
437    </xsl:when>
438     <xsl:otherwise>
439 <!-- HELM: cn could contain MathML presentation -->
440 <!-- HELM: was
441       <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
442      Now is: -->
443     <xsl:choose>
444      <xsl:when test="child::text() and not(*[1])">
445       <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
446      </xsl:when>
447      <xsl:otherwise>
448       <xsl:choose>
449        <xsl:when test="not(*[2])">
450         <xsl:copy-of select="*[1]"/>
451        </xsl:when>
452        <xsl:otherwise>
453         <m:mrow>
454          <xsl:copy-of select="*|text()"/>
455         </m:mrow>
456        </xsl:otherwise>
457       </xsl:choose>
458      </xsl:otherwise>
459     </xsl:choose>
460 <!-- HELM -->
461     </xsl:otherwise>
462   </xsl:choose>
463 </xsl:template>
464
465 <xsl:template match = "m:cn" mode="cnid">
466   <xsl:choose>
467     <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
468       <m:msub xref="{@id}">
469         <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
470         <m:mn> <xsl:value-of select="@base"/> </m:mn>
471       </m:msub>
472     </xsl:when>
473     <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
474       <m:mfenced separators="" xref="{@id}">
475         <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
476         <xsl:if test="text()[2] &lt; 0">
477           <m:mo>-</m:mo>
478           <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
479         </xsl:if>
480         <xsl:if test="not(text()[2] &lt; 0)">
481           <m:mo>+</m:mo>
482           <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
483         </xsl:if>
484         <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
485         <m:mo>i</m:mo>
486       </m:mfenced>
487     </xsl:when>
488     <xsl:when test="@type='complex' and @base and child::m:sep[1]">
489       <m:msub xref="{@id}">
490         <m:mfenced separators="">
491           <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
492           <xsl:if test="text()[2] &lt; 0">
493             <m:mo>-</m:mo>
494             <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
495           </xsl:if>
496           <xsl:if test="not(text()[2] &lt; 0)">
497             <m:mo>+</m:mo>
498             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
499           </xsl:if>
500           <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
501           <m:mo>i</m:mo>
502         </m:mfenced>
503         <m:mn> <xsl:value-of select="@base"/> </m:mn>
504       </m:msub>
505     </xsl:when>
506     <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
507       <m:mfrac xref="{@id}">
508         <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
509         <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
510       </m:mfrac>
511     </xsl:when>
512     <xsl:when test="@type='rational' and @base and child::m:sep[1]">
513       <m:msub xref="{@id}">
514         <m:mfenced>
515           <m:mfrac>
516             <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
517             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
518           </m:mfrac>
519         </m:mfenced>
520         <m:mn> <xsl:value-of select="@base"/> </m:mn>
521       </m:msub>
522     </xsl:when>
523     <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
524       <m:mrow xref="{@id}">
525         <m:mo>Polar</m:mo>
526         <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
527         <m:mfenced separators=",">
528           <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
529           <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
530         </m:mfenced>
531       </m:mrow>
532     </xsl:when>
533     <xsl:when test="@type='polar' and @base and child::m:sep[1]">
534       <m:msub xref="{@id}">
535         <m:mrow>
536           <m:mo>Polar</m:mo>
537           <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
538           <m:mfenced separators=",">
539             <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
540             <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
541           </m:mfenced>
542         </m:mrow>
543         <m:mn> <xsl:value-of select="@base"/> </m:mn>
544       </m:msub>
545    </xsl:when>
546     <xsl:otherwise>
547 <!-- HELM: cn could contain MathML presentation -->
548 <!-- HELM: was
549       <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
550      Now is: -->
551     <xsl:choose>
552      <xsl:when test="child::text() and not(*[1])">
553       <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
554      </xsl:when>
555      <xsl:otherwise>
556       <xsl:variable name="id" select="@id"/>
557       <xsl:choose>
558        <xsl:when test="not(*[2])">
559         <xsl:for-each select="*[1]">
560          <xsl:copy>
561           <xsl:attribute name="xref">
562            <xsl:value-of select="$id"/>
563           </xsl:attribute>
564           <xsl:copy-of select="@*|*"/>
565          </xsl:copy>
566         </xsl:for-each>
567        </xsl:when>
568        <xsl:otherwise>
569         <m:mrow xref="{$id}">
570          <xsl:copy-of select="*|text()"/>
571         </m:mrow>
572        </xsl:otherwise>
573       </xsl:choose>
574      </xsl:otherwise>
575     </xsl:choose>
576 <!-- HELM -->
577     </xsl:otherwise>
578   </xsl:choose>
579 </xsl:template>
580
581 <xsl:template match = "m:ci">
582   <xsl:choose>
583     <xsl:when test="@type='vector' or @type=matrix or @type=set">
584       <m:mi mathvariant="bold">
585         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
586           <xsl:attribute name="xref">
587             <xsl:value-of select="@id"/>
588           </xsl:attribute>
589         </xsl:if>
590         <xsl:apply-templates mode = "semantics"/>
591       </m:mi>
592     </xsl:when>
593     <xsl:when test="child::text() and not(child::*[1])">
594       <m:mi>
595         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
596           <xsl:attribute name="xref">
597             <xsl:value-of select="@id"/>
598           </xsl:attribute>
599         </xsl:if>
600 <!-- HELM: ERROR, added mode="semantics", it didn't generate identifiers -->
601         <xsl:apply-templates mode = "semantics"/>
602       </m:mi>
603     </xsl:when>
604 <!-- HELM: text & markup !!! Not compliant with the specification -->
605     <xsl:when test="child::text() and *[1] and not(*[1]=m:sep)">
606       <m:mrow>
607         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
608           <xsl:attribute name="xref">
609             <xsl:value-of select="@id"/>
610           </xsl:attribute>
611         </xsl:if>
612 <!-- HELM: added semantics mode -->
613         <xsl:apply-templates mode="semantics"/>
614       </m:mrow>
615     </xsl:when>
616 <!-- HELM -->
617     <xsl:otherwise>
618       <xsl:if test="*[2]">
619         <m:mrow>
620           <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
621             <xsl:attribute name="xref">
622               <xsl:value-of select="@id"/>
623             </xsl:attribute>
624           </xsl:if>
625           <xsl:apply-templates select="*"/>
626         </m:mrow>
627       </xsl:if>
628       <xsl:if test="not(*[2])">
629 <!-- HELM: ci could contain MathML presentation -->
630 <!-- HELM: was
631         <xsl:apply-templates select="*[1]"/>
632      Now is: -->
633        <xsl:variable name="id" select="@id"/>
634         <xsl:for-each select="*[1]">
635          <xsl:copy>
636           <xsl:attribute name="xref">
637            <xsl:value-of select="$id"/>
638           </xsl:attribute>
639          <xsl:copy-of select="@*|*"/>
640          </xsl:copy>
641         </xsl:for-each>
642 <!-- HELM -->
643       </xsl:if>
644     </xsl:otherwise>
645   </xsl:choose>
646 </xsl:template>
647
648 <xsl:template match = "m:ci/m:*[not(self::m:sep)]">
649   <xsl:copy-of select = "."/>
650 </xsl:template>
651
652 <!-- HELM: revised version previous Version x.xx from Feb. 18, 2000 -->
653 <xsl:template match = "m:csymbol">
654 <!-- HELM: mrow to maintain csymbol id -->
655    <m:mrow>
656     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
657      <xsl:attribute name="xref">
658       <xsl:value-of select="@id"/>
659      </xsl:attribute>
660     </xsl:if>
661     <xsl:for-each select="* and text()">
662      <xsl:choose>
663      <xsl:when test="text()">
664       <m:mo><xsl:value-of select="."/></m:mo>
665      </xsl:when>
666      <xsl:otherwise>
667       <xsl:copy-of select = "."/>
668      </xsl:otherwise>
669      </xsl:choose>
670     </xsl:for-each>
671    </m:mrow>
672 </xsl:template>
673
674 <!-- HELM: csymbol cannot contain ci or cn elements, but only text and/or 
675 presentation elements. PCDATA should render as if it were wrapped in 
676 an mo. Mixed content: mrow which contains mo + presentation elements --> 
677 <!-- <xsl:template match = "m:csymbol/m:*">
678   <xsl:choose>
679     <xsl:when test="self::m:cn or self::m:ci">
680       <xsl:apply-templates mode = "semantics"/>
681     </xsl:when>
682     <xsl:otherwise>
683       <xsl:copy-of select = "."/>
684     </xsl:otherwise>
685   </xsl:choose>
686 </xsl:template>
687
688 <xsl:template match = "m:csymbol/text()">
689   <xsl:choose>
690     <xsl:when test=". &lt; 0 or . = 0 or . &gt; 0">
691       <m:mn> <xsl:copy-of select = "."/> </m:mn>
692     </xsl:when>
693     <xsl:otherwise>
694       <m:mi> <xsl:copy-of select = "."/> </m:mi>
695     </xsl:otherwise>
696   </xsl:choose>
697 </xsl:template> -->
698
699
700 <!-- ***************** BASIC CONTENT ELEMENTS ***************** -->
701
702 <!-- HELM: the entity &#x2061; is not defined:                -->
703 <!-- fn and domainofapplication are rendered as their content -->
704 <xsl:template match = "m:apply[m:*[1][self::m:fn]]">
705   <m:mrow>
706     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
707       <xsl:attribute name="xref">
708         <xsl:value-of select="@id"/>
709       </xsl:attribute>
710     </xsl:if>
711     <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
712     <m:mo>
713 <!-- HELM: xref added -->        
714         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:fn/@id">
715           <xsl:attribute name="xref">
716             <xsl:value-of select="m:fn/@id"/>
717           </xsl:attribute>
718         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
719     <m:mfenced separators=",">
720       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
721     </m:mfenced>
722   </m:mrow>
723 </xsl:template>
724
725 <!-- fn has been deprecated, so now we use: -->
726 <xsl:template match = "m:apply">
727   <m:mrow>
728     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
729       <xsl:attribute name="xref">
730         <xsl:value-of select="@id"/>
731       </xsl:attribute>
732     </xsl:if>
733     <xsl:choose>
734       <xsl:when test="*[2]=m:domainofapplication">
735         <m:msub>
736           <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
737             <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
738           </xsl:apply-templates>
739           <xsl:apply-templates select = "*[position()=2]" mode = "semantics"/>
740           </m:msub>
741           <m:mo>
742 <!-- HELM: xref added -->        
743         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:domainofapplication/@id">
744           <xsl:attribute name="xref">
745             <xsl:value-of select="m:domainofapplication/@id"/>
746           </xsl:attribute>
747         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
748           <m:mfenced separators=",">
749             <xsl:apply-templates select = "*[position()>2]" mode = "semantics"/>
750             </m:mfenced>
751           </xsl:when>
752           <xsl:otherwise>
753             <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
754               <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
755             </xsl:apply-templates>
756             <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
757             <m:mfenced separators=",">
758               <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
759               </m:mfenced> 
760             </xsl:otherwise>
761           </xsl:choose>
762         </m:mrow>
763       </xsl:template>
764       
765       <xsl:template match = "m:domainofapplication">
766         <xsl:apply-templates select = "*[1]" mode = "semantics"/> 
767         </xsl:template>
768     
769       <xsl:template match = "m:fn">
770         <xsl:apply-templates select = "*[1]" mode = "semantics">
771           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
772         </xsl:apply-templates>
773       </xsl:template>
774       
775       <xsl:template match = "m:interval">
776         <m:mfenced separators=",">
777           <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
778             <xsl:attribute name="xref">
779               <xsl:value-of select="@id"/>
780             </xsl:attribute>
781           </xsl:if>
782           <xsl:if test="@closure='closed' or @closure='closed-open'">
783             <xsl:attribute name="open">[</xsl:attribute>
784           </xsl:if>
785           <xsl:if test="@closure='closed' or @closure='open-closed'">
786             <xsl:attribute name="close">]</xsl:attribute>
787           </xsl:if>
788           <xsl:apply-templates select="*" mode = "semantics"/>
789           </m:mfenced>
790         </xsl:template>
791         
792         <xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
793           <m:mrow>
794     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
795       <xsl:attribute name="xref">
796         <xsl:value-of select="@id"/>
797       </xsl:attribute>
798     </xsl:if>
799     <xsl:apply-templates select = "*[1]" mode = "semantics"/>
800     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
801     <m:mfenced separators=",">
802       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
803     </m:mfenced>
804  </m:mrow>
805 </xsl:template>
806
807 <xsl:template match = "m:apply[*[1][self::m:inverse]]">
808   <xsl:choose>
809     <xsl:when test="*[2]=m:exp or *[2]=m:ln or *[2]=m:sin or *[2]=m:cos or
810                     *[2]=m:tan or *[2]=m:sec or *[2]=m:csc or *[2]=m:cot or
811                     *[2]=m:sinh or *[2]=m:cosh or *[2]=m:tanh or *[2]=m:sech or
812                     *[2]=m:csch or *[2]=m:coth or *[2]=m:arcsin or
813                     *[2]=m:arccos or *[2]=m:arctan">
814       <m:mo>
815         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
816           <xsl:attribute name="xref">
817             <xsl:value-of select="@id"/>
818           </xsl:attribute>
819         </xsl:if>
820         <xsl:apply-templates select="*[2]" mode="inverse"/>
821       </m:mo>
822     </xsl:when>
823     <xsl:otherwise>
824       <m:msup>
825         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
826           <xsl:attribute name="xref">
827             <xsl:value-of select="@id"/>
828           </xsl:attribute>
829         </xsl:if>
830         <xsl:apply-templates select = "*[2]"/>
831         <m:mfenced>
832 <!-- HELM: xref added -->        
833          <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:inverse/@id">
834           <xsl:attribute name="xref">
835             <xsl:value-of select="m:inverse/@id"/>
836           </xsl:attribute>
837          </xsl:if>
838          <m:mn>-1</m:mn>
839         </m:mfenced>
840       </m:msup>
841     </xsl:otherwise>
842   </xsl:choose>
843 </xsl:template>
844
845 <xsl:template match = "*" mode="inverse">
846   <xsl:choose>
847     <xsl:when test="self::m:exp">
848       <xsl:value-of select="'ln'"/>
849     </xsl:when>
850     <xsl:when test="self::m:ln">
851       <xsl:value-of select="'exp'"/>
852     </xsl:when>
853     <xsl:when test="self::m:sin">
854       <xsl:value-of select="'arcsin'"/>
855     </xsl:when>
856     <xsl:when test="self::m:cos">
857       <xsl:value-of select="'arccos'"/>
858     </xsl:when>
859     <xsl:when test="self::m:tan">
860       <xsl:value-of select="'arctan'"/>
861     </xsl:when>
862     <xsl:when test="self::m:sec">
863       <xsl:value-of select="'arcsec'"/>
864     </xsl:when>
865     <xsl:when test="self::m:csc">
866       <xsl:value-of select="'arccsc'"/>
867     </xsl:when>
868     <xsl:when test="self::m:cot">
869       <xsl:value-of select="'arccot'"/>
870     </xsl:when>
871     <xsl:when test="self::m:sinh">
872       <xsl:value-of select="'arcsinh'"/>
873     </xsl:when>
874     <xsl:when test="self::m:cosh">
875       <xsl:value-of select="'arccosh'"/>
876     </xsl:when>
877     <xsl:when test="self::m:tanh">
878       <xsl:value-of select="'arctanh'"/>
879     </xsl:when>
880     <xsl:when test="self::m:sech">
881       <xsl:value-of select="'arcsech'"/>
882     </xsl:when>
883     <xsl:when test="self::m:csch">
884       <xsl:value-of select="'arccsch'"/>
885     </xsl:when>
886     <xsl:when test="self::m:coth">
887       <xsl:value-of select="'arccoth'"/>
888     </xsl:when>
889     <xsl:when test="self::m:arcsin">
890       <xsl:value-of select="'sin'"/>
891     </xsl:when>
892     <xsl:when test="self::m:arccos">
893       <xsl:value-of select="'cos'"/>
894     </xsl:when>
895     <xsl:when test="self::m:arctan">
896       <xsl:value-of select="'tan'"/>
897     </xsl:when>
898   </xsl:choose>
899 </xsl:template>
900
901 <xsl:template match = "m:sep"/>
902
903 <xsl:template match = "m:condition">
904   <xsl:choose>
905     <xsl:when test="parent::m:apply[m:forall[1]]"/>
906     <xsl:otherwise>
907       <xsl:choose>
908         <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
909           <m:mrow xref="{@id}">
910             <xsl:apply-templates select="*" mode = "semantics"/>
911           </m:mrow>
912         </xsl:when>
913         <xsl:otherwise>
914           <xsl:if test="not(*[2])">
915             <xsl:apply-templates select="*" mode = "semantics"/>
916           </xsl:if>
917           <xsl:if test="*[2]">
918             <m:mrow>
919               <xsl:apply-templates select="*" mode = "semantics"/>
920             </m:mrow>
921           </xsl:if>
922         </xsl:otherwise>
923       </xsl:choose>
924     </xsl:otherwise>
925   </xsl:choose>
926 </xsl:template>
927
928 <xsl:template match = "m:declare"/>
929
930 <xsl:template match = "m:lambda">
931   <m:mrow>
932     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
933       <xsl:attribute name="xref">
934         <xsl:value-of select="@id"/>
935       </xsl:attribute>
936     </xsl:if>
937     <m:mo><xsl:text disable-output-escaping='yes'>&#x039B;</xsl:text> </m:mo>
938     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
939     <m:mfenced separators=",">
940       <xsl:for-each select = "*">
941         <xsl:choose>
942           <xsl:when test="self::m:ci or self::m:cn">
943             <xsl:apply-templates select = "." mode="semantics"/>
944           </xsl:when>
945           <xsl:otherwise>
946             <m:mrow>
947               <xsl:apply-templates select = "." mode="semantics"/>
948             </m:mrow>
949           </xsl:otherwise>
950         </xsl:choose>
951       </xsl:for-each>
952     </m:mfenced>
953   </m:mrow>
954 </xsl:template>
955
956 <xsl:template match = "m:apply[*[1][self::m:apply[m:compose[1]]]]">
957   <m:mrow>
958     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
959       <xsl:attribute name="xref">
960         <xsl:value-of select="@id"/>
961       </xsl:attribute>
962     </xsl:if>
963     <xsl:apply-templates select = "*[1]" mode = "semantics"/>
964     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
965     <m:mfenced separators=",">
966       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
967     </m:mfenced>
968  </m:mrow>
969 </xsl:template>
970
971 <xsl:template match = "m:apply[*[1][self::m:compose]]">
972   <m:mfenced separators="">
973     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
974       <xsl:attribute name="xref">
975         <xsl:value-of select="@id"/>
976       </xsl:attribute>
977     </xsl:if>
978     <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] |
979                                        self::m:fn]" mode="semantics"/>
980     <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] |
981                                                             self::m:fn]">
982       <m:mo>
983 <!-- HELM: xref added -->        
984         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:compose/@id">
985           <xsl:attribute name="xref">
986             <xsl:value-of select="../m:compose/@id"/>
987           </xsl:attribute>
988         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2218;</xsl:text></m:mo>
989       <xsl:apply-templates select = "." mode="semantics"/>
990     </xsl:for-each>
991   </m:mfenced>
992 </xsl:template>
993
994 <xsl:template match = "m:ident">
995   <xsl:choose>
996     <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
997       <m:mo xref="{@id}">id</m:mo>
998     </xsl:when>
999     <xsl:otherwise>
1000       <m:mo>id</m:mo>
1001     </xsl:otherwise>
1002   </xsl:choose>
1003 </xsl:template>
1004
1005 <xsl:template match="m:piecewise">
1006   <m:mrow>
1007     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1008       <xsl:attribute name="xref">
1009         <xsl:value-of select="@id"/>
1010       </xsl:attribute>
1011     </xsl:if> 
1012     <xsl:element name="m:mfenced">
1013       <xsl:attribute name="open">{</xsl:attribute>
1014       <xsl:attribute name="close"></xsl:attribute>
1015       <m:mtable groupalign="left left left">
1016         <xsl:for-each select="m:piece">
1017         <m:mtr columnalign="left">
1018           <m:mtd>
1019             <m:mrow>
1020               <xsl:apply-templates select="*[position()=1]" mode = "semantics"/>
1021             </m:mrow>
1022           </m:mtd>
1023           <m:mtd>
1024               <m:mrow>
1025                 <m:mtext>if <m:mspace width="5"/></m:mtext>
1026                 <xsl:apply-templates select="*[position()=2]" mode = "semantics"/>
1027               </m:mrow> 
1028             </m:mtd>
1029           </m:mtr>
1030         </xsl:for-each>
1031         <xsl:if test="m:otherwise">
1032           <m:mtr columnalign="left">
1033             <m:mtd>
1034               <m:mrow>
1035                 <xsl:apply-templates select="m:otherwise/*" mode = "semantics"/>
1036               </m:mrow>
1037             </m:mtd>
1038             <m:mtd>
1039               <m:mrow>
1040               otherwise  
1041             </m:mrow>
1042           </m:mtd>
1043       </m:mtr>
1044     </xsl:if>
1045   </m:mtable>
1046 </xsl:element>
1047 </m:mrow>
1048 </xsl:template>
1049
1050 <!-- HELM: was (it didn't match with prefixed MathML)
1051 <xsl:template match="m:apply[child::*[position()=1 and name()='domain']]">
1052      Now is: -->
1053 <xsl:template match="m:apply[child::*[position()=1 and self::m:domain]]">
1054   <m:mrow>
1055     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1056       <xsl:attribute name="xref">
1057         <xsl:value-of select="@id"/>
1058       </xsl:attribute>
1059     </xsl:if>
1060     <m:mi>domain</m:mi>
1061     <m:mfenced open="(" close=")">
1062       <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
1063     </m:mfenced>
1064   </m:mrow>
1065 </xsl:template>
1066
1067 <!-- HELM: was (it didn't match with prefixed MathML)
1068 <xsl:template match="m:apply[child::*[position()=1 and name()='codomain']]">
1069      Now is: -->
1070 <xsl:template match="m:apply[child::*[position()=1 and self::m:codomain]]">
1071   <m:mrow>
1072     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1073       <xsl:attribute name="xref">
1074         <xsl:value-of select="@id"/>
1075       </xsl:attribute>
1076     </xsl:if>
1077     <m:mi>codomain</m:mi>
1078     <m:mfenced open="(" close=")">
1079       <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
1080     </m:mfenced>
1081   </m:mrow>
1082 </xsl:template>
1083
1084 <!-- HELM: was (it didn't match with prefixed MathML)
1085 <xsl:template match="m:apply[child::*[position()=1 and name()='image']]">
1086      Now is: -->
1087 <xsl:template match="m:apply[child::*[position()=1 and self::m:image]]">
1088   <m:mrow>
1089     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1090       <xsl:attribute name="xref">
1091         <xsl:value-of select="@id"/>
1092       </xsl:attribute>
1093     </xsl:if>
1094     <m:mi>image</m:mi>
1095     <m:mfenced open="(" close=")">
1096       <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
1097     </m:mfenced>
1098   </m:mrow>
1099 </xsl:template>
1100
1101
1102 <!-- ***************** ARITHMETIC, ALGEBRA & LOGIC ***************** -->
1103
1104 <xsl:template match = "m:apply[m:quotient[1]]">
1105   <m:mrow>
1106     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1107       <xsl:attribute name="xref">
1108         <xsl:value-of select="@id"/>
1109       </xsl:attribute>
1110     </xsl:if>
1111     <m:mo form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em">
1112       <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
1113     </m:mo>
1114     <m:mfrac>
1115 <!-- HELM: xref added -->        
1116         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:quotient/@id">
1117           <xsl:attribute name="xref">
1118             <xsl:value-of select="m:quotient/@id"/>
1119           </xsl:attribute>
1120         </xsl:if>
1121       <m:mrow>
1122         <xsl:apply-templates select="*[2]" mode = "semantics">
1123           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1124         </xsl:apply-templates>
1125       </m:mrow>
1126       <m:mrow>
1127         <xsl:apply-templates select="*[3]" mode = "semantics">
1128           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1129           <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1130         </xsl:apply-templates>
1131       </m:mrow>
1132     </m:mfrac>
1133     <m:mo form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em">
1134      <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
1135     </m:mo>
1136   </m:mrow>
1137 </xsl:template>
1138
1139 <xsl:template match = "m:apply[*[1][self::m:exp]]">
1140   <m:msup>
1141     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1142       <xsl:attribute name="xref">
1143         <xsl:value-of select="@id"/>
1144       </xsl:attribute>
1145     </xsl:if>
1146     <m:mo>
1147 <!-- HELM: xref added -->        
1148         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exp/@id">
1149           <xsl:attribute name="xref">
1150             <xsl:value-of select="m:exp/@id"/>
1151           </xsl:attribute>
1152         </xsl:if>e</m:mo>
1153     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
1154   </m:msup>
1155 </xsl:template>
1156
1157 <xsl:template match = "m:apply[m:factorial[1]]">
1158   <m:mrow>
1159     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1160       <xsl:attribute name="xref">
1161         <xsl:value-of select="@id"/>
1162       </xsl:attribute>
1163     </xsl:if>
1164     <xsl:apply-templates select = "*[2]" mode = "semantics">
1165       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1166       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1167     </xsl:apply-templates>
1168     <m:mo>
1169 <!-- HELM: xref added -->        
1170         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorial/@id">
1171           <xsl:attribute name="xref">
1172             <xsl:value-of select="m:factorial/@id"/>
1173           </xsl:attribute>
1174         </xsl:if>!</m:mo>
1175   </m:mrow>
1176 </xsl:template>
1177
1178 <xsl:template match = "m:apply[m:max[1] | m:min[1]]">
1179   <m:mrow>
1180     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1181       <xsl:attribute name="xref">
1182         <xsl:value-of select="@id"/>
1183       </xsl:attribute>
1184     </xsl:if>
1185     <xsl:if test="*[2]=m:bvar">
1186       <m:munder>
1187         <xsl:if test="*[1]=m:max">
1188           <m:mo>
1189 <!-- HELM: xref added -->        
1190         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
1191           <xsl:attribute name="xref">
1192             <xsl:value-of select="m:max/@id"/>
1193           </xsl:attribute>
1194         </xsl:if>max</m:mo>
1195         </xsl:if>
1196         <xsl:if test="*[1]=m:min">
1197           <m:mo>
1198 <!-- HELM: xref added -->        
1199         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
1200           <xsl:attribute name="xref">
1201             <xsl:value-of select="m:min/@id"/>
1202           </xsl:attribute>
1203         </xsl:if>min</m:mo>
1204         </xsl:if>
1205         <xsl:apply-templates select="*[2]" mode = "semantics"/>
1206       </m:munder>
1207       <xsl:if test="*[3]=m:condition">
1208         <m:mfenced open="{{" close="}}" separators="">
1209           <m:mfenced open="" close="" separators=",">
1210             <xsl:for-each select = "*[position()>3]">
1211               <xsl:apply-templates select = "." mode="semantics"/>
1212             </xsl:for-each>
1213           </m:mfenced>
1214           <m:mo>|</m:mo>
1215           <xsl:apply-templates select="*[3]" mode = "semantics"/>
1216         </m:mfenced>
1217       </xsl:if>
1218       <xsl:if test="not(*[3]=m:condition)">
1219         <m:mfenced open="{{" close="}}" separators=",">
1220           <xsl:for-each select = "*[position()>2]">
1221             <xsl:apply-templates select = "." mode="semantics"/>
1222           </xsl:for-each>
1223         </m:mfenced>
1224       </xsl:if>
1225     </xsl:if>
1226     <xsl:if test="*[2]=m:condition">
1227       <xsl:if test="*[1]=m:max">
1228         <m:mo>
1229 <!-- HELM: xref added -->        
1230         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
1231           <xsl:attribute name="xref">
1232             <xsl:value-of select="m:max/@id"/>
1233           </xsl:attribute>
1234         </xsl:if>max</m:mo>
1235       </xsl:if>
1236       <xsl:if test="*[1]=m:min">
1237         <m:mo>
1238 <!-- HELM: xref added -->        
1239         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
1240           <xsl:attribute name="xref">
1241             <xsl:value-of select="m:min/@id"/>
1242           </xsl:attribute>
1243         </xsl:if>min</m:mo>
1244       </xsl:if>
1245       <m:mfenced open="{{" close="}}" separators="">
1246         <xsl:if test="*[3]">
1247           <m:mfenced open="" close="" separators=",">
1248             <xsl:for-each select = "*[position()>2]">
1249               <xsl:apply-templates select = "." mode="semantics"/>
1250             </xsl:for-each>
1251           </m:mfenced>
1252           <m:mo>|</m:mo>
1253         </xsl:if>
1254         <xsl:apply-templates select="*[2]" mode = "semantics"/>
1255       </m:mfenced>
1256     </xsl:if>
1257     <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
1258       <xsl:if test="*[1]=m:max">
1259         <m:mo>
1260 <!-- HELM: xref added -->        
1261         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
1262           <xsl:attribute name="xref">
1263             <xsl:value-of select="m:max/@id"/>
1264           </xsl:attribute>
1265         </xsl:if>max</m:mo>
1266       </xsl:if>
1267       <xsl:if test="*[1]=m:min">
1268         <m:mo>
1269 <!-- HELM: xref added -->        
1270         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
1271           <xsl:attribute name="xref">
1272             <xsl:value-of select="m:min/@id"/>
1273           </xsl:attribute>
1274         </xsl:if>min</m:mo>
1275       </xsl:if>
1276       <m:mfenced open="{{" close="}}" separators=",">
1277         <xsl:for-each select = "*[position()>1]">
1278           <xsl:apply-templates select = "." mode="semantics"/>
1279         </xsl:for-each>
1280       </m:mfenced>
1281     </xsl:if>
1282   </m:mrow>
1283 </xsl:template>
1284
1285 <xsl:template match = "m:apply[m:minus[1]]">
1286   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1287   <xsl:param name="PARAM" select="$NO_PARAM"/>
1288   <xsl:param name="PAREN" select="$PAR_NO"/>
1289   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1290   <xsl:choose>
1291     <xsl:when test="$IN_PREC &gt; $MINUS_PREC or $IN_PREC=$MINUS_PREC and
1292                                                         $PARAM=$PAR_SAME">
1293       <m:mfenced separators="">
1294         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1295           <xsl:attribute name="xref">
1296             <xsl:value-of select="@id"/>
1297           </xsl:attribute>
1298         </xsl:if>
1299         <xsl:apply-templates select="." mode="minus">
1300           <xsl:with-param name="PARAM" select="$PARAM"/>
1301           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1302           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1303         </xsl:apply-templates>
1304       </m:mfenced>
1305     </xsl:when>
1306     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1307                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1308                     and not($SEM_SW=$SEM_XREF_EXT)">
1309       <xsl:apply-templates select="." mode="minus">
1310         <xsl:with-param name="PARAM" select="$PARAM"/>
1311         <xsl:with-param name="PAREN" select="$PAREN"/>
1312         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1313       </xsl:apply-templates>
1314     </xsl:when>
1315     <xsl:otherwise>
1316       <m:mrow>
1317         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1318           <xsl:attribute name="xref">
1319             <xsl:value-of select="@id"/>
1320           </xsl:attribute>
1321         </xsl:if>
1322         <xsl:apply-templates select="." mode="minus">
1323           <xsl:with-param name="PARAM" select="$PARAM"/>
1324           <xsl:with-param name="PAREN" select="$PAREN"/>
1325           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1326         </xsl:apply-templates>
1327       </m:mrow>
1328     </xsl:otherwise>
1329   </xsl:choose>
1330 </xsl:template>
1331
1332 <xsl:template match = "m:apply[m:minus[1]]" mode="minus">
1333   <xsl:param name="PARAM" select="$NO_PARAM"/>
1334   <xsl:param name="PAREN" select="$PAR_NO"/>
1335   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1336   <xsl:if test="not(*[3])">
1337     <m:mo>
1338 <!-- HELM: xref added -->        
1339         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
1340           <xsl:attribute name="xref">
1341             <xsl:value-of select="m:minus/@id"/>
1342           </xsl:attribute>
1343         </xsl:if>-</m:mo>
1344     <xsl:apply-templates select="*[2]" mode = "semantics">
1345       <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
1346       <xsl:with-param name="PAREN" select="$PAREN"/>
1347       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1348     </xsl:apply-templates>
1349   </xsl:if>
1350   <xsl:if test="*[3]">
1351     <xsl:apply-templates select="*[2]" mode = "semantics">
1352       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
1353       <xsl:with-param name="PARAM" select="$PARAM"/>
1354       <xsl:with-param name="PAREN" select="$PAREN"/>
1355       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1356     </xsl:apply-templates>
1357     <m:mo>
1358 <!-- HELM: xref added -->        
1359         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
1360           <xsl:attribute name="xref">
1361             <xsl:value-of select="m:minus/@id"/>
1362           </xsl:attribute>
1363         </xsl:if>-</m:mo>
1364     <xsl:apply-templates select="*[3]" mode = "semantics">
1365       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
1366       <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1367       <xsl:with-param name="PAREN" select="$PAREN"/>
1368       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1369     </xsl:apply-templates>
1370   </xsl:if>
1371 </xsl:template>
1372
1373 <xsl:template match = "m:apply[m:plus[1]]">
1374   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1375   <xsl:param name="PARAM" select="$NO_PARAM"/>
1376   <xsl:param name="PAREN" select="$PAR_NO"/>
1377   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1378   <xsl:choose>
1379     <xsl:when test="$IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and
1380                                                       $PARAM=$PAR_SAME">
1381       <m:mfenced separators="">
1382         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1383           <xsl:attribute name="xref">
1384             <xsl:value-of select="@id"/>
1385           </xsl:attribute>
1386         </xsl:if>
1387         <xsl:apply-templates select="." mode="plus">
1388           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1389           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1390           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1391         </xsl:apply-templates>
1392       </m:mfenced>
1393     </xsl:when>
1394     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1395                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1396                     and not($SEM_SW=$SEM_XREF_EXT)">
1397       <xsl:apply-templates select="." mode="plus">
1398         <xsl:with-param name="PARAM" select="$PARAM"/>
1399         <xsl:with-param name="PAREN" select="$PAREN"/>
1400         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1401       </xsl:apply-templates>
1402     </xsl:when>
1403     <xsl:otherwise>
1404       <m:mrow>
1405         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1406           <xsl:attribute name="xref">
1407             <xsl:value-of select="@id"/>
1408           </xsl:attribute>
1409         </xsl:if>
1410         <xsl:apply-templates select="." mode="plus">
1411           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1412           <xsl:with-param name="PAREN" select="$PAREN"/>
1413           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1414         </xsl:apply-templates>
1415       </m:mrow>
1416     </xsl:otherwise>
1417   </xsl:choose>
1418 </xsl:template>
1419
1420 <xsl:template match = "m:apply[m:plus[1]]" mode="plus">
1421   <xsl:param name="PARAM" select="$NO_PARAM"/>
1422   <xsl:param name="PAREN" select="$PAR_NO"/>
1423   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1424   <xsl:if test="*[2]">
1425     <xsl:apply-templates select="*[2]" mode = "semantics">
1426       <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1427       <xsl:with-param name="PARAM" select="$PARAM"/>
1428       <xsl:with-param name="PAREN" select="$PAREN"/>
1429       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1430     </xsl:apply-templates>
1431     <xsl:for-each select = "*[position()>2]">
1432       <xsl:choose>
1433         <xsl:when test=". &lt; 0">
1434           <m:mo>-</m:mo>
1435           <m:mn> <xsl:value-of select="-."/> </m:mn>
1436         </xsl:when>
1437         <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
1438           <xsl:apply-templates select="." mode = "semantics">
1439             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1440             <xsl:with-param name="PAREN" select="$PAREN"/>
1441             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1442           </xsl:apply-templates>
1443         </xsl:when>
1444         <xsl:otherwise>
1445           <m:mo>
1446 <!-- HELM: xref added -->        
1447         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:plus/@id">
1448           <xsl:attribute name="xref">
1449             <xsl:value-of select="../m:plus/@id"/>
1450           </xsl:attribute>
1451         </xsl:if>+</m:mo>
1452           <xsl:apply-templates select="." mode = "semantics">
1453             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1454             <xsl:with-param name="PAREN" select="$PAREN"/>
1455             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1456           </xsl:apply-templates>
1457         </xsl:otherwise>
1458       </xsl:choose>
1459     </xsl:for-each>
1460   </xsl:if>
1461 </xsl:template>
1462
1463 <!-- HELM WARNING: power id is lost!                              -->
1464 <!-- msup should maintain the power definitionURL info but also the 
1465      reference to apply                                           -->
1466 <xsl:template match = "m:apply[m:power[1]]">
1467   <xsl:choose>
1468     <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] |
1469                          m:gcd[1] | m:lcm[1] | m:sin[1] | m:cos[1] | m:tan[1] |
1470                          m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] |
1471                          m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] |
1472                          m:coth[1] | m:arcsin[1] | m:arccos[1] |
1473                          m:arctan[1] | m:arcsec[1] | m:arccsc[1] | 
1474                          m:arccot[1] | m:arcsinh[1] | m:arccosh[1] |
1475                          m:arctanh[1] | m:arcsech[1] | m:arccsch [1]|
1476                          m:arccoth[1] ]">
1477       <xsl:apply-templates select="*[2]" mode = "semantics"/>
1478     </xsl:when>
1479     <xsl:otherwise>
1480       <m:msup>
1481         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1482           <xsl:attribute name="xref">
1483             <xsl:value-of select="@id"/>
1484           </xsl:attribute>
1485         </xsl:if>
1486         <xsl:apply-templates select = "*[2]" mode = "semantics">
1487           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1488           <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1489         </xsl:apply-templates>
1490         <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1491       </m:msup>
1492     </xsl:otherwise>
1493   </xsl:choose>
1494 </xsl:template>
1495
1496 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
1497   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1498   <xsl:param name="PARAM" select="$NO_PARAM"/>
1499   <xsl:param name="PAREN" select="$PAR_NO"/>
1500   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1501   <xsl:choose>
1502     <xsl:when test="$IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and
1503                                                     $PARAM=$PAR_SAME">
1504       <m:mfenced separators="">
1505         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1506           <xsl:attribute name="xref">
1507             <xsl:value-of select="@id"/>
1508           </xsl:attribute>
1509         </xsl:if>
1510         <xsl:apply-templates select="." mode="remdiv">
1511           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1512           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1513           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1514         </xsl:apply-templates>
1515       </m:mfenced>
1516     </xsl:when>
1517     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1518                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1519                     and not($SEM_SW=$SEM_XREF_EXT)">
1520       <xsl:apply-templates select="." mode="remdiv">
1521         <xsl:with-param name="PARAM" select="$PARAM"/>
1522         <xsl:with-param name="PAREN" select="$PAREN"/>
1523         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1524       </xsl:apply-templates>
1525     </xsl:when>
1526     <xsl:otherwise>
1527       <m:mrow>
1528         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1529           <xsl:attribute name="xref">
1530             <xsl:value-of select="@id"/>
1531           </xsl:attribute>
1532         </xsl:if>
1533         <xsl:apply-templates select="." mode="remdiv">
1534           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1535           <xsl:with-param name="PAREN" select="$PAREN"/>
1536           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1537         </xsl:apply-templates>
1538       </m:mrow>
1539     </xsl:otherwise>
1540   </xsl:choose>
1541 </xsl:template>
1542
1543 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
1544   <xsl:param name="PARAM" select="$NO_PARAM"/>
1545   <xsl:param name="PAREN" select="$PAR_NO"/>
1546   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1547   <xsl:apply-templates select = "*[2]" mode = "semantics">
1548     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
1549       <xsl:with-param name="PARAM" select="$PARAM"/>
1550       <xsl:with-param name="PAREN" select="$PAREN"/>
1551       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1552   </xsl:apply-templates>
1553   <m:mo>
1554     <xsl:if test="m:rem">
1555 <!-- HELM: xref added -->        
1556         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rem/@id">
1557           <xsl:attribute name="xref">
1558             <xsl:value-of select="m:rem/@id"/>
1559           </xsl:attribute>
1560         </xsl:if>      
1561       <xsl:value-of select="'%'"/>
1562     </xsl:if>
1563     <xsl:if test="m:divide">
1564 <!-- HELM: xref added -->        
1565         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divide/@id">
1566           <xsl:attribute name="xref">
1567             <xsl:value-of select="m:divide/@id"/>
1568           </xsl:attribute>
1569         </xsl:if>
1570       <xsl:value-of select="'/'"/>
1571     </xsl:if>
1572   </m:mo>
1573   <xsl:apply-templates select = "*[3]" mode = "semantics">
1574     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
1575     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1576     <xsl:with-param name="PAREN" select="$PAREN"/>
1577     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1578   </xsl:apply-templates>
1579 </xsl:template>
1580
1581 <xsl:template match = "m:apply[m:times[1]]">
1582   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1583   <xsl:param name="PARAM" select="$NO_PARAM"/>
1584   <xsl:param name="PAREN" select="$PAR_NO"/>
1585   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1586   <xsl:choose>
1587     <xsl:when test="$IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and
1588                                                     $PARAM=$PAR_SAME">
1589       <m:mfenced separators="">
1590         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1591           <xsl:attribute name="xref">
1592             <xsl:value-of select="@id"/>
1593           </xsl:attribute>
1594         </xsl:if>
1595         <xsl:apply-templates select="." mode="times">
1596           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1597           <xsl:with-param name="PAREN" select="$PAR_YES"/>
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
1603                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1604                     and not($SEM_SW=$SEM_XREF_EXT)">
1605       <xsl:apply-templates select="." mode="times">
1606         <xsl:with-param name="PARAM" select="$PARAM"/>
1607         <xsl:with-param name="PAREN" select="$PAREN"/>
1608         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1609       </xsl:apply-templates>
1610     </xsl:when>
1611     <xsl:otherwise>
1612       <m:mrow>
1613         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1614           <xsl:attribute name="xref">
1615             <xsl:value-of select="@id"/>
1616           </xsl:attribute>
1617         </xsl:if>
1618         <xsl:apply-templates select="." mode="times">
1619           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1620           <xsl:with-param name="PAREN" select="$PAREN"/>
1621           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1622         </xsl:apply-templates>
1623       </m:mrow>
1624     </xsl:otherwise>
1625   </xsl:choose>
1626 </xsl:template>
1627
1628 <xsl:template match = "m:apply[m:times[1]]" mode="times">
1629   <xsl:param name="PARAM" select="$NO_PARAM"/>
1630   <xsl:param name="PAREN" select="$PAR_NO"/>
1631   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1632   <xsl:apply-templates select="*[2]" mode = "semantics">
1633     <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
1634     <xsl:with-param name="PARAM" select="$PARAM"/>
1635     <xsl:with-param name="PAREN" select="$PAREN"/>
1636     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1637   </xsl:apply-templates>
1638   <xsl:if test="*[3]">
1639     <xsl:for-each select = "*[position()>2]">
1640 <!-- HELM: to distinguish between * and the application -->
1641 <!-- Was:
1642       <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
1643      Now is: -->
1644      <m:mo>
1645 <!-- HELM: xref added -->        
1646         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:times/@id">
1647           <xsl:attribute name="xref">
1648             <xsl:value-of select="../m:times/@id"/>
1649           </xsl:attribute>
1650         </xsl:if>*</m:mo>
1651       <xsl:apply-templates select="." mode = "semantics">
1652         <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
1653         <xsl:with-param name="PAREN" select="$PAREN"/>
1654         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1655       </xsl:apply-templates>
1656     </xsl:for-each>
1657   </xsl:if>
1658 </xsl:template>
1659
1660 <xsl:template match = "m:apply[m:root[1]]">
1661   <m:msqrt>
1662     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1663       <xsl:attribute name="xref">
1664         <xsl:value-of select="@id"/>
1665       </xsl:attribute>
1666     </xsl:if>
1667     <xsl:if test="*[2]=m:degree">
1668       <xsl:apply-templates select="*[3]" mode = "semantics">
1669         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1670         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1671       </xsl:apply-templates>
1672       <xsl:apply-templates select="*[2]" mode = "semantics"/>
1673     </xsl:if>
1674     <xsl:if test="not(*[2]=m:degree)">
1675       <xsl:apply-templates select="*[2]" mode = "semantics">
1676         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1677         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1678       </xsl:apply-templates>
1679       <m:mn>2</m:mn>
1680     </xsl:if>
1681   </m:msqrt>
1682 </xsl:template>
1683
1684 <xsl:template match = "m:apply[m:gcd[1]]">
1685   <m:mrow>
1686     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1687       <xsl:attribute name="xref">
1688         <xsl:value-of select="@id"/>
1689       </xsl:attribute>
1690     </xsl:if>
1691     <xsl:if test="not(parent::m:apply[m:power[1]])">
1692       <m:mo>
1693 <!-- HELM: xref added -->        
1694         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
1695           <xsl:attribute name="xref">
1696             <xsl:value-of select="m:gcd/@id"/>
1697           </xsl:attribute>
1698         </xsl:if>gcd</m:mo>
1699     </xsl:if>
1700     <xsl:if test="parent::m:apply[m:power[1]]">
1701       <m:msup>
1702         <m:mo>
1703 <!-- HELM: xref added -->        
1704         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
1705           <xsl:attribute name="xref">
1706             <xsl:value-of select="m:gcd/@id"/>
1707           </xsl:attribute>
1708         </xsl:if>gcd</m:mo>
1709         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1710       </m:msup>
1711     </xsl:if>
1712     <m:mfenced separators=",">
1713       <xsl:for-each select = "*[position()>1]">
1714         <xsl:apply-templates select = "." mode="semantics"/>
1715       </xsl:for-each>
1716     </m:mfenced>
1717   </m:mrow>
1718 </xsl:template>
1719
1720 <xsl:template match = "m:apply[m:and[1]]">
1721   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1722   <xsl:param name="PAREN" select="$PAR_NO"/>
1723   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1724   <xsl:choose>
1725     <xsl:when test="$IN_PREC &gt; $AND_PREC">
1726       <m:mfenced separators="">
1727         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1728           <xsl:attribute name="xref">
1729             <xsl:value-of select="@id"/>
1730           </xsl:attribute>
1731         </xsl:if>
1732         <xsl:apply-templates select="." mode="and">
1733           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1734           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1735         </xsl:apply-templates>
1736       </m:mfenced>
1737     </xsl:when>
1738     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1739                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1740                     and not($SEM_SW=$SEM_XREF_EXT)">
1741       <xsl:apply-templates select="." mode="and">
1742         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1743         <xsl:with-param name="PAREN" select="$PAREN"/>
1744         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1745       </xsl:apply-templates>
1746     </xsl:when>
1747     <xsl:otherwise>
1748       <m:mrow>
1749         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1750           <xsl:attribute name="xref">
1751             <xsl:value-of select="@id"/>
1752           </xsl:attribute>
1753         </xsl:if>
1754         <xsl:apply-templates select="." mode="and">
1755           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1756           <xsl:with-param name="PAREN" select="$PAREN"/>
1757           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1758         </xsl:apply-templates>
1759       </m:mrow>
1760     </xsl:otherwise>
1761   </xsl:choose>
1762 </xsl:template>
1763
1764 <xsl:template match = "m:apply[m:and[1]]" mode="and">
1765   <xsl:param name="PARAM" select="$NO_PARAM"/>
1766   <xsl:param name="PAREN" select="$PAR_NO"/>
1767   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1768   <xsl:apply-templates select="*[2]" mode = "semantics">
1769     <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1770     <xsl:with-param name="PARAM" select="$PARAM"/>
1771     <xsl:with-param name="PAREN" select="$PAREN"/>
1772     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1773   </xsl:apply-templates>
1774   <xsl:for-each select = "*[position()>2]">
1775     <m:mo>
1776 <!-- HELM: xref added -->        
1777         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:and/@id">
1778           <xsl:attribute name="xref">
1779             <xsl:value-of select="../m:and/@id"/>
1780           </xsl:attribute>
1781         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2227;</xsl:text></m:mo>
1782     <xsl:apply-templates select="." mode = "semantics">
1783       <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1784       <xsl:with-param name="PAREN" select="$PAREN"/>
1785       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1786     </xsl:apply-templates>
1787   </xsl:for-each>
1788 </xsl:template>
1789
1790 <xsl:template match = "m:apply[m:or[1]]">
1791   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1792   <xsl:param name="PAREN" select="$PAR_NO"/>
1793   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1794   <xsl:choose>
1795     <xsl:when test="$IN_PREC &gt; $OR_PREC">
1796       <m:mfenced separators="">
1797         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1798           <xsl:attribute name="xref">
1799             <xsl:value-of select="@id"/>
1800           </xsl:attribute>
1801         </xsl:if>
1802         <xsl:apply-templates select="." mode="or">
1803           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1804           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1805         </xsl:apply-templates>
1806       </m:mfenced>
1807     </xsl:when>
1808     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1809                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1810                     and not($SEM_SW=$SEM_XREF_EXT)">
1811       <xsl:apply-templates select="." mode="or">
1812         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1813         <xsl:with-param name="PAREN" select="$PAREN"/>
1814         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1815       </xsl:apply-templates>
1816     </xsl:when>
1817     <xsl:otherwise>
1818       <m:mrow>
1819         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1820           <xsl:attribute name="xref">
1821             <xsl:value-of select="@id"/>
1822           </xsl:attribute>
1823         </xsl:if>
1824         <xsl:apply-templates select="." mode="or">
1825           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1826           <xsl:with-param name="PAREN" select="$PAREN"/>
1827           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1828         </xsl:apply-templates>
1829       </m:mrow>
1830     </xsl:otherwise>
1831   </xsl:choose>
1832 </xsl:template>
1833
1834 <xsl:template match = "m:apply[m:or[1]]" mode="or">
1835   <xsl:param name="PARAM" select="$NO_PARAM"/>
1836   <xsl:param name="PAREN" select="$PAR_NO"/>
1837   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1838   <xsl:apply-templates select="*[2]" mode = "semantics">
1839     <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1840     <xsl:with-param name="PARAM" select="$PARAM"/>
1841     <xsl:with-param name="PAREN" select="$PAREN"/>
1842     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1843   </xsl:apply-templates>
1844   <xsl:for-each select = "*[position()>2]">
1845     <m:mo> 
1846 <!-- HELM: xref added -->        
1847         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:or/@id">
1848           <xsl:attribute name="xref">
1849             <xsl:value-of select="../m:or/@id"/>
1850           </xsl:attribute>
1851         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2228;</xsl:text></m:mo>
1852     <xsl:apply-templates select="." mode = "semantics">
1853       <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1854       <xsl:with-param name="PAREN" select="$PAREN"/>
1855       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1856     </xsl:apply-templates>
1857   </xsl:for-each>
1858 </xsl:template>
1859
1860 <xsl:template match = "m:apply[m:xor[1]]">
1861   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1862   <xsl:param name="PAREN" select="$PAR_NO"/>
1863   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1864   <xsl:choose>
1865     <xsl:when test="$IN_PREC &gt; $XOR_PREC">
1866       <m:mfenced separators="">
1867         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1868           <xsl:attribute name="xref">
1869             <xsl:value-of select="@id"/>
1870           </xsl:attribute>
1871         </xsl:if>
1872         <xsl:apply-templates select="." mode="xor">
1873           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1874           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1875           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1876         </xsl:apply-templates>
1877       </m:mfenced>
1878     </xsl:when>
1879     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1880                                                 and not($SEM_SW=$SEM_ALL)">
1881       <xsl:apply-templates select="." mode="xor">
1882         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1883         <xsl:with-param name="PAREN" select="$PAREN"/>
1884       </xsl:apply-templates>
1885     </xsl:when>
1886     <xsl:otherwise>
1887       <m:mrow>
1888         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1889           <xsl:attribute name="xref">
1890             <xsl:value-of select="@id"/>
1891           </xsl:attribute>
1892         </xsl:if>
1893         <xsl:apply-templates select="." mode="xor">
1894           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1895           <xsl:with-param name="PAREN" select="$PAREN"/>
1896           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1897         </xsl:apply-templates>
1898       </m:mrow>
1899     </xsl:otherwise>
1900   </xsl:choose>
1901 </xsl:template>
1902
1903 <xsl:template match = "m:apply[m:xor[1]]" mode="xor">
1904   <xsl:param name="PARAM" select="$NO_PARAM"/>
1905   <xsl:param name="PAREN" select="$PAR_NO"/>
1906   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1907   <xsl:apply-templates select="*[2]" mode = "semantics">
1908     <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1909     <xsl:with-param name="PARAM" select="$PARAM"/>
1910     <xsl:with-param name="PAREN" select="$PAREN"/>
1911     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1912   </xsl:apply-templates>
1913   <xsl:for-each select = "*[position()>2]">
1914     <m:mo>
1915 <!-- HELM: xref added -->        
1916         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:xor/@id">
1917           <xsl:attribute name="xref">
1918             <xsl:value-of select="../m:xor/@id"/>
1919           </xsl:attribute>
1920         </xsl:if><xsl:text disable-output-escaping='yes'>&#x22BB;</xsl:text></m:mo>
1921     <xsl:apply-templates select="." mode = "semantics">
1922       <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1923       <xsl:with-param name="PAREN" select="$PAREN"/>
1924       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1925     </xsl:apply-templates>
1926   </xsl:for-each>
1927 </xsl:template>
1928
1929 <xsl:template match = "m:apply[m:not[1]]">
1930   <m:mrow>
1931     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1932       <xsl:attribute name="xref">
1933         <xsl:value-of select="@id"/>
1934       </xsl:attribute>
1935     </xsl:if>
1936 <!-- HELM: was <m:mo>not</m:mo> 
1937      Now is -->
1938     <m:mo>
1939 <!-- HELM: xref added -->        
1940         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:not/@id">
1941           <xsl:attribute name="xref">
1942             <xsl:value-of select="m:not/@id"/>
1943           </xsl:attribute>
1944         </xsl:if>&#x000AC;</m:mo>
1945     <xsl:apply-templates select = "*[2]" mode = "semantics">
1946       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1947     </xsl:apply-templates>
1948   </m:mrow>
1949 </xsl:template>
1950
1951 <xsl:template match = "m:apply[m:forall[1]]">
1952   <m:mrow>
1953     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1954       <xsl:attribute name="xref">
1955         <xsl:value-of select="@id"/>
1956       </xsl:attribute>
1957     </xsl:if>
1958     <m:mo>
1959 <!-- HELM: xref added -->        
1960         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:forall/@id">
1961           <xsl:attribute name="xref">
1962             <xsl:value-of select="m:forall/@id"/>
1963           </xsl:attribute>
1964         </xsl:if>for all</m:mo>
1965     <xsl:if test="count(m:bvar) &gt; 1">
1966       <m:mfenced separators=",">
1967         <xsl:for-each select = "m:bvar">
1968           <xsl:apply-templates select = "." mode="semantics"/>
1969         </xsl:for-each>
1970       </m:mfenced>
1971     </xsl:if>
1972     <xsl:if test="count(m:bvar)=1">
1973       <xsl:apply-templates select = "m:bvar" mode="semantics"/>
1974     </xsl:if>
1975     <xsl:if test="m:condition">
1976       <m:mo>:</m:mo>
1977       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1978       <m:mo>,</m:mo>
1979     </xsl:if>
1980     <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
1981                                 not(self::m:condition)]" mode = "semantics"/>
1982   </m:mrow>
1983 </xsl:template>
1984
1985 <xsl:template match = "m:apply[m:exists[1]]">
1986   <m:mrow>
1987     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1988       <xsl:attribute name="xref">
1989         <xsl:value-of select="@id"/>
1990       </xsl:attribute>
1991     </xsl:if>
1992     <m:mo>
1993 <!-- HELM: xref added -->        
1994         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exists/@id">
1995           <xsl:attribute name="xref">
1996             <xsl:value-of select="m:exists/@id"/>
1997           </xsl:attribute>
1998         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2203;</xsl:text> </m:mo>
1999     <xsl:if test="count(m:bvar) &gt; 1">
2000       <m:mfenced separators=",">
2001         <xsl:for-each select = "m:bvar">
2002           <xsl:apply-templates select = "." mode="semantics"/>
2003         </xsl:for-each>
2004       </m:mfenced>
2005     </xsl:if>
2006     <xsl:if test="count(m:bvar)=1">
2007       <xsl:apply-templates select = "m:bvar" mode="semantics"/>
2008     </xsl:if>
2009     <xsl:if test="m:condition">
2010       <m:mo>,</m:mo>
2011       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
2012     </xsl:if>
2013     <xsl:if test="*[position()>1 and not(self::m:bvar) and not(self::m:condition)]">
2014       <m:mo>:</m:mo>
2015       <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
2016                                 not(self::m:condition)]" mode = "semantics"/>
2017     </xsl:if>
2018   </m:mrow>
2019 </xsl:template>
2020
2021 <!-- HELM WARNING: abs id was lost! -->
2022 <xsl:template match = "m:apply[m:abs[1]]">
2023   <xsl:if test="not(parent::m:apply[m:power[1]])">
2024 <!-- HELM: was
2025     <m:mfenced open="|" close="|" separators="">
2026      Now is: mrow + mo -->
2027      <m:mrow>
2028       <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2029         <xsl:attribute name="xref">
2030           <xsl:value-of select="@id"/>
2031         </xsl:attribute>
2032       </xsl:if>
2033       <m:mo>
2034 <!-- HELM: xref added -->        
2035         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2036           <xsl:attribute name="xref">
2037             <xsl:value-of select="m:abs/@id"/>
2038           </xsl:attribute>
2039         </xsl:if>|</m:mo>
2040       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2041       <m:mo>
2042 <!-- HELM: xref added -->        
2043         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2044           <xsl:attribute name="xref">
2045             <xsl:value-of select="m:abs/@id"/>
2046           </xsl:attribute>
2047         </xsl:if>|</m:mo> 
2048 <!-- HELM: </m:mfenced> -->
2049      </m:mrow>
2050   </xsl:if>
2051   <xsl:if test="parent::m:apply[m:power[1]]">
2052     <m:msup>
2053 <!-- HELM: was
2054       <m:mfenced open="|" close="|" separators="">
2055      Now is: mrow + mo -->
2056       <m:mrow>
2057         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2058           <xsl:attribute name="xref">
2059             <xsl:value-of select="@id"/>
2060           </xsl:attribute>
2061         </xsl:if>
2062         <m:mo>
2063 <!-- HELM: xref added -->        
2064         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2065           <xsl:attribute name="xref">
2066             <xsl:value-of select="m:abs/@id"/>
2067           </xsl:attribute>
2068         </xsl:if>|</m:mo> 
2069         <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2070         <m:mo>
2071 <!-- HELM: xref added -->        
2072         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2073           <xsl:attribute name="xref">
2074             <xsl:value-of select="m:abs/@id"/>
2075           </xsl:attribute>
2076         </xsl:if>|</m:mo> 
2077 <!-- HELM: </m:mfenced> -->
2078       </m:mrow>
2079       <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2080     </m:msup>
2081   </xsl:if>
2082 </xsl:template>
2083
2084 <xsl:template match = "m:apply[m:conjugate[1]]">
2085   <m:mover>
2086     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2087       <xsl:attribute name="xref">
2088         <xsl:value-of select="@id"/>
2089       </xsl:attribute>
2090     </xsl:if>
2091     <m:mrow>
2092       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2093     </m:mrow>
2094     <m:mo>
2095 <!-- HELM: xref added -->        
2096         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:conjugate/@id">
2097           <xsl:attribute name="xref">
2098             <xsl:value-of select="m:conjugate/@id"/>
2099           </xsl:attribute>
2100         </xsl:if><xsl:text disable-output-escaping='yes'>&#x0332;</xsl:text> </m:mo>
2101   </m:mover>
2102 </xsl:template>
2103
2104 <xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
2105   <m:mrow>
2106     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2107       <xsl:attribute name="xref">
2108         <xsl:value-of select="@id"/>
2109       </xsl:attribute>
2110     </xsl:if>
2111     <m:mo>
2112       <xsl:if test="m:arg">
2113 <!-- HELM: xref added -->        
2114         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:arg/@id">
2115           <xsl:attribute name="xref">
2116             <xsl:value-of select="m:arg/@id"/>
2117           </xsl:attribute>
2118         </xsl:if>
2119         <xsl:value-of select="'Arg'"/>
2120       </xsl:if>
2121       <xsl:if test="m:real">
2122 <!-- HELM: xref added -->        
2123         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:real/@id">
2124           <xsl:attribute name="xref">
2125             <xsl:value-of select="m:real/@id"/>
2126           </xsl:attribute>
2127         </xsl:if>
2128         <xsl:value-of select="'Re'"/>
2129       </xsl:if>
2130       <xsl:if test="m:imaginary">
2131 <!-- HELM: xref added -->        
2132         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginary/@id">
2133           <xsl:attribute name="xref">
2134             <xsl:value-of select="m:imaginary/@id"/>
2135           </xsl:attribute>
2136         </xsl:if>
2137         <xsl:value-of select="'Im'"/>
2138       </xsl:if>
2139     </m:mo>
2140     <m:mfenced separators="">
2141       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2142     </m:mfenced>
2143   </m:mrow>
2144 </xsl:template>
2145
2146 <!-- HELM: was (it didn't match with prefixed MathML)
2147 <xsl:template match="m:apply[child::*[position()=1 and name()='lcm']]">
2148      Now is: -->
2149 <xsl:template match="m:apply[child::*[position()=1 and self::m:lcm]]">
2150   <m:mrow>
2151     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2152       <xsl:attribute name="xref">
2153         <xsl:value-of select="@id"/>
2154       </xsl:attribute>
2155     </xsl:if>
2156     <xsl:if test="not(parent::m:apply[m:power[1]])">
2157       <m:mo>
2158 <!-- HELM: xref added -->        
2159         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
2160           <xsl:attribute name="xref">
2161             <xsl:value-of select="m:lcm/@id"/>
2162           </xsl:attribute>
2163         </xsl:if>lcm</m:mo>
2164     </xsl:if>
2165     <xsl:if test="parent::m:apply[m:power[1]]">
2166       <m:msup>
2167         <m:mo>
2168 <!-- HELM: xref added -->        
2169         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
2170           <xsl:attribute name="xref">
2171             <xsl:value-of select="m:lcm/@id"/>
2172           </xsl:attribute>
2173         </xsl:if>lcm</m:mo>
2174         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2175         </m:msup>
2176       </xsl:if>
2177       <m:mfenced separators=",">
2178         <xsl:for-each select = "*[position()>1]">
2179           <xsl:apply-templates select = "." mode="semantics"/>
2180           </xsl:for-each>
2181         </m:mfenced>
2182       </m:mrow>
2183     </xsl:template>
2184
2185 <!-- HELM: was (it didn't match with prefixed MathML)
2186 <xsl:template match="m:apply[child::*[position()=1 and name()='floor']]">
2187      Now is: -->
2188 <xsl:template match="m:apply[child::*[position()=1 and self::m:floor]]">
2189   <m:mrow>
2190     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2191       <xsl:attribute name="xref">
2192         <xsl:value-of select="@id"/>
2193       </xsl:attribute>
2194     </xsl:if>
2195     <m:mo>
2196 <!-- HELM: xref added -->        
2197         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
2198           <xsl:attribute name="xref">
2199             <xsl:value-of select="m:floor/@id"/>
2200           </xsl:attribute>
2201         </xsl:if>
2202 <!-- HELM: not rendered correctly <![CDATA[&LeftFloor;]]> -->
2203       <xsl:text disable-output-escaping="yes">&#x230A;</xsl:text>
2204     </m:mo>
2205     <xsl:apply-templates select="child::*[position()=last()]" mode="semantics"/>
2206     <m:mo>
2207 <!-- HELM: xref added -->        
2208         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
2209           <xsl:attribute name="xref">
2210             <xsl:value-of select="m:floor/@id"/>
2211           </xsl:attribute>
2212         </xsl:if>
2213 <!-- HELM: not rendered correctly <![CDATA[&RightFloor;]]> -->
2214 <xsl:text disable-output-escaping="yes">&#x230B;</xsl:text>
2215     </m:mo>
2216 </m:mrow>
2217 </xsl:template>
2218
2219 <!-- HELM: was (it didn't match with prefixed MathML)
2220 <xsl:template match="m:apply[child::*[position()=1 and name()='ceiling']]">
2221      Now is: -->
2222 <xsl:template match="m:apply[child::*[position()=1 and self::m:ceiling]]">
2223   <m:mrow>
2224     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2225       <xsl:attribute name="xref">
2226         <xsl:value-of select="@id"/>
2227       </xsl:attribute>
2228     </xsl:if>
2229     <m:mo>
2230 <!-- HELM: xref added -->        
2231         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
2232           <xsl:attribute name="xref">
2233             <xsl:value-of select="m:ceiling/@id"/>
2234           </xsl:attribute>
2235         </xsl:if>
2236 <!-- HELM: not rendered correctly <![CDATA[&LeftCeiling;]]> -->
2237       <xsl:text disable-output-escaping="yes">&#x2308;</xsl:text>
2238     </m:mo>
2239     <xsl:apply-templates select="child::*[position()=last()]"  mode="semantics"/>
2240     <m:mo>
2241 <!-- HELM: xref added -->        
2242         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
2243           <xsl:attribute name="xref">
2244             <xsl:value-of select="m:ceiling/@id"/>
2245           </xsl:attribute>
2246         </xsl:if>
2247 <!-- HELM: not rendered correctly <![CDATA[&RightCeiling;]]> -->
2248       <xsl:text disable-output-escaping="yes">&#x2309;</xsl:text>
2249     </m:mo>
2250   </m:mrow>
2251 </xsl:template>
2252
2253
2254 <!-- ***************** RELATIONS ***************** -->
2255
2256 <xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies
2257                      | m:in | m:notin | m:notsubset | m:notprsubset
2258                      | m:subset | m:prsubset | m:eq | m:gt | m:lt
2259                      | m:geq | m:leq | m:equivalent | m:factorof]">
2260   <m:mrow>
2261     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2262       <xsl:attribute name="xref">
2263         <xsl:value-of select="@id"/>
2264       </xsl:attribute>
2265     </xsl:if>
2266     <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:factorof or *[1]=m:tendsto or
2267                   *[1]=m:implies or *[1]=m:in or *[1]=m:notin or
2268                   *[1]=m:notsubset or *[1]=m:notprsubset">
2269       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2270       <m:mo>
2271         <xsl:if test="*[1]=m:neq">
2272 <!-- HELM: xref added -->        
2273         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:neq/@id">
2274           <xsl:attribute name="xref">
2275             <xsl:value-of select="m:neq/@id"/>
2276           </xsl:attribute>
2277         </xsl:if>
2278          <xsl:text disable-output-escaping='yes'>&#x2260;</xsl:text>
2279         </xsl:if>
2280         <xsl:if test="*[1]=m:approx">
2281 <!-- HELM: xref added -->        
2282         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:approx/@id">
2283           <xsl:attribute name="xref">
2284             <xsl:value-of select="m:approx/@id"/>
2285           </xsl:attribute>
2286         </xsl:if>
2287          <xsl:text disable-output-escaping='yes'>&#x224A;</xsl:text>
2288         </xsl:if>
2289         <xsl:if test="*[1]=m:factorof">
2290 <!-- HELM: xref added -->        
2291         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorof/@id">
2292           <xsl:attribute name="xref">
2293             <xsl:value-of select="m:factorof/@id"/>
2294           </xsl:attribute>
2295         </xsl:if>
2296           |
2297         </xsl:if>
2298         <xsl:if test="*[1]=m:tendsto">
2299 <!-- HELM: xref added -->        
2300         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2301           <xsl:attribute name="xref">
2302             <xsl:value-of select="m:tendsto/@id"/>
2303           </xsl:attribute>
2304         </xsl:if>
2305          <xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text>
2306         </xsl:if>
2307         <xsl:if test="*[1]=m:implies">
2308 <!-- HELM: xref added -->        
2309         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:implies/@id">
2310           <xsl:attribute name="xref">
2311             <xsl:value-of select="m:implies/@id"/>
2312           </xsl:attribute>
2313         </xsl:if>
2314          <xsl:text disable-output-escaping='yes'>&#x21D2;</xsl:text>
2315         </xsl:if>
2316         <xsl:if test="*[1]=m:in">
2317 <!-- HELM: xref added -->        
2318         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:in/@id">
2319           <xsl:attribute name="xref">
2320             <xsl:value-of select="m:in/@id"/>
2321           </xsl:attribute>
2322         </xsl:if>
2323           <xsl:text disable-output-escaping='yes'>&#x2208;</xsl:text>
2324         </xsl:if>
2325         <xsl:if test="*[1]=m:notin">
2326 <!-- HELM: xref added -->        
2327         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notin/@id">
2328           <xsl:attribute name="xref">
2329             <xsl:value-of select="m:notin/@id"/>
2330           </xsl:attribute>
2331         </xsl:if>
2332          <xsl:text disable-output-escaping='yes'>&#x2209;</xsl:text>
2333         </xsl:if>
2334         <xsl:if test="*[1]=m:notsubset">
2335 <!-- HELM: xref added -->        
2336         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notsubset/@id">
2337           <xsl:attribute name="xref">
2338             <xsl:value-of select="m:notsubset/@id"/>
2339           </xsl:attribute>
2340         </xsl:if>
2341          <xsl:text disable-output-escaping='yes'>&#x2284;</xsl:text>
2342         </xsl:if>
2343         <xsl:if test="*[1]=m:notprsubset">
2344 <!-- HELM: xref added -->        
2345         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notprsubset/@id">
2346           <xsl:attribute name="xref">
2347             <xsl:value-of select="m:notprsubset/@id"/>
2348           </xsl:attribute>
2349         </xsl:if>
2350          <xsl:text disable-output-escaping='yes'>&#x2288;</xsl:text>
2351         </xsl:if>
2352       </m:mo>
2353       <xsl:apply-templates select = "*[3]" mode = "semantics"/>
2354       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
2355         <m:mo>
2356 <!-- HELM: xref added -->        
2357         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2358           <xsl:attribute name="xref">
2359             <xsl:value-of select="m:tendsto/@id"/>
2360           </xsl:attribute>
2361         </xsl:if>-</m:mo>
2362       </xsl:if>
2363       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
2364         <m:mo>
2365 <!-- HELM: xref added -->        
2366         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2367           <xsl:attribute name="xref">
2368             <xsl:value-of select="m:tendsto/@id"/>
2369           </xsl:attribute>
2370         </xsl:if>+</m:mo>
2371       </xsl:if>
2372     </xsl:if>
2373     <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt
2374                or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
2375       <xsl:apply-templates select = "*[2]" mode="semantics"/>
2376       <xsl:for-each select = "*[position()>2]">
2377         <m:mo>
2378           <xsl:if test="../*[self::m:subset][1]">
2379 <!-- HELM: xref added -->        
2380         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:subset/@id">
2381           <xsl:attribute name="xref">
2382             <xsl:value-of select="../m:subset/@id"/>
2383           </xsl:attribute>
2384         </xsl:if>
2385             <xsl:text disable-output-escaping='yes'>&#x2286;</xsl:text>
2386           </xsl:if>
2387           <xsl:if test="../*[self::m:prsubset][1]">
2388 <!-- HELM: xref added -->        
2389         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:prsubset/@id">
2390           <xsl:attribute name="xref">
2391             <xsl:value-of select="../m:prsubset/@id"/>
2392           </xsl:attribute>
2393         </xsl:if>
2394            <xsl:text disable-output-escaping='yes'>&#x2282;</xsl:text>
2395           </xsl:if>
2396           <xsl:if test="../*[self::m:eq][1]">
2397 <!-- HELM: xref added -->        
2398         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:eq/@id">
2399           <xsl:attribute name="xref">
2400             <xsl:value-of select="../m:eq/@id"/>
2401           </xsl:attribute>
2402         </xsl:if>
2403             <xsl:value-of select="'='"/>
2404           </xsl:if>
2405           <xsl:if test="../*[self::m:gt][1]">
2406 <!-- HELM: xref added -->        
2407         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:gt/@id">
2408           <xsl:attribute name="xref">
2409             <xsl:value-of select="../m:gt/@id"/>
2410           </xsl:attribute>
2411         </xsl:if>
2412             <xsl:value-of select="'&gt;'"/>
2413           </xsl:if>
2414           <xsl:if test="../*[self::m:lt][1]">
2415 <!-- HELM: xref added -->        
2416         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:lt/@id">
2417           <xsl:attribute name="xref">
2418             <xsl:value-of select="../m:lt/@id"/>
2419           </xsl:attribute>
2420         </xsl:if>
2421             <xsl:value-of select="'&lt;'"/>
2422           </xsl:if>
2423           <xsl:if test="../*[self::m:geq][1]">
2424 <!-- HELM: xref added -->        
2425         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:geq/@id">
2426           <xsl:attribute name="xref">
2427             <xsl:value-of select="../m:geq/@id"/>
2428           </xsl:attribute>
2429         </xsl:if>
2430            <xsl:text disable-output-escaping='yes'>&#x2265;</xsl:text>
2431           </xsl:if>
2432           <xsl:if test="../*[self::m:leq][1]">
2433 <!-- HELM: xref added -->        
2434         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:leq/@id">
2435           <xsl:attribute name="xref">
2436             <xsl:value-of select="../m:leq/@id"/>
2437           </xsl:attribute>
2438         </xsl:if>
2439            <xsl:text disable-output-escaping='yes'>&#x2264;</xsl:text>
2440           </xsl:if>
2441           <xsl:if test="../*[self::m:equivalent][1]">
2442 <!-- HELM: xref added -->        
2443         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:equivalent/@id">
2444           <xsl:attribute name="xref">
2445             <xsl:value-of select="../m:equivalent/@id"/>
2446           </xsl:attribute>
2447         </xsl:if>
2448            <xsl:text disable-output-escaping='yes'>&#x2261;</xsl:text>
2449           </xsl:if>
2450         </m:mo>
2451         <xsl:apply-templates select = "." mode="semantics"/>
2452       </xsl:for-each>
2453     </xsl:if>
2454   </m:mrow>
2455 </xsl:template>
2456
2457
2458 <!-- ***************** CALCULUS ***************** -->
2459
2460 <xsl:template match = "m:apply[*[1][self::m:ln]]">
2461   <m:mrow>
2462     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2463       <xsl:attribute name="xref">
2464         <xsl:value-of select="@id"/>
2465       </xsl:attribute>
2466     </xsl:if>
2467     <xsl:choose>
2468       <xsl:when test="parent::m:apply[m:power[1]]">
2469         <m:msup>
2470           <m:mo>
2471 <!-- HELM: xref added -->        
2472         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
2473           <xsl:attribute name="xref">
2474             <xsl:value-of select="m:ln/@id"/>
2475           </xsl:attribute>
2476         </xsl:if>ln</m:mo>
2477           <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2478         </m:msup>
2479       </xsl:when>
2480       <xsl:otherwise>
2481         <m:mo>
2482 <!-- HELM: xref added -->        
2483         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
2484           <xsl:attribute name="xref">
2485             <xsl:value-of select="m:ln/@id"/>
2486           </xsl:attribute>
2487         </xsl:if>ln</m:mo>
2488       </xsl:otherwise>
2489     </xsl:choose>
2490     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
2491     <xsl:apply-templates select = "*[2]" mode = "semantics">
2492       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2493     </xsl:apply-templates>
2494   </m:mrow>
2495 </xsl:template>
2496
2497 <xsl:template match = "m:apply[m:log[1]]">
2498   <m:mrow>
2499     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2500       <xsl:attribute name="xref">
2501         <xsl:value-of select="@id"/>
2502       </xsl:attribute>
2503     </xsl:if>
2504     <xsl:choose>
2505       <xsl:when test="parent::m:apply[m:power[1]]">
2506         <xsl:if test="not(*[2]=m:logbase)">
2507           <m:msup>
2508             <m:mo>
2509 <!-- HELM: xref added -->        
2510         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2511           <xsl:attribute name="xref">
2512             <xsl:value-of select="m:log/@id"/>
2513           </xsl:attribute>
2514         </xsl:if>log</m:mo>
2515             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2516           </m:msup>
2517         </xsl:if>
2518         <xsl:if test="*[2]=m:logbase">
2519           <m:msubsup>
2520             <m:mo>
2521 <!-- HELM: xref added -->        
2522         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2523           <xsl:attribute name="xref">
2524             <xsl:value-of select="m:log/@id"/>
2525           </xsl:attribute>
2526         </xsl:if>log</m:mo>
2527             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2528             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
2529           </m:msubsup>
2530         </xsl:if>
2531       </xsl:when>
2532       <xsl:otherwise>
2533         <xsl:if test="not(*[2]=m:logbase)">
2534           <m:mo>
2535 <!-- HELM: xref added -->        
2536         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2537           <xsl:attribute name="xref">
2538             <xsl:value-of select="m:log/@id"/>
2539           </xsl:attribute>
2540         </xsl:if>log</m:mo>
2541         </xsl:if>
2542         <xsl:if test="*[2]=m:logbase">
2543           <m:msub>
2544             <m:mo>
2545 <!-- HELM: xref added -->        
2546         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2547           <xsl:attribute name="xref">
2548             <xsl:value-of select="m:log/@id"/>
2549           </xsl:attribute>
2550         </xsl:if>log</m:mo>
2551             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
2552           </m:msub>
2553         </xsl:if>
2554       </xsl:otherwise>
2555     </xsl:choose>
2556     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
2557     <xsl:if test="*[2]=m:logbase">
2558       <xsl:apply-templates select = "*[3]" mode = "semantics">
2559         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2560       </xsl:apply-templates>
2561     </xsl:if>
2562     <xsl:if test="not(*[2]=m:logbase)">
2563       <xsl:apply-templates select = "*[2]" mode = "semantics">
2564         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2565       </xsl:apply-templates>
2566     </xsl:if>
2567   </m:mrow>
2568 </xsl:template>
2569
2570 <xsl:template match = "m:apply[m:diff[1]]">
2571   <m:mrow>
2572     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2573       <xsl:attribute name="xref">
2574         <xsl:value-of select="@id"/>
2575       </xsl:attribute>
2576     </xsl:if>
2577     <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
2578       <m:mfrac>
2579 <!-- HELM: xref added -->        
2580         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
2581           <xsl:attribute name="xref">
2582             <xsl:value-of select="m:diff/@id"/>
2583           </xsl:attribute>
2584         </xsl:if>
2585         <m:msup>
2586           <m:mo>d</m:mo>
2587           <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
2588         </m:msup>
2589         <m:mrow>
2590           <m:mo>d</m:mo>
2591           <m:msup>
2592             <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
2593             <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
2594           </m:msup>
2595         </m:mrow>
2596       </m:mfrac>
2597     </xsl:if>
2598     <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
2599       <m:mfrac>
2600 <!-- HELM: xref added -->        
2601         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
2602           <xsl:attribute name="xref">
2603             <xsl:value-of select="m:diff/@id"/>
2604           </xsl:attribute>
2605         </xsl:if>
2606         <m:mo>d</m:mo>
2607         <m:mrow>
2608           <m:mo>d</m:mo>
2609           <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
2610         </m:mrow>
2611       </m:mfrac>
2612     </xsl:if>
2613     <xsl:apply-templates select = "*[3]" mode = "semantics"/>
2614   </m:mrow>
2615 </xsl:template>
2616
2617 <xsl:template match = "m:apply[m:partialdiff[1]]">
2618   <m:mrow>
2619     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2620       <xsl:attribute name="xref">
2621         <xsl:value-of select="@id"/>
2622       </xsl:attribute>
2623     </xsl:if>
2624     <xsl:for-each select = "m:bvar">
2625       <xsl:if test="*[last()]=m:degree">
2626         <m:mfrac>
2627 <!-- HELM: xref added -->        
2628         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
2629           <xsl:attribute name="xref">
2630             <xsl:value-of select="../m:partialdiff/@id"/>
2631           </xsl:attribute>
2632         </xsl:if>
2633           <m:msup>
2634              <m:mo>d</m:mo>
2635              <xsl:apply-templates select = "m:degree" mode = "semantics"/>
2636           </m:msup>
2637           <m:mrow>
2638             <m:mo>d</m:mo>
2639             <m:msup>
2640               <xsl:apply-templates select = "*[1]" mode = "semantics"/>
2641               <xsl:apply-templates select = "m:degree" mode = "semantics"/>
2642             </m:msup>
2643           </m:mrow>
2644         </m:mfrac>
2645       </xsl:if>
2646       <xsl:if test="not(*[last()]=m:degree)">
2647         <m:mfrac>
2648 <!-- HELM: xref added -->        
2649         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
2650           <xsl:attribute name="xref">
2651             <xsl:value-of select="../m:partialdiff/@id"/>
2652           </xsl:attribute>
2653         </xsl:if>
2654           <m:mo>d</m:mo>
2655           <m:mrow>
2656             <m:mo>d</m:mo>
2657             <xsl:apply-templates select = "*[1]" mode = "semantics"/>
2658           </m:mrow>
2659         </m:mfrac>
2660       </xsl:if>
2661     </xsl:for-each>
2662     <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
2663   </m:mrow>
2664 </xsl:template>
2665
2666 <xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
2667   <xsl:apply-templates select="*" mode = "semantics"/>
2668 </xsl:template>
2669
2670 <xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
2671   <m:mrow>
2672     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2673       <xsl:attribute name="xref">
2674         <xsl:value-of select="@id"/>
2675       </xsl:attribute>
2676     </xsl:if>
2677     <m:mo>
2678       <xsl:if test="*[1]=m:divergence">
2679 <!-- HELM: xref added -->        
2680         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divergence/@id">
2681           <xsl:attribute name="xref">
2682             <xsl:value-of select="m:divergence/@id"/>
2683           </xsl:attribute>
2684         </xsl:if>
2685         <xsl:value-of select="'div'"/>
2686       </xsl:if>
2687       <xsl:if test="*[1]=m:grad">
2688 <!-- HELM: xref added -->        
2689         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:grad/@id">
2690           <xsl:attribute name="xref">
2691             <xsl:value-of select="m:grad/@id"/>
2692           </xsl:attribute>
2693         </xsl:if>
2694         <xsl:value-of select="'grad'"/>
2695       </xsl:if>
2696       <xsl:if test="*[1]=m:curl">
2697 <!-- HELM: xref added -->        
2698         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:curl/@id">
2699           <xsl:attribute name="xref">
2700             <xsl:value-of select="m:curl/@id"/>
2701           </xsl:attribute>
2702         </xsl:if>
2703         <xsl:value-of select="'curl'"/>
2704       </xsl:if>
2705     </m:mo>
2706     <xsl:choose>
2707       <xsl:when test="*[2]=m:ci">
2708         <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2709       </xsl:when>
2710       <xsl:otherwise>
2711         <m:mfenced separators="">
2712           <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2713         </m:mfenced>
2714       </xsl:otherwise>
2715     </xsl:choose>
2716   </m:mrow>
2717 </xsl:template>
2718
2719 <xsl:template match = "m:apply[m:laplacian[1]]">
2720   <m:mrow>
2721     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2722       <xsl:attribute name="xref">
2723         <xsl:value-of select="@id"/>
2724       </xsl:attribute>
2725     </xsl:if>
2726     <m:msup>
2727       <m:mo>
2728 <!-- HELM: xref added -->        
2729         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:laplacian/@id">
2730           <xsl:attribute name="xref">
2731             <xsl:value-of select="m:laplacian/@id"/>
2732           </xsl:attribute>
2733         </xsl:if>
2734         <xsl:text disable-output-escaping='yes'>&#x0394;</xsl:text></m:mo>
2735       <m:mn>2</m:mn>
2736     </m:msup>
2737     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2738   </m:mrow>
2739 </xsl:template>
2740
2741
2742 <!-- ***************** SET THEORY ***************** -->
2743
2744 <xsl:template match = "m:set | m:list">
2745   <m:mfenced open="{{" close="}}" separators="">
2746     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2747       <xsl:attribute name="xref">
2748         <xsl:value-of select="@id"/>
2749       </xsl:attribute>
2750     </xsl:if>
2751     <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
2752       <xsl:apply-templates select="m:bvar" mode = "semantics"/>
2753       <m:mo>|</m:mo>
2754       <xsl:apply-templates select="m:condition" mode = "semantics"/>
2755     </xsl:if>
2756     <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
2757       <m:mfenced open="" close="" separators=",">
2758         <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
2759           <xsl:apply-templates select = "." mode="semantics"/>
2760         </xsl:for-each>
2761       </m:mfenced>
2762       <m:mo>|</m:mo>
2763       <xsl:apply-templates select="m:condition" mode = "semantics"/>
2764     </xsl:if>
2765     <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
2766       <m:mfenced open="" close="" separators=",">
2767         <xsl:for-each select = "*">
2768           <xsl:apply-templates select = "." mode="semantics"/>
2769         </xsl:for-each>
2770       </m:mfenced>
2771     </xsl:if>
2772   </m:mfenced>
2773 </xsl:template>
2774
2775 <xsl:template match = "m:apply[m:union[1]]">
2776   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2777   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2778   <xsl:param name="PARAM" select="$NO_PARAM"/>
2779   <xsl:param name="PAREN" select="$PAR_NO"/>
2780   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2781   <xsl:choose>
2782     <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC
2783                     and $PARAM=$PAR_SAME and not($IN_OP=$UNION_OP)">
2784       <m:mfenced separators="">
2785         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2786           <xsl:attribute name="xref">
2787             <xsl:value-of select="@id"/>
2788           </xsl:attribute>
2789         </xsl:if>
2790         <xsl:apply-templates select="." mode="union">
2791           <xsl:with-param name="PARAM" select="$PARAM"/>
2792           <xsl:with-param name="PAREN" select="$PAREN"/>
2793           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2794         </xsl:apply-templates>
2795       </m:mfenced>
2796     </xsl:when>
2797     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2798                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2799                     and not($SEM_SW=$SEM_XREF_EXT)">
2800       <xsl:apply-templates select="." mode="union">
2801         <xsl:with-param name="PARAM" select="$PARAM"/>
2802         <xsl:with-param name="PAREN" select="$PAREN"/>
2803         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2804       </xsl:apply-templates>
2805     </xsl:when>
2806     <xsl:otherwise>
2807       <m:mrow>
2808         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2809           <xsl:attribute name="xref">
2810             <xsl:value-of select="@id"/>
2811           </xsl:attribute>
2812         </xsl:if>
2813         <xsl:apply-templates select="." mode="union">
2814           <xsl:with-param name="IN_OP" select="$UNION_OP"/>
2815           <xsl:with-param name="PARAM" select="$PARAM"/>
2816           <xsl:with-param name="PAREN" select="$PAREN"/>
2817           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2818         </xsl:apply-templates>
2819       </m:mrow>
2820     </xsl:otherwise>
2821   </xsl:choose>
2822 </xsl:template>
2823
2824 <xsl:template match = "m:apply[m:union[1]]" mode="union">
2825   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2826   <xsl:param name="PARAM" select="$NO_PARAM"/>
2827   <xsl:param name="PAREN" select="$PAR_NO"/>
2828   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2829   <xsl:apply-templates select = "*[2]" mode="semantics">
2830     <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
2831     <xsl:with-param name="PARAM" select="$PARAM"/>
2832     <xsl:with-param name="PAREN" select="$PAREN"/>
2833     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2834   </xsl:apply-templates>
2835   <xsl:for-each select = "*[position()>2]">
2836     <m:mo>
2837 <!-- HELM: xref added -->        
2838         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:union/@id">
2839           <xsl:attribute name="xref">
2840             <xsl:value-of select="../m:union/@id"/>
2841           </xsl:attribute>
2842         </xsl:if>&#x22C3;</m:mo>
2843 <!-- HELM: not rendered correctly <![CDATA[&Union;]]> -->
2844   <!--   <xsl:text disable-output-escaping="yes">&#x22C3;</xsl:text></m:mo>-->
2845     <xsl:apply-templates select = "." mode="semantics">
2846       <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
2847       <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
2848       <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
2849       <xsl:with-param name="PAREN" select="$PAREN"/>
2850       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
2851     </xsl:apply-templates>
2852   </xsl:for-each>
2853 </xsl:template>
2854
2855 <xsl:template match = "m:apply[m:intersect[1]]">
2856   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2857   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2858   <xsl:param name="PARAM" select="$NO_PARAM"/>
2859   <xsl:param name="PAREN" select="$PAR_NO"/>
2860   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2861   <xsl:choose>
2862     <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC or $IN_PREC=$INTERSECT_PREC
2863                     and $PARAM=$PAR_SAME and not($IN_OP=$INTERSECT_OP)">
2864       <m:mfenced separators="">
2865         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2866           <xsl:attribute name="xref">
2867             <xsl:value-of select="@id"/>
2868           </xsl:attribute>
2869         </xsl:if>
2870         <xsl:apply-templates select="." mode="intersect">
2871           <xsl:with-param name="PARAM" select="$PARAM"/>
2872           <xsl:with-param name="PAREN" select="$PAREN"/>
2873           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2874         </xsl:apply-templates>
2875       </m:mfenced>
2876     </xsl:when>
2877     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2878                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2879                     and not($SEM_SW=$SEM_XREF_EXT)">
2880       <xsl:apply-templates select="." mode="intersect">
2881         <xsl:with-param name="PARAM" select="$PARAM"/>
2882         <xsl:with-param name="PAREN" select="$PAREN"/>
2883         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2884       </xsl:apply-templates>
2885     </xsl:when>
2886     <xsl:otherwise>
2887       <m:mrow>
2888         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2889           <xsl:attribute name="xref">
2890             <xsl:value-of select="@id"/>
2891           </xsl:attribute>
2892         </xsl:if>
2893         <xsl:apply-templates select="." mode="intersect">
2894           <xsl:with-param name="IN_OP" select="$INTERSECT_OP"/>
2895           <xsl:with-param name="PARAM" select="$PARAM"/>
2896           <xsl:with-param name="PAREN" select="$PAREN"/>
2897           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2898         </xsl:apply-templates>
2899       </m:mrow>
2900     </xsl:otherwise>
2901   </xsl:choose>
2902 </xsl:template>
2903
2904 <xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
2905   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2906   <xsl:param name="PARAM" select="$NO_PARAM"/>
2907   <xsl:param name="PAREN" select="$PAR_NO"/>
2908   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2909   <xsl:apply-templates select = "*[2]" mode="semantics">
2910     <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
2911     <xsl:with-param name="PARAM" select="$PARAM"/>
2912     <xsl:with-param name="PAREN" select="$PAREN"/>
2913     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2914   </xsl:apply-templates>
2915   <xsl:for-each select = "*[position()>2]">
2916     <m:mo>
2917 <!-- HELM: xref added -->        
2918         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:intersect/@id">
2919           <xsl:attribute name="xref">
2920             <xsl:value-of select="../m:intersect/@id"/>
2921           </xsl:attribute>
2922         </xsl:if>
2923 <!-- HELM: not rendered correctly <![CDATA[&Intersection;]]> -->
2924       <xsl:text disable-output-escaping="yes">&#x22C2;</xsl:text></m:mo>
2925     <xsl:apply-templates select = "." mode="semantics">
2926       <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
2927       <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
2928       <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
2929       <xsl:with-param name="PAREN" select="$PAREN"/>
2930       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
2931     </xsl:apply-templates>
2932   </xsl:for-each>
2933 </xsl:template>
2934
2935 <xsl:template match = "m:apply[m:setdiff[1]]">
2936   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2937   <xsl:param name="PARAM" select="$NO_PARAM"/>
2938   <xsl:param name="PAREN" select="$PAR_NO"/>
2939   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2940   <xsl:choose>
2941     <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC
2942                     and $PARAM=$PAR_SAME">
2943       <m:mfenced separators="">
2944         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2945           <xsl:attribute name="xref">
2946             <xsl:value-of select="@id"/>
2947           </xsl:attribute>
2948         </xsl:if>
2949         <xsl:apply-templates select="." mode="setdiff">
2950           <xsl:with-param name="PARAM" select="$PARAM"/>
2951           <xsl:with-param name="PAREN" select="$PAREN"/>
2952           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2953         </xsl:apply-templates>
2954       </m:mfenced>
2955     </xsl:when>
2956     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2957                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2958                     and not($SEM_SW=$SEM_XREF_EXT)">
2959       <xsl:apply-templates select="." mode="setdiff">
2960         <xsl:with-param name="PARAM" select="$PARAM"/>
2961         <xsl:with-param name="PAREN" select="$PAREN"/>
2962         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2963       </xsl:apply-templates>
2964     </xsl:when>
2965     <xsl:otherwise>
2966       <m:mrow>
2967         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2968           <xsl:attribute name="xref">
2969             <xsl:value-of select="@id"/>
2970           </xsl:attribute>
2971         </xsl:if>
2972         <xsl:apply-templates select="." mode="setdiff">
2973           <xsl:with-param name="PARAM" select="$PARAM"/>
2974           <xsl:with-param name="PAREN" select="$PAREN"/>
2975           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2976         </xsl:apply-templates>
2977       </m:mrow>
2978     </xsl:otherwise>
2979   </xsl:choose>
2980 </xsl:template>
2981
2982 <xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
2983   <xsl:param name="PARAM" select="$NO_PARAM"/>
2984   <xsl:param name="PAREN" select="$PAR_NO"/>
2985   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2986   <xsl:apply-templates select = "*[2]" mode = "semantics">
2987     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
2988     <xsl:with-param name="PARAM" select="$PARAM"/>
2989     <xsl:with-param name="PAREN" select="$PAREN"/>
2990     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2991   </xsl:apply-templates>
2992   <m:mo>
2993 <!-- HELM: xref added -->        
2994         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
2995           <xsl:attribute name="xref">
2996             <xsl:value-of select="m:setdiff/@id"/>
2997           </xsl:attribute>
2998         </xsl:if>\</m:mo>
2999   <xsl:apply-templates select = "*[3]" mode = "semantics">
3000     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
3001     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
3002     <xsl:with-param name="PAREN" select="$PAREN"/>
3003     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3004   </xsl:apply-templates>
3005 </xsl:template>
3006
3007 <xsl:template match = "m:apply[m:cartesianproduct[1]]">
3008   <xsl:param name="IN_PREC" select="$NO_PREC"/>
3009   <xsl:param name="PARAM" select="$NO_PARAM"/>
3010   <xsl:param name="PAREN" select="$PAR_NO"/>
3011   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
3012   <xsl:choose>
3013     <xsl:when test="$IN_PREC &gt; $CARTPROD_PREC or $IN_PREC=$CARTPROD_PREC
3014                     and $PARAM=$PAR_SAME">
3015       <m:mfenced separators="">
3016         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3017           <xsl:attribute name="xref">
3018             <xsl:value-of select="@id"/>
3019           </xsl:attribute>
3020         </xsl:if>
3021         <xsl:apply-templates select="." mode="cartprod">
3022           <xsl:with-param name="PARAM" select="$PARAM"/>
3023           <xsl:with-param name="PAREN" select="$PAREN"/>
3024           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3025         </xsl:apply-templates>
3026       </m:mfenced>
3027     </xsl:when>
3028     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
3029                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
3030                     and not($SEM_SW=$SEM_XREF_EXT)">
3031       <xsl:apply-templates select="." mode="cartprod">
3032         <xsl:with-param name="PARAM" select="$PARAM"/>
3033         <xsl:with-param name="PAREN" select="$PAREN"/>
3034         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3035       </xsl:apply-templates>
3036     </xsl:when>
3037     <xsl:otherwise>
3038       <m:mrow>
3039         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3040           <xsl:attribute name="xref">
3041             <xsl:value-of select="@id"/>
3042           </xsl:attribute>
3043         </xsl:if>
3044         <xsl:apply-templates select="." mode="cartprod">
3045           <xsl:with-param name="PARAM" select="$PARAM"/>
3046           <xsl:with-param name="PAREN" select="$PAREN"/>
3047           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3048         </xsl:apply-templates>
3049       </m:mrow>
3050     </xsl:otherwise>
3051   </xsl:choose>
3052 </xsl:template>
3053
3054 <xsl:template match = "m:apply[m:cartesianproduct[1]]" mode="cartprod">
3055   <xsl:param name="PARAM" select="$NO_PARAM"/>
3056   <xsl:param name="PAREN" select="$PAR_NO"/>
3057   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
3058   <xsl:apply-templates select = "*[2]" mode = "semantics">
3059     <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
3060     <xsl:with-param name="PARAM" select="$PARAM"/>
3061     <xsl:with-param name="PAREN" select="$PAREN"/>
3062     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3063   </xsl:apply-templates>
3064   <xsl:for-each select = "*[position()>2]">
3065     <m:mo>
3066 <!-- HELM: xref added -->        
3067         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:cartesianproduct/@id">
3068           <xsl:attribute name="xref">
3069             <xsl:value-of select="../m:cartesianproduct/@id"/>
3070           </xsl:attribute>
3071         </xsl:if>
3072 <!-- HELM: not rendered correctly <![CDATA[&times;]]> -->
3073      <xsl:text disable-output-escaping="yes">&#x00D7;</xsl:text></m:mo>
3074     <xsl:apply-templates select = "." mode="semantics">
3075       <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
3076       <xsl:with-param name="PARAM" select="$PAR_SAME"/>
3077       <xsl:with-param name="PAREN" select="$PAREN"/>
3078       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3079     </xsl:apply-templates>
3080   </xsl:for-each>
3081 </xsl:template>
3082
3083 <!-- HELM WARNING: card id was lost! -->
3084 <xsl:template match = "m:apply[m:card[1]]">
3085 <!-- HELM: was
3086   <m:mfenced open="|" close="|" separators=",">
3087      Now is: mrow + mo -->
3088   <m:mrow>
3089     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3090       <xsl:attribute name="xref">
3091         <xsl:value-of select="@id"/>
3092       </xsl:attribute>
3093     </xsl:if>
3094     <mo>
3095 <!-- HELM: xref added -->        
3096         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:card/@id">
3097           <xsl:attribute name="xref">
3098             <xsl:value-of select="m:card/@id"/>
3099           </xsl:attribute>
3100         </xsl:if>|</mo>
3101     <xsl:for-each select = "*[position()>1]">
3102       <xsl:apply-templates select = "." mode="semantics"/>
3103     </xsl:for-each>
3104      <mo>
3105 <!-- HELM: xref added -->        
3106         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
3107           <xsl:attribute name="xref">
3108             <xsl:value-of select="m:setdiff/@id"/>
3109           </xsl:attribute>
3110         </xsl:if>|</mo>
3111   </m:mrow>
3112 <!-- HELM:  </m:mfenced> -->
3113 </xsl:template>
3114
3115
3116 <!-- ***************** SEQUENCES AND SERIES ***************** -->
3117
3118 <xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
3119   <m:mrow>
3120     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3121       <xsl:attribute name="xref">
3122         <xsl:value-of select="@id"/>
3123       </xsl:attribute>
3124     </xsl:if>
3125     <xsl:choose>
3126       <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
3127         <m:munderover>
3128           <m:mo>
3129             <xsl:if test="*[1]=m:sum">
3130 <!-- HELM: xref added -->        
3131         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
3132           <xsl:attribute name="xref">
3133             <xsl:value-of select="m:sum/@id"/>
3134           </xsl:attribute>
3135         </xsl:if>
3136              <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
3137             </xsl:if>
3138             <xsl:if test="*[1]=m:product">
3139 <!-- HELM: xref added -->        
3140         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
3141           <xsl:attribute name="xref">
3142             <xsl:value-of select="m:product/@id"/>
3143           </xsl:attribute>
3144         </xsl:if>
3145              <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
3146             </xsl:if>
3147           </m:mo>
3148           <m:mrow>
3149             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3150             <m:mo>=</m:mo>
3151             <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
3152           </m:mrow>
3153           <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
3154         </m:munderover>
3155         <xsl:apply-templates select = "*[5]" mode = "semantics"/>
3156       </xsl:when>
3157       <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
3158         <m:munder>
3159           <m:mo>
3160             <xsl:if test="*[1]=m:sum">
3161              <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
3162             </xsl:if>
3163             <xsl:if test="*[1]=m:product">
3164              <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
3165             </xsl:if>
3166           </m:mo>
3167           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3168         </m:munder>
3169         <xsl:apply-templates select = "*[4]" mode = "semantics"/>
3170       </xsl:when>
3171       <xsl:when test="*[2]=m:domainofapplication">
3172         <m:munder>
3173           <m:mo>
3174             <xsl:if test="*[1]=m:sum">
3175 <!-- HELM: xref added -->        
3176         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
3177           <xsl:attribute name="xref">
3178             <xsl:value-of select="m:sum/@id"/>
3179           </xsl:attribute>
3180         </xsl:if>
3181 <!-- HELM: not rendered correctly <![CDATA[&Sum;]]> -->
3182               <xsl:text disable-output-escaping="yes">&#x2211;</xsl:text>
3183             </xsl:if>
3184             <xsl:if test="*[1]=m:product">
3185 <!-- HELM: xref added -->        
3186         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
3187           <xsl:attribute name="xref">
3188             <xsl:value-of select="m:product/@id"/>
3189           </xsl:attribute>
3190         </xsl:if>
3191 <!-- HELM: not rendered correctly <![CDATA[&Product;]]> -->
3192               <xsl:text disable-output-escaping="yes">&#x220F;</xsl:text>
3193             </xsl:if>
3194           </m:mo>
3195           <xsl:apply-templates select="m:domainofapplication" mode = "semantics"/>
3196         </m:munder>
3197         <m:mrow>
3198           <xsl:apply-templates select="*[position()=last()]" mode = "semantics"/>
3199           </m:mrow>
3200         </xsl:when>
3201       </xsl:choose>
3202     </m:mrow>
3203   </xsl:template>
3204   
3205 <!-- HELM: was (it didn't match with prefixed MathML)
3206 <xsl:template match="m:apply[child::*[position()=1 and name()='int']]">
3207      Now is: -->
3208 <xsl:template match="m:apply[child::*[position()=1 and self::m:int]]">
3209   <m:mrow>
3210     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3211       <xsl:attribute name="xref">
3212         <xsl:value-of select="@id"/>
3213       </xsl:attribute>
3214     </xsl:if>
3215     <xsl:choose>
3216     <xsl:when test="m:condition">
3217       <m:msub>
3218         <m:mo>
3219 <!-- HELM: xref added -->        
3220         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3221           <xsl:attribute name="xref">
3222             <xsl:value-of select="m:int/@id"/>
3223           </xsl:attribute>
3224         </xsl:if>
3225 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3226          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3227         <xsl:apply-templates select="m:condition" mode="semantics"/>
3228       </m:msub>
3229       <m:mrow>
3230         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3231       </m:mrow>
3232       <m:mrow>
3233         <m:mo>d</m:mo>
3234         <xsl:apply-templates select="m:bvar" mode="semantics"/>
3235       </m:mrow>
3236     </xsl:when>
3237     <xsl:when test="m:domainofapplication">
3238       <m:msub>
3239         <m:mo>
3240 <!-- HELM: xref added -->        
3241         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3242           <xsl:attribute name="xref">
3243             <xsl:value-of select="m:int/@id"/>
3244           </xsl:attribute>
3245         </xsl:if>
3246 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3247          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3248         <xsl:apply-templates select="m:domainofapplication" mode="semantics"/>
3249       </m:msub>
3250       <m:mrow>
3251         <xsl:apply-templates select="*[position()=last()]" mode="semantics" />
3252       </m:mrow>
3253     </xsl:when>
3254     <xsl:otherwise>
3255       <xsl:choose>
3256         <xsl:when test="m:interval">
3257           <m:msubsup>
3258             <m:mo>
3259 <!-- HELM: xref added -->        
3260         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3261           <xsl:attribute name="xref">
3262             <xsl:value-of select="m:int/@id"/>
3263           </xsl:attribute>
3264         </xsl:if>
3265 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3266              <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3267             <xsl:apply-templates select="m:interval/*[position()=1]" mode="semantics" />
3268             <xsl:apply-templates select="m:interval/*[position()=2]" mode="semantics"/>
3269           </m:msubsup>
3270           <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3271           <m:mo>d</m:mo>
3272           <xsl:apply-templates select="m:bvar" mode="semantics"/>
3273         </xsl:when>
3274         <xsl:when test="m:lowlimit">
3275         <m:msubsup>
3276           <m:mo>
3277 <!-- HELM: xref added -->        
3278         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3279           <xsl:attribute name="xref">
3280             <xsl:value-of select="m:int/@id"/>
3281           </xsl:attribute>
3282         </xsl:if>
3283 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3284            <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3285           <m:mrow><xsl:apply-templates select="m:lowlimit" mode="semantics"/></m:mrow>
3286           <m:mrow><xsl:apply-templates select="m:uplimit" mode="semantics"/></m:mrow>
3287         </m:msubsup>
3288         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3289         <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
3290       </xsl:when>
3291       <xsl:otherwise>
3292         <m:mo>
3293 <!-- HELM: xref added -->        
3294         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3295           <xsl:attribute name="xref">
3296             <xsl:value-of select="m:int/@id"/>
3297           </xsl:attribute>
3298         </xsl:if>
3299 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3300          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3301         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3302         <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
3303       </xsl:otherwise>
3304       </xsl:choose>
3305     </xsl:otherwise>
3306     </xsl:choose>
3307   </m:mrow>
3308 </xsl:template>
3309
3310 <xsl:template match = "m:apply[m:limit[1]]">
3311   <m:mrow>
3312     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3313       <xsl:attribute name="xref">
3314         <xsl:value-of select="@id"/>
3315       </xsl:attribute>
3316     </xsl:if>
3317     <m:munder>
3318       <m:mo>
3319 <!-- HELM: xref added -->        
3320         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lim/@id">
3321           <xsl:attribute name="xref">
3322             <xsl:value-of select="m:lim/@id"/>
3323           </xsl:attribute>
3324         </xsl:if>lim</m:mo>
3325       <m:mrow>
3326         <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
3327             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3328             <m:mo><xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text></m:mo>
3329             <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3330         </xsl:if>
3331         <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
3332           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3333         </xsl:if>
3334       </m:mrow>
3335     </m:munder>
3336     <xsl:apply-templates select = "*[4]" mode = "semantics"/>
3337   </m:mrow>
3338 </xsl:template>
3339
3340
3341 <!-- ***************** TRIGONOMETRY ***************** -->
3342
3343 <xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos |
3344                        self::m:tan | self::m:sec | self::m:csc |
3345                        self::m:cot | self::m:sinh | self::m:cosh |
3346                        self::m:tanh | self::m:sech | self::m:csch |
3347                        self::m:coth | self::m:arcsin | self::m:arccos |
3348                        self::m:arctan | self::m:arcsec | self::m:arccsc | 
3349                        self::m:arccot | self::m:arcsinh | self::m:arccosh |
3350                        self::m:arctanh | self::m:arcsech | self::m:arccsch |
3351                        self::m:arccoth ] ]">
3352                         
3353   <m:mrow>
3354     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3355       <xsl:attribute name="xref">
3356         <xsl:value-of select="@id"/>
3357       </xsl:attribute>
3358     </xsl:if>
3359     <xsl:if test="not(parent::m:apply[m:power[1]])">
3360       <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
3361     </xsl:if>
3362     <xsl:if test="parent::m:apply[m:power[1]]">
3363       <m:msup>
3364         <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
3365         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
3366       </m:msup>
3367     </xsl:if>
3368     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
3369     <xsl:apply-templates select = "*[2]" mode = "semantics">
3370       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
3371       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3372     </xsl:apply-templates>
3373   </m:mrow>
3374 </xsl:template>
3375
3376 <xsl:template match = "*" mode="trigonometry">
3377   <m:mo>
3378     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3379       <xsl:attribute name="xref">
3380         <xsl:value-of select="@id"/>
3381       </xsl:attribute>
3382     </xsl:if>
3383     <xsl:choose>
3384       <xsl:when test="self::m:sin">
3385         <xsl:value-of select="'sin'"/>
3386       </xsl:when>
3387       <xsl:when test="self::m:cos">
3388         <xsl:value-of select="'cos'"/>
3389       </xsl:when>
3390       <xsl:when test="self::m:tan">
3391         <xsl:value-of select="'tan'"/>
3392       </xsl:when>
3393       <xsl:when test="self::m:sec">
3394         <xsl:value-of select="'sec'"/>
3395       </xsl:when>
3396       <xsl:when test="self::m:csc">
3397         <xsl:value-of select="'csc'"/>
3398       </xsl:when>
3399       <xsl:when test="self::m:cot">
3400         <xsl:value-of select="'cot'"/>
3401       </xsl:when>
3402       <xsl:when test="self::m:sinh">
3403         <xsl:value-of select="'sinh'"/>
3404       </xsl:when>
3405       <xsl:when test="self::m:cosh">
3406         <xsl:value-of select="'cosh'"/>
3407       </xsl:when>
3408       <xsl:when test="self::m:tanh">
3409         <xsl:value-of select="'tanh'"/>
3410       </xsl:when>
3411       <xsl:when test="self::m:sech">
3412         <xsl:value-of select="'sech'"/>
3413       </xsl:when>
3414       <xsl:when test="self::m:csch">
3415         <xsl:value-of select="'csch'"/>
3416       </xsl:when>
3417       <xsl:when test="self::m:coth">
3418         <xsl:value-of select="'coth'"/>
3419       </xsl:when>
3420       <xsl:when test="self::m:arcsin">
3421         <xsl:value-of select="'arcsin'"/>
3422       </xsl:when>
3423       <xsl:when test="self::m:arccos">
3424         <xsl:value-of select="'arccos'"/>
3425       </xsl:when>
3426       <xsl:when test="self::m:arctan">
3427         <xsl:value-of select="'arctan'"/>
3428       </xsl:when>
3429       <xsl:when test="self::m:arcsec">
3430         <xsl:value-of select="'arcsec'"/>
3431       </xsl:when>
3432       <xsl:when test="self::m:arccsc">
3433         <xsl:value-of select="'arccsc'"/>
3434       </xsl:when>
3435       <xsl:when test="self::m:arccot">
3436         <xsl:value-of select="'arccot'"/>
3437       </xsl:when>
3438       <xsl:when test="self::m:arcsinh">
3439         <xsl:value-of select="'arcsinh'"/>
3440       </xsl:when>
3441       <xsl:when test="self::m:arccosh">
3442         <xsl:value-of select="'arccosh'"/>
3443       </xsl:when>
3444       <xsl:when test="self::m:arctanh">
3445         <xsl:value-of select="'arctanh'"/>
3446       </xsl:when>
3447       <xsl:when test="self::m:arcsech">
3448         <xsl:value-of select="'arcsech'"/>
3449       </xsl:when>
3450       <xsl:when test="self::m:arccsch">
3451         <xsl:value-of select="'arccsch'"/>
3452       </xsl:when>
3453       <xsl:when test="self::m:arccoth">
3454         <xsl:value-of select="'arccot'"/>
3455       </xsl:when>
3456     </xsl:choose>
3457   </m:mo>
3458 </xsl:template>
3459
3460
3461 <!-- ***************** STATISTICS ***************** -->
3462
3463 <!-- HELM WARNING: mean id was lost! -->
3464 <xsl:template match = "m:apply[m:mean[1]]">
3465 <!-- HELM: was
3466   <m:mfenced open="&lt;" close="&gt;" separators=",">
3467      Now is: mrow + mo + separator (mo) -->
3468   <m:mrow>
3469     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3470       <xsl:attribute name="xref">
3471         <xsl:value-of select="@id"/>
3472       </xsl:attribute>
3473     </xsl:if>
3474     <m:mo>
3475 <!-- HELM: xref added -->        
3476         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3477           <xsl:attribute name="xref">
3478             <xsl:value-of select="m:mean/@id"/>
3479           </xsl:attribute>
3480         </xsl:if>&#x003C;</m:mo>
3481     <xsl:for-each select = "*[position()>1]">
3482 <!-- HELM: if added -->
3483       <xsl:if test="position() != 1">
3484        <m:mo separator="true">,</m:mo>
3485       </xsl:if> 
3486       <xsl:apply-templates select = "." mode="semantics"/>
3487     </xsl:for-each>
3488     <m:mo>
3489 <!-- HELM: xref added -->        
3490         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3491           <xsl:attribute name="xref">
3492             <xsl:value-of select="m:mean/@id"/>
3493           </xsl:attribute>
3494         </xsl:if>&#x003E;</m:mo>
3495    </m:mrow>
3496 <!-- HELM:  </m:mfenced> -->
3497 </xsl:template>
3498
3499 <xsl:template match = "m:apply[m:sdev[1]]">
3500   <m:mrow>
3501     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3502       <xsl:attribute name="xref">
3503         <xsl:value-of select="@id"/>
3504       </xsl:attribute>
3505     </xsl:if>
3506     <m:mo>
3507 <!-- HELM: xref added -->        
3508         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sdev/@id">
3509           <xsl:attribute name="xref">
3510             <xsl:value-of select="m:sdev/@id"/>
3511           </xsl:attribute>
3512         </xsl:if>
3513      <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
3514     <m:mfenced separators=",">
3515       <xsl:for-each select = "*[position()>1]">
3516         <xsl:apply-templates select = "." mode="semantics"/>
3517       </xsl:for-each>
3518     </m:mfenced>
3519   </m:mrow>
3520 </xsl:template>
3521
3522 <xsl:template match = "m:apply[m:variance[1]]">
3523   <m:mrow>
3524     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3525       <xsl:attribute name="xref">
3526         <xsl:value-of select="@id"/>
3527       </xsl:attribute>
3528     </xsl:if>
3529     <m:mo>
3530 <!-- HELM: xref added -->        
3531         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:variance/@id">
3532           <xsl:attribute name="xref">
3533             <xsl:value-of select="m:variance/@id"/>
3534           </xsl:attribute>
3535         </xsl:if>
3536      <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
3537     <m:msup>
3538       <m:mfenced separators=",">
3539         <xsl:for-each select = "*[position()>1]">
3540           <xsl:apply-templates select = "." mode="semantics"/>
3541         </xsl:for-each>
3542       </m:mfenced>
3543       <m:mn>2</m:mn>
3544     </m:msup>
3545   </m:mrow>
3546 </xsl:template>
3547
3548 <xsl:template match = "m:apply[m:median[1]]">
3549   <m:mrow>
3550     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3551       <xsl:attribute name="xref">
3552         <xsl:value-of select="@id"/>
3553       </xsl:attribute>
3554     </xsl:if>
3555     <m:mo>
3556 <!-- HELM: xref added -->        
3557         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:median/@id">
3558           <xsl:attribute name="xref">
3559             <xsl:value-of select="m:median/@id"/>
3560           </xsl:attribute>
3561         </xsl:if>median</m:mo>
3562     <m:mfenced separators=",">
3563       <xsl:for-each select = "*[position()>1]">
3564         <xsl:apply-templates select = "." mode="semantics"/>
3565       </xsl:for-each>
3566     </m:mfenced>
3567   </m:mrow>
3568 </xsl:template>
3569
3570 <xsl:template match = "m:apply[m:mode[1]]">
3571   <m:mrow>
3572     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3573       <xsl:attribute name="xref">
3574         <xsl:value-of select="@id"/>
3575       </xsl:attribute>
3576     </xsl:if>
3577     <m:mo>
3578 <!-- HELM: xref added -->        
3579         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mode/@id">
3580           <xsl:attribute name="xref">
3581             <xsl:value-of select="m:mode/@id"/>
3582           </xsl:attribute>
3583         </xsl:if>mode</m:mo>
3584     <m:mfenced separators=",">
3585       <xsl:for-each select = "*[position()>1]">
3586         <xsl:apply-templates select = "." mode="semantics"/>
3587       </xsl:for-each>
3588     </m:mfenced>
3589   </m:mrow>
3590 </xsl:template>
3591
3592 <!-- HELM WARNING: mean id was lost! -->
3593 <xsl:template match = "m:apply[m:moment[1]]">
3594 <!-- HELM: was
3595   <m:mfenced open="&lt;" close="&gt;" separators="">
3596      Now is: mrow + mo -->
3597   <m:mrow>
3598     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3599       <xsl:attribute name="xref">
3600         <xsl:value-of select="@id"/>
3601       </xsl:attribute>
3602     </xsl:if>
3603     <m:mo>
3604 <!-- HELM: xref added -->        
3605         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:moment/@id">
3606           <xsl:attribute name="xref">
3607             <xsl:value-of select="m:momemt/@id"/>
3608           </xsl:attribute>
3609         </xsl:if>&#x003C;</m:mo>
3610     <xsl:if test="*[2]=m:degree and not(*[3]=m:momentabout)">
3611       <m:msup>
3612         <xsl:apply-templates select="*[3]" mode = "semantics"/>
3613           <xsl:apply-templates select="*[2]" mode = "semantics"/>
3614           </m:msup>
3615         </xsl:if>
3616         <xsl:if test="*[2]=m:degree and *[3]=m:momentabout">
3617           <m:msup>
3618             <xsl:apply-templates select="*[4]" mode = "semantics"/>
3619             <xsl:apply-templates select="*[2]" mode = "semantics"/>
3620       </m:msup>  
3621     </xsl:if>
3622     <xsl:if test="not(*[2]=m:degree) and *[2]=m:momentabout">
3623        <xsl:for-each select = "*[position()>2]">
3624         <xsl:apply-templates select = "." mode="semantics"/>
3625       </xsl:for-each>
3626     </xsl:if>
3627     <xsl:if test="not(*[2]=m:degree) and not(*[2]=m:momentabout)">
3628       <xsl:for-each select = "*[position()>1]">
3629         <xsl:apply-templates select = "." mode="semantics"/>
3630       </xsl:for-each>
3631     </xsl:if>
3632     <m:mo>
3633 <!-- HELM: xref added -->        
3634         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3635           <xsl:attribute name="xref">
3636             <xsl:value-of select="m:mean/@id"/>
3637           </xsl:attribute>
3638         </xsl:if>&#x003E;</m:mo>
3639   </m:mrow>
3640 <!-- HELM:  </m:mfenced> -->
3641 </xsl:template>
3642
3643
3644 <!-- ***************** LINEAR ALGEBRA ***************** -->
3645
3646 <xsl:template match="m:vector">
3647   <m:mfenced separators="">
3648     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3649       <xsl:attribute name="xref">
3650         <xsl:value-of select="@id"/>
3651       </xsl:attribute>
3652     </xsl:if>
3653     <m:mtable>
3654       <xsl:for-each select="*">
3655         <m:mtd>
3656           <xsl:apply-templates select="." mode = "semantics"/>
3657         </m:mtd>
3658       </xsl:for-each>
3659     </m:mtable>
3660   </m:mfenced>
3661 </xsl:template>
3662
3663 <xsl:template match = "m:matrix">
3664   <m:mfenced separators="">
3665     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3666       <xsl:attribute name="xref">
3667         <xsl:value-of select="@id"/>
3668       </xsl:attribute>
3669     </xsl:if>
3670     <m:mtable>
3671       <xsl:apply-templates select="*" mode = "semantics"/>
3672     </m:mtable>
3673   </m:mfenced>
3674 </xsl:template>
3675
3676 <xsl:template match = "m:matrixrow">
3677   <m:mtr>
3678     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3679       <xsl:attribute name="xref">
3680         <xsl:value-of select="@id"/>
3681       </xsl:attribute>
3682     </xsl:if>
3683     <xsl:for-each select="*">
3684       <m:mtd>
3685         <xsl:apply-templates select="." mode = "semantics"/>
3686       </m:mtd>
3687     </xsl:for-each>
3688   </m:mtr>
3689 </xsl:template>
3690
3691 <xsl:template match = "m:apply[m:determinant[1]]">
3692   <m:mrow>
3693     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3694       <xsl:attribute name="xref">
3695         <xsl:value-of select="@id"/>
3696       </xsl:attribute>
3697     </xsl:if>
3698     <m:mo>
3699 <!-- HELM: xref added -->        
3700         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:determinant/@id">
3701           <xsl:attribute name="xref">
3702             <xsl:value-of select="m:determinant/@id"/>
3703           </xsl:attribute>
3704         </xsl:if>det</m:mo>
3705     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3706   </m:mrow>
3707 </xsl:template>
3708
3709 <xsl:template match = "m:apply[m:transpose[1]]">
3710   <m:msup>
3711     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3712       <xsl:attribute name="xref">
3713         <xsl:value-of select="@id"/>
3714       </xsl:attribute>
3715     </xsl:if>
3716     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3717     <m:mo>
3718 <!-- HELM: xref added -->        
3719         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:transpose/@id">
3720           <xsl:attribute name="xref">
3721             <xsl:value-of select="m:transpose/@id"/>
3722           </xsl:attribute>
3723         </xsl:if>T</m:mo>
3724   </m:msup>
3725 </xsl:template>
3726
3727 <!-- HELM: ERROR, this template generates the selected content elements
3728      and doesn't generate the presentation for selector                 -->
3729 <!--<xsl:template match = "m:apply[m:selector[1]]">
3730   <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
3731       <xsl:variable name="m" select = "*[3]"/>
3732       <xsl:choose>
3733         <xsl:when test="*[4]=m:cn">
3734           <xsl:variable name="n" select = "*[4]"/>
3735           <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
3736         </xsl:when>
3737         <xsl:otherwise>
3738           <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
3739         </xsl:otherwise>
3740       </xsl:choose>
3741   </xsl:if>
3742   <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
3743     <xsl:variable name="m" select = "*[3]"/>
3744     <xsl:copy-of select = "*[2]/*[position()=$m]"/>
3745   </xsl:if>
3746 </xsl:template> -->
3747
3748 <xsl:template match = "m:apply[m:selector[1]]">
3749    <msub>
3750     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3751      <xsl:attribute name="xref">
3752       <xsl:value-of select="@id"/>
3753      </xsl:attribute>
3754     </xsl:if> 
3755     <xsl:apply-templates select = "*[2]" mode="semantics"/>
3756     <m:mrow>
3757      <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:selector/@id">
3758       <xsl:attribute name="xref">
3759        <xsl:value-of select="m:selector/@id"/>
3760       </xsl:attribute>
3761      </xsl:if>
3762      <xsl:choose>
3763      <xsl:when test="*[3]=m:cn">
3764       <xsl:apply-templates select = "*[3]" mode="semantics"/>
3765      </xsl:when>
3766      <xsl:otherwise>
3767       <m:mi>*</m:mi>
3768      </xsl:otherwise>
3769      </xsl:choose> 
3770      <xsl:if test="*[2]=m:matrix and *[4]=m:cn">
3771       <xsl:apply-templates select = "*[4]" mode="semantics"/>
3772      </xsl:if>
3773     </m:mrow>
3774    </msub>
3775 </xsl:template>
3776
3777 <xsl:template match = "m:apply[m:vectorproduct[1] |
3778                                  m:scalarproduct[1] | m:outerproduct[1]]">
3779   <m:mrow>
3780     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3781       <xsl:attribute name="xref">
3782         <xsl:value-of select="@id"/>
3783       </xsl:attribute>
3784     </xsl:if>
3785     <xsl:apply-templates select="*[2]" mode = "semantics"/>
3786     <m:mo>
3787       <xsl:if test="m:vectorproduct[1]">
3788 <!-- HELM: xref added -->        
3789         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:vectorproduct/@id">
3790           <xsl:attribute name="xref">
3791             <xsl:value-of select="m:vectorproduct/@id"/>
3792           </xsl:attribute>
3793         </xsl:if>
3794        <xsl:text disable-output-escaping='yes'>&#x2A2F;</xsl:text>
3795       </xsl:if>
3796       <xsl:if test="m:scalarproduct[1] | m:outerproduct[1]">
3797 <!-- HELM: xref added -->        
3798         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and *[1]/@id">
3799           <xsl:attribute name="xref">
3800             <xsl:value-of select="*[1]/@id"/>
3801           </xsl:attribute>
3802         </xsl:if>           
3803         <xsl:value-of select="'.'"/>
3804       </xsl:if>
3805     </m:mo>
3806     <xsl:apply-templates select="*[3]" mode = "semantics"/>
3807   </m:mrow>
3808 </xsl:template>
3809
3810
3811 <!-- ***************** CONSTANT and SYMBOL ELEMENTS ***************** -->
3812
3813 <xsl:template match="m:integers">
3814    <m:mi>
3815 <!-- HELM: xref added -->        
3816         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:integers/@id">
3817           <xsl:attribute name="xref">
3818             <xsl:value-of select="m:integers/@id"/>
3819           </xsl:attribute>
3820         </xsl:if>
3821     <xsl:text disable-output-escaping='yes'>&#x2124;</xsl:text></m:mi>
3822 </xsl:template>
3823
3824 <xsl:template match="m:reals">
3825    <m:mi>
3826 <!-- HELM: xref added -->        
3827         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:reals/@id">
3828           <xsl:attribute name="xref">
3829             <xsl:value-of select="m:reals/@id"/>
3830           </xsl:attribute>
3831         </xsl:if>
3832     <xsl:text disable-output-escaping='yes'>&#x211D;</xsl:text></m:mi>
3833 </xsl:template>
3834
3835 <xsl:template match="m:rationals">
3836   <m:mi>
3837 <!-- HELM: xref added -->        
3838         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rationals/@id">
3839           <xsl:attribute name="xref">
3840             <xsl:value-of select="m:rationals/@id"/>
3841           </xsl:attribute>
3842         </xsl:if>
3843    <xsl:text disable-output-escaping='yes'>&#x211A;</xsl:text></m:mi>
3844 </xsl:template>
3845
3846 <xsl:template match="m:naturalnumbers">
3847   <m:mi>
3848 <!-- HELM: xref added -->        
3849         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:naturalnumbers/@id">
3850           <xsl:attribute name="xref">
3851             <xsl:value-of select="m:naturalnumbers/@id"/>
3852           </xsl:attribute>
3853         </xsl:if>
3854    <xsl:text disable-output-escaping='yes'>&#x2115;</xsl:text></m:mi> 
3855 </xsl:template>
3856
3857 <xsl:template match="m:complexes">
3858   <m:mi>
3859 <!-- HELM: xref added -->        
3860         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:complexes/@id">
3861           <xsl:attribute name="xref">
3862             <xsl:value-of select="m:complexes/@id"/>
3863           </xsl:attribute>
3864         </xsl:if>
3865    <xsl:text disable-output-escaping='yes'>&#x2102;</xsl:text></m:mi>
3866 </xsl:template>
3867
3868 <xsl:template match="m:primes">
3869   <m:mi>
3870 <!-- HELM: xref added -->        
3871         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:primes/@id">
3872           <xsl:attribute name="xref">
3873             <xsl:value-of select="m:primes/@id"/>
3874           </xsl:attribute>
3875         </xsl:if>
3876    <xsl:text disable-output-escaping='yes'>&#x2119;</xsl:text></m:mi>
3877 </xsl:template>
3878
3879 <xsl:template match="m:exponentiale">
3880   <m:mi>
3881 <!-- HELM: xref added -->        
3882         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exponentiale/@id">
3883           <xsl:attribute name="xref">
3884             <xsl:value-of select="m:exponentiale/@id"/>
3885           </xsl:attribute>
3886         </xsl:if>
3887    <xsl:text disable-output-escaping="yes">&#x2147;</xsl:text></m:mi>
3888 </xsl:template>
3889
3890 <xsl:template match="m:imaginaryi">
3891   <m:mi>
3892 <!-- HELM: xref added -->        
3893         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginaryi/@id">
3894           <xsl:attribute name="xref">
3895             <xsl:value-of select="m:imaginaryi/@id"/>
3896           </xsl:attribute>
3897         </xsl:if>
3898 <!-- HELM: not rendered correctly <![CDATA[&ImaginaryI;]]> -->
3899    <xsl:text disable-output-escaping="yes">&#xF74E;</xsl:text></m:mi>
3900 </xsl:template>
3901
3902 <xsl:template match="m:notanumber">
3903   <m:mi>
3904 <!-- HELM: xref added -->        
3905         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notanumber/@id">
3906           <xsl:attribute name="xref">
3907             <xsl:value-of select="m:notanumber/@id"/>
3908           </xsl:attribute>
3909         </xsl:if>NaN</m:mi>  
3910 </xsl:template>
3911
3912 <xsl:template match="m:true">
3913   <m:mi>
3914 <!-- HELM: xref added -->        
3915         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:true/@id">
3916           <xsl:attribute name="xref">
3917             <xsl:value-of select="m:true/@id"/>
3918           </xsl:attribute>
3919         </xsl:if>true</m:mi>  
3920 </xsl:template>
3921
3922 <xsl:template match="m:false">
3923   <m:mi>
3924 <!-- HELM: xref added -->        
3925         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:false/@id">
3926           <xsl:attribute name="xref">
3927             <xsl:value-of select="m:false/@id"/>
3928           </xsl:attribute>
3929         </xsl:if>false</m:mi>   
3930 </xsl:template>
3931
3932 <xsl:template match="m:emptyset">
3933   <m:mi>
3934 <!-- HELM: xref added -->        
3935         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:emptyset/@id">
3936           <xsl:attribute name="xref">
3937             <xsl:value-of select="m:emptyset/@id"/>
3938           </xsl:attribute>
3939         </xsl:if>
3940 <!-- HELM: not rendered correctly <![CDATA[&empty;]]> -->
3941    <xsl:text disable-output-escaping="yes">&#xE2D3;</xsl:text></m:mi>
3942 </xsl:template>
3943
3944 <xsl:template match="m:pi">
3945   <m:mi>
3946 <!-- HELM: xref added -->        
3947         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:pi/@id">
3948           <xsl:attribute name="xref">
3949             <xsl:value-of select="m:pi/@id"/>
3950           </xsl:attribute>
3951         </xsl:if>
3952 <!-- HELM: not rendered correctly <![CDATA[&pi;]]> -->
3953    <xsl:text disable-output-escaping="yes">&#x03C0;</xsl:text></m:mi>
3954 </xsl:template>
3955
3956 <xsl:template match="m:eulergamma">
3957   <m:mi>
3958 <!-- HELM: xref added -->        
3959         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:eulergamma/@id">
3960           <xsl:attribute name="xref">
3961             <xsl:value-of select="m:eulergamma/@id"/>
3962           </xsl:attribute>
3963         </xsl:if>
3964 <!-- HELM: not rendered correctly <![CDATA[&gamma;]]> -->
3965    <xsl:text disable-output-escaping="yes">&#x03B3;</xsl:text></m:mi>
3966 </xsl:template>
3967
3968 <xsl:template match="m:infinity">
3969   <m:mi>
3970 <!-- HELM: xref added -->        
3971         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:infinity/@id">
3972           <xsl:attribute name="xref">
3973             <xsl:value-of select="m:infinity/@id"/>
3974           </xsl:attribute>
3975         </xsl:if>
3976 <!-- HELM: not rendered correctly <![CDATA[&infin;]]> -->
3977    <xsl:text disable-output-escaping="yes">&#x221E;</xsl:text></m:mi>
3978 </xsl:template>
3979
3980 </xsl:stylesheet>
3981
3982