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