]> matita.cs.unibo.it Git - helm.git/blob - helm/style/mmlctop2_0.xsl
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / style / mmlctop2_0.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       <m:mfenced separators="">
1297         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1298           <xsl:attribute name="xref">
1299             <xsl:value-of select="@id"/>
1300           </xsl:attribute>
1301         </xsl:if>
1302         <xsl:apply-templates select="." mode="minus">
1303           <xsl:with-param name="PARAM" select="$PARAM"/>
1304           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1305           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1306         </xsl:apply-templates>
1307       </m:mfenced>
1308     </xsl:when>
1309     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1310                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1311                     and not($SEM_SW=$SEM_XREF_EXT)">
1312       <xsl:apply-templates select="." mode="minus">
1313         <xsl:with-param name="PARAM" select="$PARAM"/>
1314         <xsl:with-param name="PAREN" select="$PAREN"/>
1315         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1316       </xsl:apply-templates>
1317     </xsl:when>
1318     <xsl:otherwise>
1319       <m:mrow>
1320         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1321           <xsl:attribute name="xref">
1322             <xsl:value-of select="@id"/>
1323           </xsl:attribute>
1324         </xsl:if>
1325         <xsl:apply-templates select="." mode="minus">
1326           <xsl:with-param name="PARAM" select="$PARAM"/>
1327           <xsl:with-param name="PAREN" select="$PAREN"/>
1328           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1329         </xsl:apply-templates>
1330       </m:mrow>
1331     </xsl:otherwise>
1332   </xsl:choose>
1333 </xsl:template>
1334
1335 <xsl:template match = "m:apply[m:minus[1]]" mode="minus">
1336   <xsl:param name="PARAM" select="$NO_PARAM"/>
1337   <xsl:param name="PAREN" select="$PAR_NO"/>
1338   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1339   <xsl:if test="not(*[3])">
1340     <m:mo>
1341 <!-- HELM: xref added -->        
1342         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
1343           <xsl:attribute name="xref">
1344             <xsl:value-of select="m:minus/@id"/>
1345           </xsl:attribute>
1346         </xsl:if>-</m:mo>
1347     <xsl:apply-templates select="*[2]" mode = "semantics">
1348       <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
1349       <xsl:with-param name="PAREN" select="$PAREN"/>
1350       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1351     </xsl:apply-templates>
1352   </xsl:if>
1353   <xsl:if test="*[3]">
1354     <xsl:apply-templates select="*[2]" mode = "semantics">
1355       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
1356       <xsl:with-param name="PARAM" select="$PARAM"/>
1357       <xsl:with-param name="PAREN" select="$PAREN"/>
1358       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1359     </xsl:apply-templates>
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="*[3]" mode = "semantics">
1368       <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
1369       <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1370       <xsl:with-param name="PAREN" select="$PAREN"/>
1371       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1372     </xsl:apply-templates>
1373   </xsl:if>
1374 </xsl:template>
1375
1376 <xsl:template match = "m:apply[m:plus[1]]">
1377   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1378   <xsl:param name="PARAM" select="$NO_PARAM"/>
1379   <xsl:param name="PAREN" select="$PAR_NO"/>
1380   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1381   <xsl:choose>
1382     <xsl:when test="$IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and
1383                                                       $PARAM=$PAR_SAME">
1384       <m:mfenced separators="">
1385         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1386           <xsl:attribute name="xref">
1387             <xsl:value-of select="@id"/>
1388           </xsl:attribute>
1389         </xsl:if>
1390         <xsl:apply-templates select="." mode="plus">
1391           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1392           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1393           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1394         </xsl:apply-templates>
1395       </m:mfenced>
1396     </xsl:when>
1397     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1398                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1399                     and not($SEM_SW=$SEM_XREF_EXT)">
1400       <xsl:apply-templates select="." mode="plus">
1401         <xsl:with-param name="PARAM" select="$PARAM"/>
1402         <xsl:with-param name="PAREN" select="$PAREN"/>
1403         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1404       </xsl:apply-templates>
1405     </xsl:when>
1406     <xsl:otherwise>
1407       <m:mrow>
1408         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1409           <xsl:attribute name="xref">
1410             <xsl:value-of select="@id"/>
1411           </xsl:attribute>
1412         </xsl:if>
1413         <xsl:apply-templates select="." mode="plus">
1414           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1415           <xsl:with-param name="PAREN" select="$PAREN"/>
1416           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1417         </xsl:apply-templates>
1418       </m:mrow>
1419     </xsl:otherwise>
1420   </xsl:choose>
1421 </xsl:template>
1422
1423 <xsl:template match = "m:apply[m:plus[1]]" mode="plus">
1424   <xsl:param name="PARAM" select="$NO_PARAM"/>
1425   <xsl:param name="PAREN" select="$PAR_NO"/>
1426   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1427   <xsl:if test="*[2]">
1428     <xsl:apply-templates select="*[2]" mode = "semantics">
1429       <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1430       <xsl:with-param name="PARAM" select="$PARAM"/>
1431       <xsl:with-param name="PAREN" select="$PAREN"/>
1432       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1433     </xsl:apply-templates>
1434     <xsl:for-each select = "*[position()>2]">
1435       <xsl:choose>
1436         <xsl:when test=". &lt; 0">
1437           <m:mo>-</m:mo>
1438           <m:mn> <xsl:value-of select="-."/> </m:mn>
1439         </xsl:when>
1440         <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
1441           <xsl:apply-templates select="." mode = "semantics">
1442             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1443             <xsl:with-param name="PAREN" select="$PAREN"/>
1444             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1445           </xsl:apply-templates>
1446         </xsl:when>
1447         <xsl:otherwise>
1448           <m:mo>
1449 <!-- HELM: xref added -->        
1450         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:plus/@id">
1451           <xsl:attribute name="xref">
1452             <xsl:value-of select="../m:plus/@id"/>
1453           </xsl:attribute>
1454         </xsl:if>+</m:mo>
1455           <xsl:apply-templates select="." mode = "semantics">
1456             <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
1457             <xsl:with-param name="PAREN" select="$PAREN"/>
1458             <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1459           </xsl:apply-templates>
1460         </xsl:otherwise>
1461       </xsl:choose>
1462     </xsl:for-each>
1463   </xsl:if>
1464 </xsl:template>
1465
1466 <!-- HELM WARNING: power id is lost!                              -->
1467 <!-- msup should maintain the power definitionURL info but also the 
1468      reference to apply                                           -->
1469 <xsl:template match = "m:apply[m:power[1]]">
1470   <xsl:choose>
1471     <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] |
1472                          m:gcd[1] | m:lcm[1] | m:sin[1] | m:cos[1] | m:tan[1] |
1473                          m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] |
1474                          m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] |
1475                          m:coth[1] | m:arcsin[1] | m:arccos[1] |
1476                          m:arctan[1] | m:arcsec[1] | m:arccsc[1] | 
1477                          m:arccot[1] | m:arcsinh[1] | m:arccosh[1] |
1478                          m:arctanh[1] | m:arcsech[1] | m:arccsch [1]|
1479                          m:arccoth[1] ]">
1480       <xsl:apply-templates select="*[2]" mode = "semantics"/>
1481     </xsl:when>
1482     <xsl:otherwise>
1483       <m:msup>
1484         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1485           <xsl:attribute name="xref">
1486             <xsl:value-of select="@id"/>
1487           </xsl:attribute>
1488         </xsl:if>
1489         <xsl:apply-templates select = "*[2]" mode = "semantics">
1490           <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1491           <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1492         </xsl:apply-templates>
1493         <xsl:apply-templates select = "*[3]" mode = "semantics"/>
1494       </m:msup>
1495     </xsl:otherwise>
1496   </xsl:choose>
1497 </xsl:template>
1498
1499 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
1500   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1501   <xsl:param name="PARAM" select="$NO_PARAM"/>
1502   <xsl:param name="PAREN" select="$PAR_NO"/>
1503   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1504   <xsl:choose>
1505     <xsl:when test="$IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and
1506                                                     $PARAM=$PAR_SAME">
1507       <m:mfenced separators="">
1508         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1509           <xsl:attribute name="xref">
1510             <xsl:value-of select="@id"/>
1511           </xsl:attribute>
1512         </xsl:if>
1513         <xsl:apply-templates select="." mode="remdiv">
1514           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1515           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1516           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1517         </xsl:apply-templates>
1518       </m:mfenced>
1519     </xsl:when>
1520     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1521                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1522                     and not($SEM_SW=$SEM_XREF_EXT)">
1523       <xsl:apply-templates select="." mode="remdiv">
1524         <xsl:with-param name="PARAM" select="$PARAM"/>
1525         <xsl:with-param name="PAREN" select="$PAREN"/>
1526         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1527       </xsl:apply-templates>
1528     </xsl:when>
1529     <xsl:otherwise>
1530       <m:mrow>
1531         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1532           <xsl:attribute name="xref">
1533             <xsl:value-of select="@id"/>
1534           </xsl:attribute>
1535         </xsl:if>
1536         <xsl:apply-templates select="." mode="remdiv">
1537           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1538           <xsl:with-param name="PAREN" select="$PAREN"/>
1539           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1540         </xsl:apply-templates>
1541       </m:mrow>
1542     </xsl:otherwise>
1543   </xsl:choose>
1544 </xsl:template>
1545
1546 <xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
1547   <xsl:param name="PARAM" select="$NO_PARAM"/>
1548   <xsl:param name="PAREN" select="$PAR_NO"/>
1549   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1550   <xsl:apply-templates select = "*[2]" mode = "semantics">
1551     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
1552       <xsl:with-param name="PARAM" select="$PARAM"/>
1553       <xsl:with-param name="PAREN" select="$PAREN"/>
1554       <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1555   </xsl:apply-templates>
1556   <m:mo>
1557     <xsl:if test="m:rem">
1558 <!-- HELM: xref added -->        
1559         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rem/@id">
1560           <xsl:attribute name="xref">
1561             <xsl:value-of select="m:rem/@id"/>
1562           </xsl:attribute>
1563         </xsl:if>      
1564       <xsl:value-of select="'%'"/>
1565     </xsl:if>
1566     <xsl:if test="m:divide">
1567 <!-- HELM: xref added -->        
1568         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divide/@id">
1569           <xsl:attribute name="xref">
1570             <xsl:value-of select="m:divide/@id"/>
1571           </xsl:attribute>
1572         </xsl:if>
1573       <xsl:value-of select="'/'"/>
1574     </xsl:if>
1575   </m:mo>
1576   <xsl:apply-templates select = "*[3]" mode = "semantics">
1577     <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
1578     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
1579     <xsl:with-param name="PAREN" select="$PAREN"/>
1580     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1581   </xsl:apply-templates>
1582 </xsl:template>
1583
1584 <xsl:template match = "m:apply[m:times[1]]">
1585   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1586   <xsl:param name="PARAM" select="$NO_PARAM"/>
1587   <xsl:param name="PAREN" select="$PAR_NO"/>
1588   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1589   <xsl:choose>
1590     <xsl:when test="$IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and
1591                                                     $PARAM=$PAR_SAME">
1592       <m:mfenced separators="">
1593         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1594           <xsl:attribute name="xref">
1595             <xsl:value-of select="@id"/>
1596           </xsl:attribute>
1597         </xsl:if>
1598         <xsl:apply-templates select="." mode="times">
1599           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1600           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1601           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1602         </xsl:apply-templates>
1603       </m:mfenced>
1604     </xsl:when>
1605     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1606                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1607                     and not($SEM_SW=$SEM_XREF_EXT)">
1608       <xsl:apply-templates select="." mode="times">
1609         <xsl:with-param name="PARAM" select="$PARAM"/>
1610         <xsl:with-param name="PAREN" select="$PAREN"/>
1611         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1612       </xsl:apply-templates>
1613     </xsl:when>
1614     <xsl:otherwise>
1615       <m:mrow>
1616         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1617           <xsl:attribute name="xref">
1618             <xsl:value-of select="@id"/>
1619           </xsl:attribute>
1620         </xsl:if>
1621         <xsl:apply-templates select="." mode="times">
1622           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1623           <xsl:with-param name="PAREN" select="$PAREN"/>
1624           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1625         </xsl:apply-templates>
1626       </m:mrow>
1627     </xsl:otherwise>
1628   </xsl:choose>
1629 </xsl:template>
1630
1631 <xsl:template match = "m:apply[m:times[1]]" mode="times">
1632   <xsl:param name="PARAM" select="$NO_PARAM"/>
1633   <xsl:param name="PAREN" select="$PAR_NO"/>
1634   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1635   <xsl:apply-templates select="*[2]" mode = "semantics">
1636     <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
1637     <xsl:with-param name="PARAM" select="$PARAM"/>
1638     <xsl:with-param name="PAREN" select="$PAREN"/>
1639     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1640   </xsl:apply-templates>
1641   <xsl:if test="*[3]">
1642     <xsl:for-each select = "*[position()>2]">
1643 <!-- HELM: to distinguish between * and the application -->
1644 <!-- Was:
1645       <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
1646      Now is: -->
1647      <m:mo>
1648 <!-- HELM: xref added -->        
1649         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:times/@id">
1650           <xsl:attribute name="xref">
1651             <xsl:value-of select="../m:times/@id"/>
1652           </xsl:attribute>
1653         </xsl:if>*</m:mo>
1654       <xsl:apply-templates select="." mode = "semantics">
1655         <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
1656         <xsl:with-param name="PAREN" select="$PAREN"/>
1657         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1658       </xsl:apply-templates>
1659     </xsl:for-each>
1660   </xsl:if>
1661 </xsl:template>
1662
1663 <xsl:template match = "m:apply[m:root[1]]">
1664   <m:msqrt>
1665     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1666       <xsl:attribute name="xref">
1667         <xsl:value-of select="@id"/>
1668       </xsl:attribute>
1669     </xsl:if>
1670     <xsl:if test="*[2]=m:degree">
1671       <xsl:apply-templates select="*[3]" mode = "semantics">
1672         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1673         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1674       </xsl:apply-templates>
1675       <xsl:apply-templates select="*[2]" mode = "semantics"/>
1676     </xsl:if>
1677     <xsl:if test="not(*[2]=m:degree)">
1678       <xsl:apply-templates select="*[2]" mode = "semantics">
1679         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1680         <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1681       </xsl:apply-templates>
1682       <m:mn>2</m:mn>
1683     </xsl:if>
1684   </m:msqrt>
1685 </xsl:template>
1686
1687 <xsl:template match = "m:apply[m:gcd[1]]">
1688   <m:mrow>
1689     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1690       <xsl:attribute name="xref">
1691         <xsl:value-of select="@id"/>
1692       </xsl:attribute>
1693     </xsl:if>
1694     <xsl:if test="not(parent::m:apply[m:power[1]])">
1695       <m:mo>
1696 <!-- HELM: xref added -->        
1697         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
1698           <xsl:attribute name="xref">
1699             <xsl:value-of select="m:gcd/@id"/>
1700           </xsl:attribute>
1701         </xsl:if>gcd</m:mo>
1702     </xsl:if>
1703     <xsl:if test="parent::m:apply[m:power[1]]">
1704       <m:msup>
1705         <m:mo>
1706 <!-- HELM: xref added -->        
1707         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
1708           <xsl:attribute name="xref">
1709             <xsl:value-of select="m:gcd/@id"/>
1710           </xsl:attribute>
1711         </xsl:if>gcd</m:mo>
1712         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
1713       </m:msup>
1714     </xsl:if>
1715     <m:mfenced separators=",">
1716       <xsl:for-each select = "*[position()>1]">
1717         <xsl:apply-templates select = "." mode="semantics"/>
1718       </xsl:for-each>
1719     </m:mfenced>
1720   </m:mrow>
1721 </xsl:template>
1722
1723 <xsl:template match = "m:apply[m:and[1]]">
1724   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1725   <xsl:param name="PAREN" select="$PAR_NO"/>
1726   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1727   <xsl:choose>
1728     <xsl:when test="$IN_PREC &gt; $AND_PREC">
1729       <m:mfenced separators="">
1730         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1731           <xsl:attribute name="xref">
1732             <xsl:value-of select="@id"/>
1733           </xsl:attribute>
1734         </xsl:if>
1735         <xsl:apply-templates select="." mode="and">
1736           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1737           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1738         </xsl:apply-templates>
1739       </m:mfenced>
1740     </xsl:when>
1741     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1742                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1743                     and not($SEM_SW=$SEM_XREF_EXT)">
1744       <xsl:apply-templates select="." mode="and">
1745         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1746         <xsl:with-param name="PAREN" select="$PAREN"/>
1747         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1748       </xsl:apply-templates>
1749     </xsl:when>
1750     <xsl:otherwise>
1751       <m:mrow>
1752         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1753           <xsl:attribute name="xref">
1754             <xsl:value-of select="@id"/>
1755           </xsl:attribute>
1756         </xsl:if>
1757         <xsl:apply-templates select="." mode="and">
1758           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1759           <xsl:with-param name="PAREN" select="$PAREN"/>
1760           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1761         </xsl:apply-templates>
1762       </m:mrow>
1763     </xsl:otherwise>
1764   </xsl:choose>
1765 </xsl:template>
1766
1767 <xsl:template match = "m:apply[m:and[1]]" mode="and">
1768   <xsl:param name="PARAM" select="$NO_PARAM"/>
1769   <xsl:param name="PAREN" select="$PAR_NO"/>
1770   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1771   <xsl:apply-templates select="*[2]" mode = "semantics">
1772     <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1773     <xsl:with-param name="PARAM" select="$PARAM"/>
1774     <xsl:with-param name="PAREN" select="$PAREN"/>
1775     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1776   </xsl:apply-templates>
1777   <xsl:for-each select = "*[position()>2]">
1778     <m:mo>
1779 <!-- HELM: xref added -->        
1780         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:and/@id">
1781           <xsl:attribute name="xref">
1782             <xsl:value-of select="../m:and/@id"/>
1783           </xsl:attribute>
1784         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2227;</xsl:text></m:mo>
1785     <xsl:apply-templates select="." mode = "semantics">
1786       <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
1787       <xsl:with-param name="PAREN" select="$PAREN"/>
1788       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1789     </xsl:apply-templates>
1790   </xsl:for-each>
1791 </xsl:template>
1792
1793 <xsl:template match = "m:apply[m:or[1]]">
1794   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1795   <xsl:param name="PAREN" select="$PAR_NO"/>
1796   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1797   <xsl:choose>
1798     <xsl:when test="$IN_PREC &gt; $OR_PREC">
1799       <m:mfenced separators="">
1800         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1801           <xsl:attribute name="xref">
1802             <xsl:value-of select="@id"/>
1803           </xsl:attribute>
1804         </xsl:if>
1805         <xsl:apply-templates select="." mode="or">
1806           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1807           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1808         </xsl:apply-templates>
1809       </m:mfenced>
1810     </xsl:when>
1811     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1812                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
1813                     and not($SEM_SW=$SEM_XREF_EXT)">
1814       <xsl:apply-templates select="." mode="or">
1815         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1816         <xsl:with-param name="PAREN" select="$PAREN"/>
1817         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1818       </xsl:apply-templates>
1819     </xsl:when>
1820     <xsl:otherwise>
1821       <m:mrow>
1822         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1823           <xsl:attribute name="xref">
1824             <xsl:value-of select="@id"/>
1825           </xsl:attribute>
1826         </xsl:if>
1827         <xsl:apply-templates select="." mode="or">
1828           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1829           <xsl:with-param name="PAREN" select="$PAREN"/>
1830           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1831         </xsl:apply-templates>
1832       </m:mrow>
1833     </xsl:otherwise>
1834   </xsl:choose>
1835 </xsl:template>
1836
1837 <xsl:template match = "m:apply[m:or[1]]" mode="or">
1838   <xsl:param name="PARAM" select="$NO_PARAM"/>
1839   <xsl:param name="PAREN" select="$PAR_NO"/>
1840   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1841   <xsl:apply-templates select="*[2]" mode = "semantics">
1842     <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1843     <xsl:with-param name="PARAM" select="$PARAM"/>
1844     <xsl:with-param name="PAREN" select="$PAREN"/>
1845     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1846   </xsl:apply-templates>
1847   <xsl:for-each select = "*[position()>2]">
1848     <m:mo> 
1849 <!-- HELM: xref added -->        
1850         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:or/@id">
1851           <xsl:attribute name="xref">
1852             <xsl:value-of select="../m:or/@id"/>
1853           </xsl:attribute>
1854         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2228;</xsl:text></m:mo>
1855     <xsl:apply-templates select="." mode = "semantics">
1856       <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
1857       <xsl:with-param name="PAREN" select="$PAREN"/>
1858       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1859     </xsl:apply-templates>
1860   </xsl:for-each>
1861 </xsl:template>
1862
1863 <xsl:template match = "m:apply[m:xor[1]]">
1864   <xsl:param name="IN_PREC" select="$NO_PREC"/>
1865   <xsl:param name="PAREN" select="$PAR_NO"/>
1866   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1867   <xsl:choose>
1868     <xsl:when test="$IN_PREC &gt; $XOR_PREC">
1869       <m:mfenced separators="">
1870         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1871           <xsl:attribute name="xref">
1872             <xsl:value-of select="@id"/>
1873           </xsl:attribute>
1874         </xsl:if>
1875         <xsl:apply-templates select="." mode="xor">
1876           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1877           <xsl:with-param name="PAREN" select="$PAR_YES"/>
1878           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1879         </xsl:apply-templates>
1880       </m:mfenced>
1881     </xsl:when>
1882     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
1883                                                 and not($SEM_SW=$SEM_ALL)">
1884       <xsl:apply-templates select="." mode="xor">
1885         <xsl:with-param name="PARAM" select="$IN_PREC"/>
1886         <xsl:with-param name="PAREN" select="$PAREN"/>
1887       </xsl:apply-templates>
1888     </xsl:when>
1889     <xsl:otherwise>
1890       <m:mrow>
1891         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1892           <xsl:attribute name="xref">
1893             <xsl:value-of select="@id"/>
1894           </xsl:attribute>
1895         </xsl:if>
1896         <xsl:apply-templates select="." mode="xor">
1897           <xsl:with-param name="PARAM" select="$IN_PREC"/>
1898           <xsl:with-param name="PAREN" select="$PAREN"/>
1899           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1900         </xsl:apply-templates>
1901       </m:mrow>
1902     </xsl:otherwise>
1903   </xsl:choose>
1904 </xsl:template>
1905
1906 <xsl:template match = "m:apply[m:xor[1]]" mode="xor">
1907   <xsl:param name="PARAM" select="$NO_PARAM"/>
1908   <xsl:param name="PAREN" select="$PAR_NO"/>
1909   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
1910   <xsl:apply-templates select="*[2]" mode = "semantics">
1911     <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1912     <xsl:with-param name="PARAM" select="$PARAM"/>
1913     <xsl:with-param name="PAREN" select="$PAREN"/>
1914     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
1915   </xsl:apply-templates>
1916   <xsl:for-each select = "*[position()>2]">
1917     <m:mo>
1918 <!-- HELM: xref added -->        
1919         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:xor/@id">
1920           <xsl:attribute name="xref">
1921             <xsl:value-of select="../m:xor/@id"/>
1922           </xsl:attribute>
1923         </xsl:if><xsl:text disable-output-escaping='yes'>&#x22BB;</xsl:text></m:mo>
1924     <xsl:apply-templates select="." mode = "semantics">
1925       <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
1926       <xsl:with-param name="PAREN" select="$PAREN"/>
1927       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
1928     </xsl:apply-templates>
1929   </xsl:for-each>
1930 </xsl:template>
1931
1932 <xsl:template match = "m:apply[m:not[1]]">
1933   <m:mrow>
1934     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1935       <xsl:attribute name="xref">
1936         <xsl:value-of select="@id"/>
1937       </xsl:attribute>
1938     </xsl:if>
1939 <!-- HELM: was <m:mo>not</m:mo> 
1940      Now is -->
1941     <m:mo>
1942 <!-- HELM: xref added -->        
1943         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:not/@id">
1944           <xsl:attribute name="xref">
1945             <xsl:value-of select="m:not/@id"/>
1946           </xsl:attribute>
1947         </xsl:if>&#x000AC;</m:mo>
1948     <xsl:apply-templates select = "*[2]" mode = "semantics">
1949       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
1950     </xsl:apply-templates>
1951   </m:mrow>
1952 </xsl:template>
1953
1954 <xsl:template match = "m:apply[m:forall[1]]">
1955   <m:mrow>
1956     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1957       <xsl:attribute name="xref">
1958         <xsl:value-of select="@id"/>
1959       </xsl:attribute>
1960     </xsl:if>
1961     <m:mo>
1962 <!-- HELM: xref added -->        
1963         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:forall/@id">
1964           <xsl:attribute name="xref">
1965             <xsl:value-of select="m:forall/@id"/>
1966           </xsl:attribute>
1967         </xsl:if>for all</m:mo>
1968     <xsl:if test="count(m:bvar) &gt; 1">
1969       <m:mfenced separators=",">
1970         <xsl:for-each select = "m:bvar">
1971           <xsl:apply-templates select = "." mode="semantics"/>
1972         </xsl:for-each>
1973       </m:mfenced>
1974     </xsl:if>
1975     <xsl:if test="count(m:bvar)=1">
1976       <xsl:apply-templates select = "m:bvar" mode="semantics"/>
1977     </xsl:if>
1978     <xsl:if test="m:condition">
1979       <m:mo>:</m:mo>
1980       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
1981       <m:mo>,</m:mo>
1982     </xsl:if>
1983     <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
1984                                 not(self::m:condition)]" mode = "semantics"/>
1985   </m:mrow>
1986 </xsl:template>
1987
1988 <xsl:template match = "m:apply[m:exists[1]]">
1989   <m:mrow>
1990     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
1991       <xsl:attribute name="xref">
1992         <xsl:value-of select="@id"/>
1993       </xsl:attribute>
1994     </xsl:if>
1995     <m:mo>
1996 <!-- HELM: xref added -->        
1997         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exists/@id">
1998           <xsl:attribute name="xref">
1999             <xsl:value-of select="m:exists/@id"/>
2000           </xsl:attribute>
2001         </xsl:if><xsl:text disable-output-escaping='yes'>&#x2203;</xsl:text> </m:mo>
2002     <xsl:if test="count(m:bvar) &gt; 1">
2003       <m:mfenced separators=",">
2004         <xsl:for-each select = "m:bvar">
2005           <xsl:apply-templates select = "." mode="semantics"/>
2006         </xsl:for-each>
2007       </m:mfenced>
2008     </xsl:if>
2009     <xsl:if test="count(m:bvar)=1">
2010       <xsl:apply-templates select = "m:bvar" mode="semantics"/>
2011     </xsl:if>
2012     <xsl:if test="m:condition">
2013       <m:mo>,</m:mo>
2014       <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
2015     </xsl:if>
2016     <xsl:if test="*[position()>1 and not(self::m:bvar) and not(self::m:condition)]">
2017       <m:mo>:</m:mo>
2018       <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
2019                                 not(self::m:condition)]" mode = "semantics"/>
2020     </xsl:if>
2021   </m:mrow>
2022 </xsl:template>
2023
2024 <!-- HELM WARNING: abs id was lost! -->
2025 <xsl:template match = "m:apply[m:abs[1]]">
2026   <xsl:if test="not(parent::m:apply[m:power[1]])">
2027 <!-- HELM: was
2028     <m:mfenced open="|" close="|" separators="">
2029      Now is: mrow + mo -->
2030      <m:mrow>
2031       <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2032         <xsl:attribute name="xref">
2033           <xsl:value-of select="@id"/>
2034         </xsl:attribute>
2035       </xsl:if>
2036       <m:mo>
2037 <!-- HELM: xref added -->        
2038         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2039           <xsl:attribute name="xref">
2040             <xsl:value-of select="m:abs/@id"/>
2041           </xsl:attribute>
2042         </xsl:if>|</m:mo>
2043       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2044       <m:mo>
2045 <!-- HELM: xref added -->        
2046         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2047           <xsl:attribute name="xref">
2048             <xsl:value-of select="m:abs/@id"/>
2049           </xsl:attribute>
2050         </xsl:if>|</m:mo> 
2051 <!-- HELM: </m:mfenced> -->
2052      </m:mrow>
2053   </xsl:if>
2054   <xsl:if test="parent::m:apply[m:power[1]]">
2055     <m:msup>
2056 <!-- HELM: was
2057       <m:mfenced open="|" close="|" separators="">
2058      Now is: mrow + mo -->
2059       <m:mrow>
2060         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2061           <xsl:attribute name="xref">
2062             <xsl:value-of select="@id"/>
2063           </xsl:attribute>
2064         </xsl:if>
2065         <m:mo>
2066 <!-- HELM: xref added -->        
2067         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2068           <xsl:attribute name="xref">
2069             <xsl:value-of select="m:abs/@id"/>
2070           </xsl:attribute>
2071         </xsl:if>|</m:mo> 
2072         <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2073         <m:mo>
2074 <!-- HELM: xref added -->        
2075         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
2076           <xsl:attribute name="xref">
2077             <xsl:value-of select="m:abs/@id"/>
2078           </xsl:attribute>
2079         </xsl:if>|</m:mo> 
2080 <!-- HELM: </m:mfenced> -->
2081       </m:mrow>
2082       <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2083     </m:msup>
2084   </xsl:if>
2085 </xsl:template>
2086
2087 <xsl:template match = "m:apply[m:conjugate[1]]">
2088   <m:mover>
2089     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2090       <xsl:attribute name="xref">
2091         <xsl:value-of select="@id"/>
2092       </xsl:attribute>
2093     </xsl:if>
2094     <m:mrow>
2095       <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
2096     </m:mrow>
2097     <m:mo>
2098 <!-- HELM: xref added -->        
2099         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:conjugate/@id">
2100           <xsl:attribute name="xref">
2101             <xsl:value-of select="m:conjugate/@id"/>
2102           </xsl:attribute>
2103         </xsl:if><xsl:text disable-output-escaping='yes'>&#x0332;</xsl:text> </m:mo>
2104   </m:mover>
2105 </xsl:template>
2106
2107 <xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
2108   <m:mrow>
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:mo>
2115       <xsl:if test="m:arg">
2116 <!-- HELM: xref added -->        
2117         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:arg/@id">
2118           <xsl:attribute name="xref">
2119             <xsl:value-of select="m:arg/@id"/>
2120           </xsl:attribute>
2121         </xsl:if>
2122         <xsl:value-of select="'Arg'"/>
2123       </xsl:if>
2124       <xsl:if test="m:real">
2125 <!-- HELM: xref added -->        
2126         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:real/@id">
2127           <xsl:attribute name="xref">
2128             <xsl:value-of select="m:real/@id"/>
2129           </xsl:attribute>
2130         </xsl:if>
2131         <xsl:value-of select="'Re'"/>
2132       </xsl:if>
2133       <xsl:if test="m:imaginary">
2134 <!-- HELM: xref added -->        
2135         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginary/@id">
2136           <xsl:attribute name="xref">
2137             <xsl:value-of select="m:imaginary/@id"/>
2138           </xsl:attribute>
2139         </xsl:if>
2140         <xsl:value-of select="'Im'"/>
2141       </xsl:if>
2142     </m:mo>
2143     <m:mfenced separators="">
2144       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2145     </m:mfenced>
2146   </m:mrow>
2147 </xsl:template>
2148
2149 <!-- HELM: was (it didn't match with prefixed MathML)
2150 <xsl:template match="m:apply[child::*[position()=1 and name()='lcm']]">
2151      Now is: -->
2152 <xsl:template match="m:apply[child::*[position()=1 and self::m:lcm]]">
2153   <m:mrow>
2154     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2155       <xsl:attribute name="xref">
2156         <xsl:value-of select="@id"/>
2157       </xsl:attribute>
2158     </xsl:if>
2159     <xsl:if test="not(parent::m:apply[m:power[1]])">
2160       <m:mo>
2161 <!-- HELM: xref added -->        
2162         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
2163           <xsl:attribute name="xref">
2164             <xsl:value-of select="m:lcm/@id"/>
2165           </xsl:attribute>
2166         </xsl:if>lcm</m:mo>
2167     </xsl:if>
2168     <xsl:if test="parent::m:apply[m:power[1]]">
2169       <m:msup>
2170         <m:mo>
2171 <!-- HELM: xref added -->        
2172         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
2173           <xsl:attribute name="xref">
2174             <xsl:value-of select="m:lcm/@id"/>
2175           </xsl:attribute>
2176         </xsl:if>lcm</m:mo>
2177         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2178         </m:msup>
2179       </xsl:if>
2180       <m:mfenced separators=",">
2181         <xsl:for-each select = "*[position()>1]">
2182           <xsl:apply-templates select = "." mode="semantics"/>
2183           </xsl:for-each>
2184         </m:mfenced>
2185       </m:mrow>
2186     </xsl:template>
2187
2188 <!-- HELM: was (it didn't match with prefixed MathML)
2189 <xsl:template match="m:apply[child::*[position()=1 and name()='floor']]">
2190      Now is: -->
2191 <xsl:template match="m:apply[child::*[position()=1 and self::m:floor]]">
2192   <m:mrow>
2193     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2194       <xsl:attribute name="xref">
2195         <xsl:value-of select="@id"/>
2196       </xsl:attribute>
2197     </xsl:if>
2198     <m:mo>
2199 <!-- HELM: xref added -->        
2200         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
2201           <xsl:attribute name="xref">
2202             <xsl:value-of select="m:floor/@id"/>
2203           </xsl:attribute>
2204         </xsl:if>
2205 <!-- HELM: not rendered correctly <![CDATA[&LeftFloor;]]> -->
2206       <xsl:text disable-output-escaping="yes">&#x230A;</xsl:text>
2207     </m:mo>
2208     <xsl:apply-templates select="child::*[position()=last()]" mode="semantics"/>
2209     <m:mo>
2210 <!-- HELM: xref added -->        
2211         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
2212           <xsl:attribute name="xref">
2213             <xsl:value-of select="m:floor/@id"/>
2214           </xsl:attribute>
2215         </xsl:if>
2216 <!-- HELM: not rendered correctly <![CDATA[&RightFloor;]]> -->
2217 <xsl:text disable-output-escaping="yes">&#x230B;</xsl:text>
2218     </m:mo>
2219 </m:mrow>
2220 </xsl:template>
2221
2222 <!-- HELM: was (it didn't match with prefixed MathML)
2223 <xsl:template match="m:apply[child::*[position()=1 and name()='ceiling']]">
2224      Now is: -->
2225 <xsl:template match="m:apply[child::*[position()=1 and self::m:ceiling]]">
2226   <m:mrow>
2227     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2228       <xsl:attribute name="xref">
2229         <xsl:value-of select="@id"/>
2230       </xsl:attribute>
2231     </xsl:if>
2232     <m:mo>
2233 <!-- HELM: xref added -->        
2234         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
2235           <xsl:attribute name="xref">
2236             <xsl:value-of select="m:ceiling/@id"/>
2237           </xsl:attribute>
2238         </xsl:if>
2239 <!-- HELM: not rendered correctly <![CDATA[&LeftCeiling;]]> -->
2240       <xsl:text disable-output-escaping="yes">&#x2308;</xsl:text>
2241     </m:mo>
2242     <xsl:apply-templates select="child::*[position()=last()]"  mode="semantics"/>
2243     <m:mo>
2244 <!-- HELM: xref added -->        
2245         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
2246           <xsl:attribute name="xref">
2247             <xsl:value-of select="m:ceiling/@id"/>
2248           </xsl:attribute>
2249         </xsl:if>
2250 <!-- HELM: not rendered correctly <![CDATA[&RightCeiling;]]> -->
2251       <xsl:text disable-output-escaping="yes">&#x2309;</xsl:text>
2252     </m:mo>
2253   </m:mrow>
2254 </xsl:template>
2255
2256
2257 <!-- ***************** RELATIONS ***************** -->
2258
2259 <xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies
2260                      | m:in | m:notin | m:notsubset | m:notprsubset
2261                      | m:subset | m:prsubset | m:eq | m:gt | m:lt
2262                      | m:geq | m:leq | m:equivalent | m:factorof]">
2263   <m:mrow>
2264     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2265       <xsl:attribute name="xref">
2266         <xsl:value-of select="@id"/>
2267       </xsl:attribute>
2268     </xsl:if>
2269     <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:factorof or *[1]=m:tendsto or
2270                   *[1]=m:implies or *[1]=m:in or *[1]=m:notin or
2271                   *[1]=m:notsubset or *[1]=m:notprsubset">
2272       <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2273       <m:mo>
2274         <xsl:if test="*[1]=m:neq">
2275 <!-- HELM: xref added -->        
2276         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:neq/@id">
2277           <xsl:attribute name="xref">
2278             <xsl:value-of select="m:neq/@id"/>
2279           </xsl:attribute>
2280         </xsl:if>
2281          <xsl:text disable-output-escaping='yes'>&#x2260;</xsl:text>
2282         </xsl:if>
2283         <xsl:if test="*[1]=m:approx">
2284 <!-- HELM: xref added -->        
2285         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:approx/@id">
2286           <xsl:attribute name="xref">
2287             <xsl:value-of select="m:approx/@id"/>
2288           </xsl:attribute>
2289         </xsl:if>
2290          <xsl:text disable-output-escaping='yes'>&#x224A;</xsl:text>
2291         </xsl:if>
2292         <xsl:if test="*[1]=m:factorof">
2293 <!-- HELM: xref added -->        
2294         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorof/@id">
2295           <xsl:attribute name="xref">
2296             <xsl:value-of select="m:factorof/@id"/>
2297           </xsl:attribute>
2298         </xsl:if>
2299           |
2300         </xsl:if>
2301         <xsl:if test="*[1]=m:tendsto">
2302 <!-- HELM: xref added -->        
2303         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2304           <xsl:attribute name="xref">
2305             <xsl:value-of select="m:tendsto/@id"/>
2306           </xsl:attribute>
2307         </xsl:if>
2308          <xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text>
2309         </xsl:if>
2310         <xsl:if test="*[1]=m:implies">
2311 <!-- HELM: xref added -->        
2312         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:implies/@id">
2313           <xsl:attribute name="xref">
2314             <xsl:value-of select="m:implies/@id"/>
2315           </xsl:attribute>
2316         </xsl:if>
2317          <xsl:text disable-output-escaping='yes'>&#x21D2;</xsl:text>
2318         </xsl:if>
2319         <xsl:if test="*[1]=m:in">
2320 <!-- HELM: xref added -->        
2321         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:in/@id">
2322           <xsl:attribute name="xref">
2323             <xsl:value-of select="m:in/@id"/>
2324           </xsl:attribute>
2325         </xsl:if>
2326           <xsl:text disable-output-escaping='yes'>&#x2208;</xsl:text>
2327         </xsl:if>
2328         <xsl:if test="*[1]=m:notin">
2329 <!-- HELM: xref added -->        
2330         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notin/@id">
2331           <xsl:attribute name="xref">
2332             <xsl:value-of select="m:notin/@id"/>
2333           </xsl:attribute>
2334         </xsl:if>
2335          <xsl:text disable-output-escaping='yes'>&#x2209;</xsl:text>
2336         </xsl:if>
2337         <xsl:if test="*[1]=m:notsubset">
2338 <!-- HELM: xref added -->        
2339         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notsubset/@id">
2340           <xsl:attribute name="xref">
2341             <xsl:value-of select="m:notsubset/@id"/>
2342           </xsl:attribute>
2343         </xsl:if>
2344          <xsl:text disable-output-escaping='yes'>&#x2284;</xsl:text>
2345         </xsl:if>
2346         <xsl:if test="*[1]=m:notprsubset">
2347 <!-- HELM: xref added -->        
2348         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notprsubset/@id">
2349           <xsl:attribute name="xref">
2350             <xsl:value-of select="m:notprsubset/@id"/>
2351           </xsl:attribute>
2352         </xsl:if>
2353          <xsl:text disable-output-escaping='yes'>&#x2288;</xsl:text>
2354         </xsl:if>
2355       </m:mo>
2356       <xsl:apply-templates select = "*[3]" mode = "semantics"/>
2357       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
2358         <m:mo>
2359 <!-- HELM: xref added -->        
2360         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2361           <xsl:attribute name="xref">
2362             <xsl:value-of select="m:tendsto/@id"/>
2363           </xsl:attribute>
2364         </xsl:if>-</m:mo>
2365       </xsl:if>
2366       <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
2367         <m:mo>
2368 <!-- HELM: xref added -->        
2369         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
2370           <xsl:attribute name="xref">
2371             <xsl:value-of select="m:tendsto/@id"/>
2372           </xsl:attribute>
2373         </xsl:if>+</m:mo>
2374       </xsl:if>
2375     </xsl:if>
2376     <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt
2377                or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
2378       <xsl:apply-templates select = "*[2]" mode="semantics"/>
2379       <xsl:for-each select = "*[position()>2]">
2380         <m:mo>
2381           <xsl:if test="../*[self::m:subset][1]">
2382 <!-- HELM: xref added -->        
2383         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:subset/@id">
2384           <xsl:attribute name="xref">
2385             <xsl:value-of select="../m:subset/@id"/>
2386           </xsl:attribute>
2387         </xsl:if>
2388             <xsl:text disable-output-escaping='yes'>&#x2286;</xsl:text>
2389           </xsl:if>
2390           <xsl:if test="../*[self::m:prsubset][1]">
2391 <!-- HELM: xref added -->        
2392         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:prsubset/@id">
2393           <xsl:attribute name="xref">
2394             <xsl:value-of select="../m:prsubset/@id"/>
2395           </xsl:attribute>
2396         </xsl:if>
2397            <xsl:text disable-output-escaping='yes'>&#x2282;</xsl:text>
2398           </xsl:if>
2399           <xsl:if test="../*[self::m:eq][1]">
2400 <!-- HELM: xref added -->        
2401         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:eq/@id">
2402           <xsl:attribute name="xref">
2403             <xsl:value-of select="../m:eq/@id"/>
2404           </xsl:attribute>
2405         </xsl:if>
2406             <xsl:value-of select="'='"/>
2407           </xsl:if>
2408           <xsl:if test="../*[self::m:gt][1]">
2409 <!-- HELM: xref added -->        
2410         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:gt/@id">
2411           <xsl:attribute name="xref">
2412             <xsl:value-of select="../m:gt/@id"/>
2413           </xsl:attribute>
2414         </xsl:if>
2415             <xsl:value-of select="'&gt;'"/>
2416           </xsl:if>
2417           <xsl:if test="../*[self::m:lt][1]">
2418 <!-- HELM: xref added -->        
2419         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:lt/@id">
2420           <xsl:attribute name="xref">
2421             <xsl:value-of select="../m:lt/@id"/>
2422           </xsl:attribute>
2423         </xsl:if>
2424             <xsl:value-of select="'&lt;'"/>
2425           </xsl:if>
2426           <xsl:if test="../*[self::m:geq][1]">
2427 <!-- HELM: xref added -->        
2428         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:geq/@id">
2429           <xsl:attribute name="xref">
2430             <xsl:value-of select="../m:geq/@id"/>
2431           </xsl:attribute>
2432         </xsl:if>
2433            <xsl:text disable-output-escaping='yes'>&#x2265;</xsl:text>
2434           </xsl:if>
2435           <xsl:if test="../*[self::m:leq][1]">
2436 <!-- HELM: xref added -->        
2437         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:leq/@id">
2438           <xsl:attribute name="xref">
2439             <xsl:value-of select="../m:leq/@id"/>
2440           </xsl:attribute>
2441         </xsl:if>
2442            <xsl:text disable-output-escaping='yes'>&#x2264;</xsl:text>
2443           </xsl:if>
2444           <xsl:if test="../*[self::m:equivalent][1]">
2445 <!-- HELM: xref added -->        
2446         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:equivalent/@id">
2447           <xsl:attribute name="xref">
2448             <xsl:value-of select="../m:equivalent/@id"/>
2449           </xsl:attribute>
2450         </xsl:if>
2451            <xsl:text disable-output-escaping='yes'>&#x2261;</xsl:text>
2452           </xsl:if>
2453         </m:mo>
2454         <xsl:apply-templates select = "." mode="semantics"/>
2455       </xsl:for-each>
2456     </xsl:if>
2457   </m:mrow>
2458 </xsl:template>
2459
2460
2461 <!-- ***************** CALCULUS ***************** -->
2462
2463 <xsl:template match = "m:apply[*[1][self::m:ln]]">
2464   <m:mrow>
2465     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2466       <xsl:attribute name="xref">
2467         <xsl:value-of select="@id"/>
2468       </xsl:attribute>
2469     </xsl:if>
2470     <xsl:choose>
2471       <xsl:when test="parent::m:apply[m:power[1]]">
2472         <m:msup>
2473           <m:mo>
2474 <!-- HELM: xref added -->        
2475         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
2476           <xsl:attribute name="xref">
2477             <xsl:value-of select="m:ln/@id"/>
2478           </xsl:attribute>
2479         </xsl:if>ln</m:mo>
2480           <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2481         </m:msup>
2482       </xsl:when>
2483       <xsl:otherwise>
2484         <m:mo>
2485 <!-- HELM: xref added -->        
2486         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
2487           <xsl:attribute name="xref">
2488             <xsl:value-of select="m:ln/@id"/>
2489           </xsl:attribute>
2490         </xsl:if>ln</m:mo>
2491       </xsl:otherwise>
2492     </xsl:choose>
2493     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
2494     <xsl:apply-templates select = "*[2]" mode = "semantics">
2495       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2496     </xsl:apply-templates>
2497   </m:mrow>
2498 </xsl:template>
2499
2500 <xsl:template match = "m:apply[m:log[1]]">
2501   <m:mrow>
2502     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2503       <xsl:attribute name="xref">
2504         <xsl:value-of select="@id"/>
2505       </xsl:attribute>
2506     </xsl:if>
2507     <xsl:choose>
2508       <xsl:when test="parent::m:apply[m:power[1]]">
2509         <xsl:if test="not(*[2]=m:logbase)">
2510           <m:msup>
2511             <m:mo>
2512 <!-- HELM: xref added -->        
2513         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2514           <xsl:attribute name="xref">
2515             <xsl:value-of select="m:log/@id"/>
2516           </xsl:attribute>
2517         </xsl:if>log</m:mo>
2518             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2519           </m:msup>
2520         </xsl:if>
2521         <xsl:if test="*[2]=m:logbase">
2522           <m:msubsup>
2523             <m:mo>
2524 <!-- HELM: xref added -->        
2525         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2526           <xsl:attribute name="xref">
2527             <xsl:value-of select="m:log/@id"/>
2528           </xsl:attribute>
2529         </xsl:if>log</m:mo>
2530             <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
2531             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
2532           </m:msubsup>
2533         </xsl:if>
2534       </xsl:when>
2535       <xsl:otherwise>
2536         <xsl:if test="not(*[2]=m:logbase)">
2537           <m:mo>
2538 <!-- HELM: xref added -->        
2539         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2540           <xsl:attribute name="xref">
2541             <xsl:value-of select="m:log/@id"/>
2542           </xsl:attribute>
2543         </xsl:if>log</m:mo>
2544         </xsl:if>
2545         <xsl:if test="*[2]=m:logbase">
2546           <m:msub>
2547             <m:mo>
2548 <!-- HELM: xref added -->        
2549         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
2550           <xsl:attribute name="xref">
2551             <xsl:value-of select="m:log/@id"/>
2552           </xsl:attribute>
2553         </xsl:if>log</m:mo>
2554             <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
2555           </m:msub>
2556         </xsl:if>
2557       </xsl:otherwise>
2558     </xsl:choose>
2559     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
2560     <xsl:if test="*[2]=m:logbase">
2561       <xsl:apply-templates select = "*[3]" mode = "semantics">
2562         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2563       </xsl:apply-templates>
2564     </xsl:if>
2565     <xsl:if test="not(*[2]=m:logbase)">
2566       <xsl:apply-templates select = "*[2]" mode = "semantics">
2567         <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
2568       </xsl:apply-templates>
2569     </xsl:if>
2570   </m:mrow>
2571 </xsl:template>
2572
2573 <xsl:template match = "m:apply[m:diff[1]]">
2574   <m:mrow>
2575     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2576       <xsl:attribute name="xref">
2577         <xsl:value-of select="@id"/>
2578       </xsl:attribute>
2579     </xsl:if>
2580     <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
2581       <m:mfrac>
2582 <!-- HELM: xref added -->        
2583         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
2584           <xsl:attribute name="xref">
2585             <xsl:value-of select="m:diff/@id"/>
2586           </xsl:attribute>
2587         </xsl:if>
2588         <m:msup>
2589           <m:mo>d</m:mo>
2590           <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
2591         </m:msup>
2592         <m:mrow>
2593           <m:mo>d</m:mo>
2594           <m:msup>
2595             <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
2596             <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
2597           </m:msup>
2598         </m:mrow>
2599       </m:mfrac>
2600     </xsl:if>
2601     <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
2602       <m:mfrac>
2603 <!-- HELM: xref added -->        
2604         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
2605           <xsl:attribute name="xref">
2606             <xsl:value-of select="m:diff/@id"/>
2607           </xsl:attribute>
2608         </xsl:if>
2609         <m:mo>d</m:mo>
2610         <m:mrow>
2611           <m:mo>d</m:mo>
2612           <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
2613         </m:mrow>
2614       </m:mfrac>
2615     </xsl:if>
2616     <xsl:apply-templates select = "*[3]" mode = "semantics"/>
2617   </m:mrow>
2618 </xsl:template>
2619
2620 <xsl:template match = "m:apply[m:partialdiff[1]]">
2621   <m:mrow>
2622     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2623       <xsl:attribute name="xref">
2624         <xsl:value-of select="@id"/>
2625       </xsl:attribute>
2626     </xsl:if>
2627     <xsl:for-each select = "m:bvar">
2628       <xsl:if test="*[last()]=m:degree">
2629         <m:mfrac>
2630 <!-- HELM: xref added -->        
2631         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
2632           <xsl:attribute name="xref">
2633             <xsl:value-of select="../m:partialdiff/@id"/>
2634           </xsl:attribute>
2635         </xsl:if>
2636           <m:msup>
2637              <m:mo>d</m:mo>
2638              <xsl:apply-templates select = "m:degree" mode = "semantics"/>
2639           </m:msup>
2640           <m:mrow>
2641             <m:mo>d</m:mo>
2642             <m:msup>
2643               <xsl:apply-templates select = "*[1]" mode = "semantics"/>
2644               <xsl:apply-templates select = "m:degree" mode = "semantics"/>
2645             </m:msup>
2646           </m:mrow>
2647         </m:mfrac>
2648       </xsl:if>
2649       <xsl:if test="not(*[last()]=m:degree)">
2650         <m:mfrac>
2651 <!-- HELM: xref added -->        
2652         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
2653           <xsl:attribute name="xref">
2654             <xsl:value-of select="../m:partialdiff/@id"/>
2655           </xsl:attribute>
2656         </xsl:if>
2657           <m:mo>d</m:mo>
2658           <m:mrow>
2659             <m:mo>d</m:mo>
2660             <xsl:apply-templates select = "*[1]" mode = "semantics"/>
2661           </m:mrow>
2662         </m:mfrac>
2663       </xsl:if>
2664     </xsl:for-each>
2665     <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
2666   </m:mrow>
2667 </xsl:template>
2668
2669 <xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
2670   <xsl:apply-templates select="*" mode = "semantics"/>
2671 </xsl:template>
2672
2673 <xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
2674   <m:mrow>
2675     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2676       <xsl:attribute name="xref">
2677         <xsl:value-of select="@id"/>
2678       </xsl:attribute>
2679     </xsl:if>
2680     <m:mo>
2681       <xsl:if test="*[1]=m:divergence">
2682 <!-- HELM: xref added -->        
2683         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divergence/@id">
2684           <xsl:attribute name="xref">
2685             <xsl:value-of select="m:divergence/@id"/>
2686           </xsl:attribute>
2687         </xsl:if>
2688         <xsl:value-of select="'div'"/>
2689       </xsl:if>
2690       <xsl:if test="*[1]=m:grad">
2691 <!-- HELM: xref added -->        
2692         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:grad/@id">
2693           <xsl:attribute name="xref">
2694             <xsl:value-of select="m:grad/@id"/>
2695           </xsl:attribute>
2696         </xsl:if>
2697         <xsl:value-of select="'grad'"/>
2698       </xsl:if>
2699       <xsl:if test="*[1]=m:curl">
2700 <!-- HELM: xref added -->        
2701         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:curl/@id">
2702           <xsl:attribute name="xref">
2703             <xsl:value-of select="m:curl/@id"/>
2704           </xsl:attribute>
2705         </xsl:if>
2706         <xsl:value-of select="'curl'"/>
2707       </xsl:if>
2708     </m:mo>
2709     <xsl:choose>
2710       <xsl:when test="*[2]=m:ci">
2711         <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2712       </xsl:when>
2713       <xsl:otherwise>
2714         <m:mfenced separators="">
2715           <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2716         </m:mfenced>
2717       </xsl:otherwise>
2718     </xsl:choose>
2719   </m:mrow>
2720 </xsl:template>
2721
2722 <xsl:template match = "m:apply[m:laplacian[1]]">
2723   <m:mrow>
2724     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2725       <xsl:attribute name="xref">
2726         <xsl:value-of select="@id"/>
2727       </xsl:attribute>
2728     </xsl:if>
2729     <m:msup>
2730       <m:mo>
2731 <!-- HELM: xref added -->        
2732         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:laplacian/@id">
2733           <xsl:attribute name="xref">
2734             <xsl:value-of select="m:laplacian/@id"/>
2735           </xsl:attribute>
2736         </xsl:if>
2737         <xsl:text disable-output-escaping='yes'>&#x0394;</xsl:text></m:mo>
2738       <m:mn>2</m:mn>
2739     </m:msup>
2740     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
2741   </m:mrow>
2742 </xsl:template>
2743
2744
2745 <!-- ***************** SET THEORY ***************** -->
2746
2747 <xsl:template match = "m:set | m:list">
2748   <m:mfenced open="{{" close="}}" separators="">
2749     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2750       <xsl:attribute name="xref">
2751         <xsl:value-of select="@id"/>
2752       </xsl:attribute>
2753     </xsl:if>
2754     <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
2755       <xsl:apply-templates select="m:bvar" mode = "semantics"/>
2756       <m:mo>|</m:mo>
2757       <xsl:apply-templates select="m:condition" mode = "semantics"/>
2758     </xsl:if>
2759     <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
2760       <m:mfenced open="" close="" separators=",">
2761         <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
2762           <xsl:apply-templates select = "." mode="semantics"/>
2763         </xsl:for-each>
2764       </m:mfenced>
2765       <m:mo>|</m:mo>
2766       <xsl:apply-templates select="m:condition" mode = "semantics"/>
2767     </xsl:if>
2768     <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
2769       <m:mfenced open="" close="" separators=",">
2770         <xsl:for-each select = "*">
2771           <xsl:apply-templates select = "." mode="semantics"/>
2772         </xsl:for-each>
2773       </m:mfenced>
2774     </xsl:if>
2775   </m:mfenced>
2776 </xsl:template>
2777
2778 <xsl:template match = "m:apply[m:union[1]]">
2779   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2780   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2781   <xsl:param name="PARAM" select="$NO_PARAM"/>
2782   <xsl:param name="PAREN" select="$PAR_NO"/>
2783   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2784   <xsl:choose>
2785     <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC
2786                     and $PARAM=$PAR_SAME and not($IN_OP=$UNION_OP)">
2787       <m:mfenced separators="">
2788         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2789           <xsl:attribute name="xref">
2790             <xsl:value-of select="@id"/>
2791           </xsl:attribute>
2792         </xsl:if>
2793         <xsl:apply-templates select="." mode="union">
2794           <xsl:with-param name="PARAM" select="$PARAM"/>
2795           <xsl:with-param name="PAREN" select="$PAREN"/>
2796           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2797         </xsl:apply-templates>
2798       </m:mfenced>
2799     </xsl:when>
2800     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2801                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2802                     and not($SEM_SW=$SEM_XREF_EXT)">
2803       <xsl:apply-templates select="." mode="union">
2804         <xsl:with-param name="PARAM" select="$PARAM"/>
2805         <xsl:with-param name="PAREN" select="$PAREN"/>
2806         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2807       </xsl:apply-templates>
2808     </xsl:when>
2809     <xsl:otherwise>
2810       <m:mrow>
2811         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2812           <xsl:attribute name="xref">
2813             <xsl:value-of select="@id"/>
2814           </xsl:attribute>
2815         </xsl:if>
2816         <xsl:apply-templates select="." mode="union">
2817           <xsl:with-param name="IN_OP" select="$UNION_OP"/>
2818           <xsl:with-param name="PARAM" select="$PARAM"/>
2819           <xsl:with-param name="PAREN" select="$PAREN"/>
2820           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2821         </xsl:apply-templates>
2822       </m:mrow>
2823     </xsl:otherwise>
2824   </xsl:choose>
2825 </xsl:template>
2826
2827 <xsl:template match = "m:apply[m:union[1]]" mode="union">
2828   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2829   <xsl:param name="PARAM" select="$NO_PARAM"/>
2830   <xsl:param name="PAREN" select="$PAR_NO"/>
2831   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2832   <xsl:apply-templates select = "*[2]" mode="semantics">
2833     <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
2834     <xsl:with-param name="PARAM" select="$PARAM"/>
2835     <xsl:with-param name="PAREN" select="$PAREN"/>
2836     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2837   </xsl:apply-templates>
2838   <xsl:for-each select = "*[position()>2]">
2839     <m:mo>
2840 <!-- HELM: xref added -->        
2841         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:union/@id">
2842           <xsl:attribute name="xref">
2843             <xsl:value-of select="../m:union/@id"/>
2844           </xsl:attribute>
2845         </xsl:if>&#x22C3;</m:mo>
2846 <!-- HELM: not rendered correctly <![CDATA[&Union;]]> -->
2847   <!--   <xsl:text disable-output-escaping="yes">&#x22C3;</xsl:text></m:mo>-->
2848     <xsl:apply-templates select = "." mode="semantics">
2849       <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
2850       <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
2851       <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
2852       <xsl:with-param name="PAREN" select="$PAREN"/>
2853       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
2854     </xsl:apply-templates>
2855   </xsl:for-each>
2856 </xsl:template>
2857
2858 <xsl:template match = "m:apply[m:intersect[1]]">
2859   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2860   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2861   <xsl:param name="PARAM" select="$NO_PARAM"/>
2862   <xsl:param name="PAREN" select="$PAR_NO"/>
2863   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2864   <xsl:choose>
2865     <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC or $IN_PREC=$INTERSECT_PREC
2866                     and $PARAM=$PAR_SAME and not($IN_OP=$INTERSECT_OP)">
2867       <m:mfenced separators="">
2868         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2869           <xsl:attribute name="xref">
2870             <xsl:value-of select="@id"/>
2871           </xsl:attribute>
2872         </xsl:if>
2873         <xsl:apply-templates select="." mode="intersect">
2874           <xsl:with-param name="PARAM" select="$PARAM"/>
2875           <xsl:with-param name="PAREN" select="$PAREN"/>
2876           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2877         </xsl:apply-templates>
2878       </m:mfenced>
2879     </xsl:when>
2880     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2881                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2882                     and not($SEM_SW=$SEM_XREF_EXT)">
2883       <xsl:apply-templates select="." mode="intersect">
2884         <xsl:with-param name="PARAM" select="$PARAM"/>
2885         <xsl:with-param name="PAREN" select="$PAREN"/>
2886         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2887       </xsl:apply-templates>
2888     </xsl:when>
2889     <xsl:otherwise>
2890       <m:mrow>
2891         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2892           <xsl:attribute name="xref">
2893             <xsl:value-of select="@id"/>
2894           </xsl:attribute>
2895         </xsl:if>
2896         <xsl:apply-templates select="." mode="intersect">
2897           <xsl:with-param name="IN_OP" select="$INTERSECT_OP"/>
2898           <xsl:with-param name="PARAM" select="$PARAM"/>
2899           <xsl:with-param name="PAREN" select="$PAREN"/>
2900           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2901         </xsl:apply-templates>
2902       </m:mrow>
2903     </xsl:otherwise>
2904   </xsl:choose>
2905 </xsl:template>
2906
2907 <xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
2908   <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
2909   <xsl:param name="PARAM" select="$NO_PARAM"/>
2910   <xsl:param name="PAREN" select="$PAR_NO"/>
2911   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2912   <xsl:apply-templates select = "*[2]" mode="semantics">
2913     <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
2914     <xsl:with-param name="PARAM" select="$PARAM"/>
2915     <xsl:with-param name="PAREN" select="$PAREN"/>
2916     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2917   </xsl:apply-templates>
2918   <xsl:for-each select = "*[position()>2]">
2919     <m:mo>
2920 <!-- HELM: xref added -->        
2921         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:intersect/@id">
2922           <xsl:attribute name="xref">
2923             <xsl:value-of select="../m:intersect/@id"/>
2924           </xsl:attribute>
2925         </xsl:if>
2926 <!-- HELM: not rendered correctly <![CDATA[&Intersection;]]> -->
2927       <xsl:text disable-output-escaping="yes">&#x22C2;</xsl:text></m:mo>
2928     <xsl:apply-templates select = "." mode="semantics">
2929       <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
2930       <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
2931       <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
2932       <xsl:with-param name="PAREN" select="$PAREN"/>
2933       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
2934     </xsl:apply-templates>
2935   </xsl:for-each>
2936 </xsl:template>
2937
2938 <xsl:template match = "m:apply[m:setdiff[1]]">
2939   <xsl:param name="IN_PREC" select="$NO_PREC"/>
2940   <xsl:param name="PARAM" select="$NO_PARAM"/>
2941   <xsl:param name="PAREN" select="$PAR_NO"/>
2942   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2943   <xsl:choose>
2944     <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC
2945                     and $PARAM=$PAR_SAME">
2946       <m:mfenced separators="">
2947         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2948           <xsl:attribute name="xref">
2949             <xsl:value-of select="@id"/>
2950           </xsl:attribute>
2951         </xsl:if>
2952         <xsl:apply-templates select="." mode="setdiff">
2953           <xsl:with-param name="PARAM" select="$PARAM"/>
2954           <xsl:with-param name="PAREN" select="$PAREN"/>
2955           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2956         </xsl:apply-templates>
2957       </m:mfenced>
2958     </xsl:when>
2959     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
2960                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
2961                     and not($SEM_SW=$SEM_XREF_EXT)">
2962       <xsl:apply-templates select="." mode="setdiff">
2963         <xsl:with-param name="PARAM" select="$PARAM"/>
2964         <xsl:with-param name="PAREN" select="$PAREN"/>
2965         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2966       </xsl:apply-templates>
2967     </xsl:when>
2968     <xsl:otherwise>
2969       <m:mrow>
2970         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
2971           <xsl:attribute name="xref">
2972             <xsl:value-of select="@id"/>
2973           </xsl:attribute>
2974         </xsl:if>
2975         <xsl:apply-templates select="." mode="setdiff">
2976           <xsl:with-param name="PARAM" select="$PARAM"/>
2977           <xsl:with-param name="PAREN" select="$PAREN"/>
2978           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2979         </xsl:apply-templates>
2980       </m:mrow>
2981     </xsl:otherwise>
2982   </xsl:choose>
2983 </xsl:template>
2984
2985 <xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
2986   <xsl:param name="PARAM" select="$NO_PARAM"/>
2987   <xsl:param name="PAREN" select="$PAR_NO"/>
2988   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
2989   <xsl:apply-templates select = "*[2]" mode = "semantics">
2990     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
2991     <xsl:with-param name="PARAM" select="$PARAM"/>
2992     <xsl:with-param name="PAREN" select="$PAREN"/>
2993     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
2994   </xsl:apply-templates>
2995   <m:mo>
2996 <!-- HELM: xref added -->        
2997         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
2998           <xsl:attribute name="xref">
2999             <xsl:value-of select="m:setdiff/@id"/>
3000           </xsl:attribute>
3001         </xsl:if>\</m:mo>
3002   <xsl:apply-templates select = "*[3]" mode = "semantics">
3003     <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
3004     <xsl:with-param name="PARAM" select="$PAR_SAME"/>
3005     <xsl:with-param name="PAREN" select="$PAREN"/>
3006     <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3007   </xsl:apply-templates>
3008 </xsl:template>
3009
3010 <xsl:template match = "m:apply[m:cartesianproduct[1]]">
3011   <xsl:param name="IN_PREC" select="$NO_PREC"/>
3012   <xsl:param name="PARAM" select="$NO_PARAM"/>
3013   <xsl:param name="PAREN" select="$PAR_NO"/>
3014   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
3015   <xsl:choose>
3016     <xsl:when test="$IN_PREC &gt; $CARTPROD_PREC or $IN_PREC=$CARTPROD_PREC
3017                     and $PARAM=$PAR_SAME">
3018       <m:mfenced separators="">
3019         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3020           <xsl:attribute name="xref">
3021             <xsl:value-of select="@id"/>
3022           </xsl:attribute>
3023         </xsl:if>
3024         <xsl:apply-templates select="." mode="cartprod">
3025           <xsl:with-param name="PARAM" select="$PARAM"/>
3026           <xsl:with-param name="PAREN" select="$PAREN"/>
3027           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3028         </xsl:apply-templates>
3029       </m:mfenced>
3030     </xsl:when>
3031     <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
3032                     and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
3033                     and not($SEM_SW=$SEM_XREF_EXT)">
3034       <xsl:apply-templates select="." mode="cartprod">
3035         <xsl:with-param name="PARAM" select="$PARAM"/>
3036         <xsl:with-param name="PAREN" select="$PAREN"/>
3037         <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3038       </xsl:apply-templates>
3039     </xsl:when>
3040     <xsl:otherwise>
3041       <m:mrow>
3042         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3043           <xsl:attribute name="xref">
3044             <xsl:value-of select="@id"/>
3045           </xsl:attribute>
3046         </xsl:if>
3047         <xsl:apply-templates select="." mode="cartprod">
3048           <xsl:with-param name="PARAM" select="$PARAM"/>
3049           <xsl:with-param name="PAREN" select="$PAREN"/>
3050           <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3051         </xsl:apply-templates>
3052       </m:mrow>
3053     </xsl:otherwise>
3054   </xsl:choose>
3055 </xsl:template>
3056
3057 <xsl:template match = "m:apply[m:cartesianproduct[1]]" mode="cartprod">
3058   <xsl:param name="PARAM" select="$NO_PARAM"/>
3059   <xsl:param name="PAREN" select="$PAR_NO"/>
3060   <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
3061   <xsl:apply-templates select = "*[2]" mode = "semantics">
3062     <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
3063     <xsl:with-param name="PARAM" select="$PARAM"/>
3064     <xsl:with-param name="PAREN" select="$PAREN"/>
3065     <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
3066   </xsl:apply-templates>
3067   <xsl:for-each select = "*[position()>2]">
3068     <m:mo>
3069 <!-- HELM: xref added -->        
3070         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:cartesianproduct/@id">
3071           <xsl:attribute name="xref">
3072             <xsl:value-of select="../m:cartesianproduct/@id"/>
3073           </xsl:attribute>
3074         </xsl:if>
3075 <!-- HELM: not rendered correctly <![CDATA[&times;]]> -->
3076      <xsl:text disable-output-escaping="yes">&#x00D7;</xsl:text></m:mo>
3077     <xsl:apply-templates select = "." mode="semantics">
3078       <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
3079       <xsl:with-param name="PARAM" select="$PAR_SAME"/>
3080       <xsl:with-param name="PAREN" select="$PAREN"/>
3081       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3082     </xsl:apply-templates>
3083   </xsl:for-each>
3084 </xsl:template>
3085
3086 <!-- HELM WARNING: card id was lost! -->
3087 <xsl:template match = "m:apply[m:card[1]]">
3088 <!-- HELM: was
3089   <m:mfenced open="|" close="|" separators=",">
3090      Now is: mrow + mo -->
3091   <m:mrow>
3092     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3093       <xsl:attribute name="xref">
3094         <xsl:value-of select="@id"/>
3095       </xsl:attribute>
3096     </xsl:if>
3097     <mo>
3098 <!-- HELM: xref added -->        
3099         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:card/@id">
3100           <xsl:attribute name="xref">
3101             <xsl:value-of select="m:card/@id"/>
3102           </xsl:attribute>
3103         </xsl:if>|</mo>
3104     <xsl:for-each select = "*[position()>1]">
3105       <xsl:apply-templates select = "." mode="semantics"/>
3106     </xsl:for-each>
3107      <mo>
3108 <!-- HELM: xref added -->        
3109         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
3110           <xsl:attribute name="xref">
3111             <xsl:value-of select="m:setdiff/@id"/>
3112           </xsl:attribute>
3113         </xsl:if>|</mo>
3114   </m:mrow>
3115 <!-- HELM:  </m:mfenced> -->
3116 </xsl:template>
3117
3118
3119 <!-- ***************** SEQUENCES AND SERIES ***************** -->
3120
3121 <xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
3122   <m:mrow>
3123     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3124       <xsl:attribute name="xref">
3125         <xsl:value-of select="@id"/>
3126       </xsl:attribute>
3127     </xsl:if>
3128     <xsl:choose>
3129       <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
3130         <m:munderover>
3131           <m:mo>
3132             <xsl:if test="*[1]=m:sum">
3133 <!-- HELM: xref added -->        
3134         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
3135           <xsl:attribute name="xref">
3136             <xsl:value-of select="m:sum/@id"/>
3137           </xsl:attribute>
3138         </xsl:if>
3139              <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
3140             </xsl:if>
3141             <xsl:if test="*[1]=m:product">
3142 <!-- HELM: xref added -->        
3143         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
3144           <xsl:attribute name="xref">
3145             <xsl:value-of select="m:product/@id"/>
3146           </xsl:attribute>
3147         </xsl:if>
3148              <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
3149             </xsl:if>
3150           </m:mo>
3151           <m:mrow>
3152             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3153             <m:mo>=</m:mo>
3154             <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
3155           </m:mrow>
3156           <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
3157         </m:munderover>
3158         <xsl:apply-templates select = "*[5]" mode = "semantics"/>
3159       </xsl:when>
3160       <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
3161         <m:munder>
3162           <m:mo>
3163             <xsl:if test="*[1]=m:sum">
3164              <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
3165             </xsl:if>
3166             <xsl:if test="*[1]=m:product">
3167              <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
3168             </xsl:if>
3169           </m:mo>
3170           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3171         </m:munder>
3172         <xsl:apply-templates select = "*[4]" mode = "semantics"/>
3173       </xsl:when>
3174       <xsl:when test="*[2]=m:domainofapplication">
3175         <m:munder>
3176           <m:mo>
3177             <xsl:if test="*[1]=m:sum">
3178 <!-- HELM: xref added -->        
3179         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
3180           <xsl:attribute name="xref">
3181             <xsl:value-of select="m:sum/@id"/>
3182           </xsl:attribute>
3183         </xsl:if>
3184 <!-- HELM: not rendered correctly <![CDATA[&Sum;]]> -->
3185               <xsl:text disable-output-escaping="yes">&#x2211;</xsl:text>
3186             </xsl:if>
3187             <xsl:if test="*[1]=m:product">
3188 <!-- HELM: xref added -->        
3189         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
3190           <xsl:attribute name="xref">
3191             <xsl:value-of select="m:product/@id"/>
3192           </xsl:attribute>
3193         </xsl:if>
3194 <!-- HELM: not rendered correctly <![CDATA[&Product;]]> -->
3195               <xsl:text disable-output-escaping="yes">&#x220F;</xsl:text>
3196             </xsl:if>
3197           </m:mo>
3198           <xsl:apply-templates select="m:domainofapplication" mode = "semantics"/>
3199         </m:munder>
3200         <m:mrow>
3201           <xsl:apply-templates select="*[position()=last()]" mode = "semantics"/>
3202           </m:mrow>
3203         </xsl:when>
3204       </xsl:choose>
3205     </m:mrow>
3206   </xsl:template>
3207   
3208 <!-- HELM: was (it didn't match with prefixed MathML)
3209 <xsl:template match="m:apply[child::*[position()=1 and name()='int']]">
3210      Now is: -->
3211 <xsl:template match="m:apply[child::*[position()=1 and self::m:int]]">
3212   <m:mrow>
3213     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3214       <xsl:attribute name="xref">
3215         <xsl:value-of select="@id"/>
3216       </xsl:attribute>
3217     </xsl:if>
3218     <xsl:choose>
3219     <xsl:when test="m:condition">
3220       <m:msub>
3221         <m:mo>
3222 <!-- HELM: xref added -->        
3223         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3224           <xsl:attribute name="xref">
3225             <xsl:value-of select="m:int/@id"/>
3226           </xsl:attribute>
3227         </xsl:if>
3228 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3229          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3230         <xsl:apply-templates select="m:condition" mode="semantics"/>
3231       </m:msub>
3232       <m:mrow>
3233         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3234       </m:mrow>
3235       <m:mrow>
3236         <m:mo>d</m:mo>
3237         <xsl:apply-templates select="m:bvar" mode="semantics"/>
3238       </m:mrow>
3239     </xsl:when>
3240     <xsl:when test="m:domainofapplication">
3241       <m:msub>
3242         <m:mo>
3243 <!-- HELM: xref added -->        
3244         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3245           <xsl:attribute name="xref">
3246             <xsl:value-of select="m:int/@id"/>
3247           </xsl:attribute>
3248         </xsl:if>
3249 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3250          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3251         <xsl:apply-templates select="m:domainofapplication" mode="semantics"/>
3252       </m:msub>
3253       <m:mrow>
3254         <xsl:apply-templates select="*[position()=last()]" mode="semantics" />
3255       </m:mrow>
3256     </xsl:when>
3257     <xsl:otherwise>
3258       <xsl:choose>
3259         <xsl:when test="m:interval">
3260           <m:msubsup>
3261             <m:mo>
3262 <!-- HELM: xref added -->        
3263         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3264           <xsl:attribute name="xref">
3265             <xsl:value-of select="m:int/@id"/>
3266           </xsl:attribute>
3267         </xsl:if>
3268 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3269              <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3270             <xsl:apply-templates select="m:interval/*[position()=1]" mode="semantics" />
3271             <xsl:apply-templates select="m:interval/*[position()=2]" mode="semantics"/>
3272           </m:msubsup>
3273           <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3274           <m:mo>d</m:mo>
3275           <xsl:apply-templates select="m:bvar" mode="semantics"/>
3276         </xsl:when>
3277         <xsl:when test="m:lowlimit">
3278         <m:msubsup>
3279           <m:mo>
3280 <!-- HELM: xref added -->        
3281         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3282           <xsl:attribute name="xref">
3283             <xsl:value-of select="m:int/@id"/>
3284           </xsl:attribute>
3285         </xsl:if>
3286 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3287            <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3288           <m:mrow><xsl:apply-templates select="m:lowlimit" mode="semantics"/></m:mrow>
3289           <m:mrow><xsl:apply-templates select="m:uplimit" mode="semantics"/></m:mrow>
3290         </m:msubsup>
3291         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3292         <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
3293       </xsl:when>
3294       <xsl:otherwise>
3295         <m:mo>
3296 <!-- HELM: xref added -->        
3297         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
3298           <xsl:attribute name="xref">
3299             <xsl:value-of select="m:int/@id"/>
3300           </xsl:attribute>
3301         </xsl:if>
3302 <!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
3303          <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
3304         <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
3305         <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
3306       </xsl:otherwise>
3307       </xsl:choose>
3308     </xsl:otherwise>
3309     </xsl:choose>
3310   </m:mrow>
3311 </xsl:template>
3312
3313 <xsl:template match = "m:apply[m:limit[1]]">
3314   <m:mrow>
3315     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3316       <xsl:attribute name="xref">
3317         <xsl:value-of select="@id"/>
3318       </xsl:attribute>
3319     </xsl:if>
3320     <m:munder>
3321       <m:mo>
3322 <!-- HELM: xref added -->        
3323         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lim/@id">
3324           <xsl:attribute name="xref">
3325             <xsl:value-of select="m:lim/@id"/>
3326           </xsl:attribute>
3327         </xsl:if>lim</m:mo>
3328       <m:mrow>
3329         <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
3330             <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3331             <m:mo><xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text></m:mo>
3332             <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3333         </xsl:if>
3334         <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
3335           <xsl:apply-templates select = "*[3]" mode = "semantics"/>
3336         </xsl:if>
3337       </m:mrow>
3338     </m:munder>
3339     <xsl:apply-templates select = "*[4]" mode = "semantics"/>
3340   </m:mrow>
3341 </xsl:template>
3342
3343
3344 <!-- ***************** TRIGONOMETRY ***************** -->
3345
3346 <xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos |
3347                        self::m:tan | self::m:sec | self::m:csc |
3348                        self::m:cot | self::m:sinh | self::m:cosh |
3349                        self::m:tanh | self::m:sech | self::m:csch |
3350                        self::m:coth | self::m:arcsin | self::m:arccos |
3351                        self::m:arctan | self::m:arcsec | self::m:arccsc | 
3352                        self::m:arccot | self::m:arcsinh | self::m:arccosh |
3353                        self::m:arctanh | self::m:arcsech | self::m:arccsch |
3354                        self::m:arccoth ] ]">
3355                         
3356   <m:mrow>
3357     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3358       <xsl:attribute name="xref">
3359         <xsl:value-of select="@id"/>
3360       </xsl:attribute>
3361     </xsl:if>
3362     <xsl:if test="not(parent::m:apply[m:power[1]])">
3363       <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
3364     </xsl:if>
3365     <xsl:if test="parent::m:apply[m:power[1]]">
3366       <m:msup>
3367         <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
3368         <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
3369       </m:msup>
3370     </xsl:if>
3371     <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
3372     <xsl:apply-templates select = "*[2]" mode = "semantics">
3373       <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
3374       <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
3375     </xsl:apply-templates>
3376   </m:mrow>
3377 </xsl:template>
3378
3379 <xsl:template match = "*" mode="trigonometry">
3380   <m:mo>
3381     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3382       <xsl:attribute name="xref">
3383         <xsl:value-of select="@id"/>
3384       </xsl:attribute>
3385     </xsl:if>
3386     <xsl:choose>
3387       <xsl:when test="self::m:sin">
3388         <xsl:value-of select="'sin'"/>
3389       </xsl:when>
3390       <xsl:when test="self::m:cos">
3391         <xsl:value-of select="'cos'"/>
3392       </xsl:when>
3393       <xsl:when test="self::m:tan">
3394         <xsl:value-of select="'tan'"/>
3395       </xsl:when>
3396       <xsl:when test="self::m:sec">
3397         <xsl:value-of select="'sec'"/>
3398       </xsl:when>
3399       <xsl:when test="self::m:csc">
3400         <xsl:value-of select="'csc'"/>
3401       </xsl:when>
3402       <xsl:when test="self::m:cot">
3403         <xsl:value-of select="'cot'"/>
3404       </xsl:when>
3405       <xsl:when test="self::m:sinh">
3406         <xsl:value-of select="'sinh'"/>
3407       </xsl:when>
3408       <xsl:when test="self::m:cosh">
3409         <xsl:value-of select="'cosh'"/>
3410       </xsl:when>
3411       <xsl:when test="self::m:tanh">
3412         <xsl:value-of select="'tanh'"/>
3413       </xsl:when>
3414       <xsl:when test="self::m:sech">
3415         <xsl:value-of select="'sech'"/>
3416       </xsl:when>
3417       <xsl:when test="self::m:csch">
3418         <xsl:value-of select="'csch'"/>
3419       </xsl:when>
3420       <xsl:when test="self::m:coth">
3421         <xsl:value-of select="'coth'"/>
3422       </xsl:when>
3423       <xsl:when test="self::m:arcsin">
3424         <xsl:value-of select="'arcsin'"/>
3425       </xsl:when>
3426       <xsl:when test="self::m:arccos">
3427         <xsl:value-of select="'arccos'"/>
3428       </xsl:when>
3429       <xsl:when test="self::m:arctan">
3430         <xsl:value-of select="'arctan'"/>
3431       </xsl:when>
3432       <xsl:when test="self::m:arcsec">
3433         <xsl:value-of select="'arcsec'"/>
3434       </xsl:when>
3435       <xsl:when test="self::m:arccsc">
3436         <xsl:value-of select="'arccsc'"/>
3437       </xsl:when>
3438       <xsl:when test="self::m:arccot">
3439         <xsl:value-of select="'arccot'"/>
3440       </xsl:when>
3441       <xsl:when test="self::m:arcsinh">
3442         <xsl:value-of select="'arcsinh'"/>
3443       </xsl:when>
3444       <xsl:when test="self::m:arccosh">
3445         <xsl:value-of select="'arccosh'"/>
3446       </xsl:when>
3447       <xsl:when test="self::m:arctanh">
3448         <xsl:value-of select="'arctanh'"/>
3449       </xsl:when>
3450       <xsl:when test="self::m:arcsech">
3451         <xsl:value-of select="'arcsech'"/>
3452       </xsl:when>
3453       <xsl:when test="self::m:arccsch">
3454         <xsl:value-of select="'arccsch'"/>
3455       </xsl:when>
3456       <xsl:when test="self::m:arccoth">
3457         <xsl:value-of select="'arccot'"/>
3458       </xsl:when>
3459     </xsl:choose>
3460   </m:mo>
3461 </xsl:template>
3462
3463
3464 <!-- ***************** STATISTICS ***************** -->
3465
3466 <!-- HELM WARNING: mean id was lost! -->
3467 <xsl:template match = "m:apply[m:mean[1]]">
3468 <!-- HELM: was
3469   <m:mfenced open="&lt;" close="&gt;" separators=",">
3470      Now is: mrow + mo + separator (mo) -->
3471   <m:mrow>
3472     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3473       <xsl:attribute name="xref">
3474         <xsl:value-of select="@id"/>
3475       </xsl:attribute>
3476     </xsl:if>
3477     <m:mo>
3478 <!-- HELM: xref added -->        
3479         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3480           <xsl:attribute name="xref">
3481             <xsl:value-of select="m:mean/@id"/>
3482           </xsl:attribute>
3483         </xsl:if>&#x003C;</m:mo>
3484     <xsl:for-each select = "*[position()>1]">
3485 <!-- HELM: if added -->
3486       <xsl:if test="position() != 1">
3487        <m:mo separator="true">,</m:mo>
3488       </xsl:if> 
3489       <xsl:apply-templates select = "." mode="semantics"/>
3490     </xsl:for-each>
3491     <m:mo>
3492 <!-- HELM: xref added -->        
3493         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3494           <xsl:attribute name="xref">
3495             <xsl:value-of select="m:mean/@id"/>
3496           </xsl:attribute>
3497         </xsl:if>&#x003E;</m:mo>
3498    </m:mrow>
3499 <!-- HELM:  </m:mfenced> -->
3500 </xsl:template>
3501
3502 <xsl:template match = "m:apply[m:sdev[1]]">
3503   <m:mrow>
3504     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3505       <xsl:attribute name="xref">
3506         <xsl:value-of select="@id"/>
3507       </xsl:attribute>
3508     </xsl:if>
3509     <m:mo>
3510 <!-- HELM: xref added -->        
3511         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sdev/@id">
3512           <xsl:attribute name="xref">
3513             <xsl:value-of select="m:sdev/@id"/>
3514           </xsl:attribute>
3515         </xsl:if>
3516      <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
3517     <m:mfenced separators=",">
3518       <xsl:for-each select = "*[position()>1]">
3519         <xsl:apply-templates select = "." mode="semantics"/>
3520       </xsl:for-each>
3521     </m:mfenced>
3522   </m:mrow>
3523 </xsl:template>
3524
3525 <xsl:template match = "m:apply[m:variance[1]]">
3526   <m:mrow>
3527     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3528       <xsl:attribute name="xref">
3529         <xsl:value-of select="@id"/>
3530       </xsl:attribute>
3531     </xsl:if>
3532     <m:mo>
3533 <!-- HELM: xref added -->        
3534         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:variance/@id">
3535           <xsl:attribute name="xref">
3536             <xsl:value-of select="m:variance/@id"/>
3537           </xsl:attribute>
3538         </xsl:if>
3539      <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
3540     <m:msup>
3541       <m:mfenced separators=",">
3542         <xsl:for-each select = "*[position()>1]">
3543           <xsl:apply-templates select = "." mode="semantics"/>
3544         </xsl:for-each>
3545       </m:mfenced>
3546       <m:mn>2</m:mn>
3547     </m:msup>
3548   </m:mrow>
3549 </xsl:template>
3550
3551 <xsl:template match = "m:apply[m:median[1]]">
3552   <m:mrow>
3553     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3554       <xsl:attribute name="xref">
3555         <xsl:value-of select="@id"/>
3556       </xsl:attribute>
3557     </xsl:if>
3558     <m:mo>
3559 <!-- HELM: xref added -->        
3560         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:median/@id">
3561           <xsl:attribute name="xref">
3562             <xsl:value-of select="m:median/@id"/>
3563           </xsl:attribute>
3564         </xsl:if>median</m:mo>
3565     <m:mfenced separators=",">
3566       <xsl:for-each select = "*[position()>1]">
3567         <xsl:apply-templates select = "." mode="semantics"/>
3568       </xsl:for-each>
3569     </m:mfenced>
3570   </m:mrow>
3571 </xsl:template>
3572
3573 <xsl:template match = "m:apply[m:mode[1]]">
3574   <m:mrow>
3575     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3576       <xsl:attribute name="xref">
3577         <xsl:value-of select="@id"/>
3578       </xsl:attribute>
3579     </xsl:if>
3580     <m:mo>
3581 <!-- HELM: xref added -->        
3582         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mode/@id">
3583           <xsl:attribute name="xref">
3584             <xsl:value-of select="m:mode/@id"/>
3585           </xsl:attribute>
3586         </xsl:if>mode</m:mo>
3587     <m:mfenced separators=",">
3588       <xsl:for-each select = "*[position()>1]">
3589         <xsl:apply-templates select = "." mode="semantics"/>
3590       </xsl:for-each>
3591     </m:mfenced>
3592   </m:mrow>
3593 </xsl:template>
3594
3595 <!-- HELM WARNING: mean id was lost! -->
3596 <xsl:template match = "m:apply[m:moment[1]]">
3597 <!-- HELM: was
3598   <m:mfenced open="&lt;" close="&gt;" separators="">
3599      Now is: mrow + mo -->
3600   <m:mrow>
3601     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3602       <xsl:attribute name="xref">
3603         <xsl:value-of select="@id"/>
3604       </xsl:attribute>
3605     </xsl:if>
3606     <m:mo>
3607 <!-- HELM: xref added -->        
3608         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:moment/@id">
3609           <xsl:attribute name="xref">
3610             <xsl:value-of select="m:momemt/@id"/>
3611           </xsl:attribute>
3612         </xsl:if>&#x003C;</m:mo>
3613     <xsl:if test="*[2]=m:degree and not(*[3]=m:momentabout)">
3614       <m:msup>
3615         <xsl:apply-templates select="*[3]" mode = "semantics"/>
3616           <xsl:apply-templates select="*[2]" mode = "semantics"/>
3617           </m:msup>
3618         </xsl:if>
3619         <xsl:if test="*[2]=m:degree and *[3]=m:momentabout">
3620           <m:msup>
3621             <xsl:apply-templates select="*[4]" mode = "semantics"/>
3622             <xsl:apply-templates select="*[2]" mode = "semantics"/>
3623       </m:msup>  
3624     </xsl:if>
3625     <xsl:if test="not(*[2]=m:degree) and *[2]=m:momentabout">
3626        <xsl:for-each select = "*[position()>2]">
3627         <xsl:apply-templates select = "." mode="semantics"/>
3628       </xsl:for-each>
3629     </xsl:if>
3630     <xsl:if test="not(*[2]=m:degree) and not(*[2]=m:momentabout)">
3631       <xsl:for-each select = "*[position()>1]">
3632         <xsl:apply-templates select = "." mode="semantics"/>
3633       </xsl:for-each>
3634     </xsl:if>
3635     <m:mo>
3636 <!-- HELM: xref added -->        
3637         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
3638           <xsl:attribute name="xref">
3639             <xsl:value-of select="m:mean/@id"/>
3640           </xsl:attribute>
3641         </xsl:if>&#x003E;</m:mo>
3642   </m:mrow>
3643 <!-- HELM:  </m:mfenced> -->
3644 </xsl:template>
3645
3646
3647 <!-- ***************** LINEAR ALGEBRA ***************** -->
3648
3649 <xsl:template match="m:vector">
3650   <m:mfenced separators="">
3651     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3652       <xsl:attribute name="xref">
3653         <xsl:value-of select="@id"/>
3654       </xsl:attribute>
3655     </xsl:if>
3656     <m:mtable>
3657       <xsl:for-each select="*">
3658         <m:mtd>
3659           <xsl:apply-templates select="." mode = "semantics"/>
3660         </m:mtd>
3661       </xsl:for-each>
3662     </m:mtable>
3663   </m:mfenced>
3664 </xsl:template>
3665
3666 <xsl:template match = "m:matrix">
3667   <m:mfenced separators="">
3668     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3669       <xsl:attribute name="xref">
3670         <xsl:value-of select="@id"/>
3671       </xsl:attribute>
3672     </xsl:if>
3673     <m:mtable>
3674       <xsl:apply-templates select="*" mode = "semantics"/>
3675     </m:mtable>
3676   </m:mfenced>
3677 </xsl:template>
3678
3679 <xsl:template match = "m:matrixrow">
3680   <m:mtr>
3681     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3682       <xsl:attribute name="xref">
3683         <xsl:value-of select="@id"/>
3684       </xsl:attribute>
3685     </xsl:if>
3686     <xsl:for-each select="*">
3687       <m:mtd>
3688         <xsl:apply-templates select="." mode = "semantics"/>
3689       </m:mtd>
3690     </xsl:for-each>
3691   </m:mtr>
3692 </xsl:template>
3693
3694 <xsl:template match = "m:apply[m:determinant[1]]">
3695   <m:mrow>
3696     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3697       <xsl:attribute name="xref">
3698         <xsl:value-of select="@id"/>
3699       </xsl:attribute>
3700     </xsl:if>
3701     <m:mo>
3702 <!-- HELM: xref added -->        
3703         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:determinant/@id">
3704           <xsl:attribute name="xref">
3705             <xsl:value-of select="m:determinant/@id"/>
3706           </xsl:attribute>
3707         </xsl:if>det</m:mo>
3708     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3709   </m:mrow>
3710 </xsl:template>
3711
3712 <xsl:template match = "m:apply[m:transpose[1]]">
3713   <m:msup>
3714     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3715       <xsl:attribute name="xref">
3716         <xsl:value-of select="@id"/>
3717       </xsl:attribute>
3718     </xsl:if>
3719     <xsl:apply-templates select = "*[2]" mode = "semantics"/>
3720     <m:mo>
3721 <!-- HELM: xref added -->        
3722         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:transpose/@id">
3723           <xsl:attribute name="xref">
3724             <xsl:value-of select="m:transpose/@id"/>
3725           </xsl:attribute>
3726         </xsl:if>T</m:mo>
3727   </m:msup>
3728 </xsl:template>
3729
3730 <!-- HELM: ERROR, this template generates the selected content elements
3731      and doesn't generate the presentation for selector                 -->
3732 <!--<xsl:template match = "m:apply[m:selector[1]]">
3733   <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
3734       <xsl:variable name="m" select = "*[3]"/>
3735       <xsl:choose>
3736         <xsl:when test="*[4]=m:cn">
3737           <xsl:variable name="n" select = "*[4]"/>
3738           <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
3739         </xsl:when>
3740         <xsl:otherwise>
3741           <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
3742         </xsl:otherwise>
3743       </xsl:choose>
3744   </xsl:if>
3745   <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
3746     <xsl:variable name="m" select = "*[3]"/>
3747     <xsl:copy-of select = "*[2]/*[position()=$m]"/>
3748   </xsl:if>
3749 </xsl:template> -->
3750
3751 <xsl:template match = "m:apply[m:selector[1]]">
3752    <msub>
3753     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3754      <xsl:attribute name="xref">
3755       <xsl:value-of select="@id"/>
3756      </xsl:attribute>
3757     </xsl:if> 
3758     <xsl:apply-templates select = "*[2]" mode="semantics"/>
3759     <m:mrow>
3760      <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:selector/@id">
3761       <xsl:attribute name="xref">
3762        <xsl:value-of select="m:selector/@id"/>
3763       </xsl:attribute>
3764      </xsl:if>
3765      <xsl:choose>
3766      <xsl:when test="*[3]=m:cn">
3767       <xsl:apply-templates select = "*[3]" mode="semantics"/>
3768      </xsl:when>
3769      <xsl:otherwise>
3770       <m:mi>*</m:mi>
3771      </xsl:otherwise>
3772      </xsl:choose> 
3773      <xsl:if test="*[2]=m:matrix and *[4]=m:cn">
3774       <xsl:apply-templates select = "*[4]" mode="semantics"/>
3775      </xsl:if>
3776     </m:mrow>
3777    </msub>
3778 </xsl:template>
3779
3780 <xsl:template match = "m:apply[m:vectorproduct[1] |
3781                                  m:scalarproduct[1] | m:outerproduct[1]]">
3782   <m:mrow>
3783     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
3784       <xsl:attribute name="xref">
3785         <xsl:value-of select="@id"/>
3786       </xsl:attribute>
3787     </xsl:if>
3788     <xsl:apply-templates select="*[2]" mode = "semantics"/>
3789     <m:mo>
3790       <xsl:if test="m:vectorproduct[1]">
3791 <!-- HELM: xref added -->        
3792         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:vectorproduct/@id">
3793           <xsl:attribute name="xref">
3794             <xsl:value-of select="m:vectorproduct/@id"/>
3795           </xsl:attribute>
3796         </xsl:if>
3797        <xsl:text disable-output-escaping='yes'>&#x2A2F;</xsl:text>
3798       </xsl:if>
3799       <xsl:if test="m:scalarproduct[1] | m:outerproduct[1]">
3800 <!-- HELM: xref added -->        
3801         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and *[1]/@id">
3802           <xsl:attribute name="xref">
3803             <xsl:value-of select="*[1]/@id"/>
3804           </xsl:attribute>
3805         </xsl:if>           
3806         <xsl:value-of select="'.'"/>
3807       </xsl:if>
3808     </m:mo>
3809     <xsl:apply-templates select="*[3]" mode = "semantics"/>
3810   </m:mrow>
3811 </xsl:template>
3812
3813
3814 <!-- ***************** CONSTANT and SYMBOL ELEMENTS ***************** -->
3815
3816 <xsl:template match="m:integers">
3817    <m:mi>
3818 <!-- HELM: xref added -->        
3819         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:integers/@id">
3820           <xsl:attribute name="xref">
3821             <xsl:value-of select="m:integers/@id"/>
3822           </xsl:attribute>
3823         </xsl:if>
3824     <xsl:text disable-output-escaping='yes'>&#x2124;</xsl:text></m:mi>
3825 </xsl:template>
3826
3827 <xsl:template match="m:reals">
3828    <m:mi>
3829 <!-- HELM: xref added -->        
3830         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:reals/@id">
3831           <xsl:attribute name="xref">
3832             <xsl:value-of select="m:reals/@id"/>
3833           </xsl:attribute>
3834         </xsl:if>
3835     <xsl:text disable-output-escaping='yes'>&#x211D;</xsl:text></m:mi>
3836 </xsl:template>
3837
3838 <xsl:template match="m:rationals">
3839   <m:mi>
3840 <!-- HELM: xref added -->        
3841         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rationals/@id">
3842           <xsl:attribute name="xref">
3843             <xsl:value-of select="m:rationals/@id"/>
3844           </xsl:attribute>
3845         </xsl:if>
3846    <xsl:text disable-output-escaping='yes'>&#x211A;</xsl:text></m:mi>
3847 </xsl:template>
3848
3849 <xsl:template match="m:naturalnumbers">
3850   <m:mi>
3851 <!-- HELM: xref added -->        
3852         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:naturalnumbers/@id">
3853           <xsl:attribute name="xref">
3854             <xsl:value-of select="m:naturalnumbers/@id"/>
3855           </xsl:attribute>
3856         </xsl:if>
3857    <xsl:text disable-output-escaping='yes'>&#x2115;</xsl:text></m:mi> 
3858 </xsl:template>
3859
3860 <xsl:template match="m:complexes">
3861   <m:mi>
3862 <!-- HELM: xref added -->        
3863         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:complexes/@id">
3864           <xsl:attribute name="xref">
3865             <xsl:value-of select="m:complexes/@id"/>
3866           </xsl:attribute>
3867         </xsl:if>
3868    <xsl:text disable-output-escaping='yes'>&#x2102;</xsl:text></m:mi>
3869 </xsl:template>
3870
3871 <xsl:template match="m:primes">
3872   <m:mi>
3873 <!-- HELM: xref added -->        
3874         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:primes/@id">
3875           <xsl:attribute name="xref">
3876             <xsl:value-of select="m:primes/@id"/>
3877           </xsl:attribute>
3878         </xsl:if>
3879    <xsl:text disable-output-escaping='yes'>&#x2119;</xsl:text></m:mi>
3880 </xsl:template>
3881
3882 <xsl:template match="m:exponentiale">
3883   <m:mi>
3884 <!-- HELM: xref added -->        
3885         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exponentiale/@id">
3886           <xsl:attribute name="xref">
3887             <xsl:value-of select="m:exponentiale/@id"/>
3888           </xsl:attribute>
3889         </xsl:if>
3890    <xsl:text disable-output-escaping="yes">&#x2147;</xsl:text></m:mi>
3891 </xsl:template>
3892
3893 <xsl:template match="m:imaginaryi">
3894   <m:mi>
3895 <!-- HELM: xref added -->        
3896         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginaryi/@id">
3897           <xsl:attribute name="xref">
3898             <xsl:value-of select="m:imaginaryi/@id"/>
3899           </xsl:attribute>
3900         </xsl:if>
3901 <!-- HELM: not rendered correctly <![CDATA[&ImaginaryI;]]> -->
3902    <xsl:text disable-output-escaping="yes">&#xF74E;</xsl:text></m:mi>
3903 </xsl:template>
3904
3905 <xsl:template match="m:notanumber">
3906   <m:mi>
3907 <!-- HELM: xref added -->        
3908         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notanumber/@id">
3909           <xsl:attribute name="xref">
3910             <xsl:value-of select="m:notanumber/@id"/>
3911           </xsl:attribute>
3912         </xsl:if>NaN</m:mi>  
3913 </xsl:template>
3914
3915 <xsl:template match="m:true">
3916   <m:mi>
3917 <!-- HELM: xref added -->        
3918         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:true/@id">
3919           <xsl:attribute name="xref">
3920             <xsl:value-of select="m:true/@id"/>
3921           </xsl:attribute>
3922         </xsl:if>true</m:mi>  
3923 </xsl:template>
3924
3925 <xsl:template match="m:false">
3926   <m:mi>
3927 <!-- HELM: xref added -->        
3928         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:false/@id">
3929           <xsl:attribute name="xref">
3930             <xsl:value-of select="m:false/@id"/>
3931           </xsl:attribute>
3932         </xsl:if>false</m:mi>   
3933 </xsl:template>
3934
3935 <xsl:template match="m:emptyset">
3936   <m:mi>
3937 <!-- HELM: xref added -->        
3938         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:emptyset/@id">
3939           <xsl:attribute name="xref">
3940             <xsl:value-of select="m:emptyset/@id"/>
3941           </xsl:attribute>
3942         </xsl:if>
3943 <!-- HELM: not rendered correctly <![CDATA[&empty;]]> -->
3944    <xsl:text disable-output-escaping="yes">&#xE2D3;</xsl:text></m:mi>
3945 </xsl:template>
3946
3947 <xsl:template match="m:pi">
3948   <m:mi>
3949 <!-- HELM: xref added -->        
3950         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:pi/@id">
3951           <xsl:attribute name="xref">
3952             <xsl:value-of select="m:pi/@id"/>
3953           </xsl:attribute>
3954         </xsl:if>
3955 <!-- HELM: not rendered correctly <![CDATA[&pi;]]> -->
3956    <xsl:text disable-output-escaping="yes">&#x03C0;</xsl:text></m:mi>
3957 </xsl:template>
3958
3959 <xsl:template match="m:eulergamma">
3960   <m:mi>
3961 <!-- HELM: xref added -->        
3962         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:eulergamma/@id">
3963           <xsl:attribute name="xref">
3964             <xsl:value-of select="m:eulergamma/@id"/>
3965           </xsl:attribute>
3966         </xsl:if>
3967 <!-- HELM: not rendered correctly <![CDATA[&gamma;]]> -->
3968    <xsl:text disable-output-escaping="yes">&#x03B3;</xsl:text></m:mi>
3969 </xsl:template>
3970
3971 <xsl:template match="m:infinity">
3972   <m:mi>
3973 <!-- HELM: xref added -->        
3974         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:infinity/@id">
3975           <xsl:attribute name="xref">
3976             <xsl:value-of select="m:infinity/@id"/>
3977           </xsl:attribute>
3978         </xsl:if>
3979 <!-- HELM: not rendered correctly <![CDATA[&infin;]]> -->
3980    <xsl:text disable-output-escaping="yes">&#x221E;</xsl:text></m:mi>
3981 </xsl:template>
3982
3983 </xsl:stylesheet>
3984
3985