]> matita.cs.unibo.it Git - helm.git/commitdiff
Modified Files:
authorIrene Schena <irene.schena@unibo.it>
Mon, 15 Apr 2002 16:17:20 +0000 (16:17 +0000)
committerIrene Schena <irene.schena@unibo.it>
Mon, 15 Apr 2002 16:17:20 +0000 (16:17 +0000)
1) mmlnotation.xsl xslt_index.txt: MathML default presentation now is
   generated by mmlctop.xsl
Added Files:
1) mmlctop.xsl mmlctop2_0.xsl: link and new Igor stylesheet for MathML default
   presentation

helm/style/mmlctop.xsl [new file with mode: 0644]
helm/style/mmlctop2_0.xsl [new file with mode: 0644]
helm/style/mmlnotation.xsl
helm/style/xslt_index.txt

diff --git a/helm/style/mmlctop.xsl b/helm/style/mmlctop.xsl
new file mode 100644 (file)
index 0000000..0a0e454
--- /dev/null
@@ -0,0 +1,3982 @@
+<?xml version="1.0"?>
+
+<!-- ******************************************************** -->
+<!--   XSL Transform of MathML content to MathML presentation -->
+<!--                                                          -->
+<!--   Authors Igor Rodionov <igor@csd.uwo.ca>,               -->
+<!--           Stephen Watt  <watt@csd.uwo.ca>.               -->  
+<!--                                                          -->
+<!--   (C) Copyright 2000  Symbolic Computation Laboratory,   -->
+<!--                       University of Western Ontario,     -->
+<!--                       London, Canada N6A 5B7.            -->
+<!--                                                          -->
+<!-- ******************************************************** -->
+<!--   Updated Nov. 2001 by:                                  -->
+<!--           S. Huerter <huerter@csd.uwo.ca>.               -->
+<!--                                                          -->
+<!--   Complies with the W3C MathML 2.0 Recommendation of     -->
+<!--   21 February 2001.                                      -->
+<!-- ******************************************************** -->
+
+<!-- ====================================================== -->
+<!--  April, 10 2002 - HELM group:                          -->
+<!--  Added the namespace prefix to all the output elements -->
+<!--  Changed the mml prefix into m                         -->
+<!--  Added xref to every mo element                        -->
+<!--  New csymbol template                                  -->
+<!--  reln is not supported                                 -->
+<!--  First draft: April 10 2002, Irene Schena              -->
+<!-- ====================================================== -->
+
+<xsl:stylesheet id="mmlctop.xsl"
+                version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!-- HELM: we don't have a default namespace.
+     Removed xmlns="http://www.w3.org/1998/Math/MathML" -->
+
+<!-- HELM: was
+<xsl:output method="xml" indent="yes"/>
+-->
+<xsl:output method="xml"/>
+
+<xsl:strip-space elements="apply semantics annotation-xml
+        csymbol fn cn ci interval matrix matrixrow vector
+        lambda bvar condition logbase degree set list
+        lowlimit uplimit"/>
+
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!--         Parameters, variables and constants           -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+<!-- ~~~~~~~~ Semantics related *constants*: ~~~~~~~~ -->
+
+<!-- Strip off semantics -->
+<xsl:variable name="SEM_STRIP" select="-1"/>
+
+<!-- Pass semantics "as is" -->
+<xsl:variable name="SEM_PASS" select="0"/>
+
+<!-- Add semantics at top level only -->
+<xsl:variable name="SEM_TOP" select="1"/>
+
+<!-- Add semantics at all levels -->
+<xsl:variable name="SEM_ALL" select="2"/>
+
+<!-- Semantics at top level only, with id refs -->
+<!-- NOTE: ids have to be already present in the
+           input for this feature to work. -->
+<xsl:variable name="SEM_XREF" select="3"/>
+
+<!-- No semantics at top level, with id refs -->
+<!-- NOTE: ids have to be already present in the
+           input for this feature to work. -->
+<xsl:variable name="SEM_XREF_EXT" select="4"/>
+
+
+<!-- ~~~~~~~~~~ Stylesheet *parameter*: SEM_SW ~~~~~~~~~~~~~~ -->
+<!-- Assumes one of the above values; SEM_PASS is the default -->
+<!-- The default can be overridden by specifying different    -->
+<!-- value on the command line when the stylesheet is invoked -->
+
+<!-- HELM: $SEM_SW was SEM_PASS (error!) -->
+<xsl:param name="SEM_SW" select="$SEM_XREF"/>
+
+
+<!-- ~~~~~~ Operator precedence definitions ~~~~~~ -->
+<xsl:variable name="UNION_OP" select="2"/>
+<xsl:variable name="INTERSECT_OP" select="6"/>
+<xsl:variable name="SETDIFF_OP" select="4"/>
+<xsl:variable name="NO_PREC" select="0"/>
+<xsl:variable name="UNION_PREC" select="1"/>
+<xsl:variable name="SETDIFF_PREC" select="1"/>
+<xsl:variable name="INTERSECT_PREC" select="3"/>
+<xsl:variable name="CARTPROD_PREC" select="3"/>
+<xsl:variable name="OR_PREC" select="5"/>
+<xsl:variable name="XOR_PREC" select="5"/>
+<xsl:variable name="AND_PREC" select="7"/>
+<xsl:variable name="PLUS_PREC" select="9"/>
+<xsl:variable name="MINUS_PREC" select="9"/>
+<xsl:variable name="MUL_PREC" select="11"/>
+<xsl:variable name="DIV_PREC" select="11"/>
+<xsl:variable name="NEG_PREC" select="13"/>
+<xsl:variable name="FUNCTION_PREC" select="99"/>
+
+<!-- ~~~~~ Miscellaneous constant definitions ~~~~~ -->
+
+<xsl:variable name="YES" select="1"/>
+<xsl:variable name="NO" select="0"/>
+<xsl:variable name="NO_PARAM" select="-1"/>
+<xsl:variable name="PAR_SAME" select="-3"/>
+<xsl:variable name="PAR_YES" select="-5"/>
+<xsl:variable name="PAR_NO" select="-7"/>
+<xsl:variable name="DOESNT_MATTER" select="-9"/>
+
+<!-- +++++++++++++++++ INDEX OF TEMPLATES +++++++++++++++++++ -->
+
+<!-- All templates are subdivided into the following categories
+     (listed in the order of appearance in the stylesheet):
+
+THE TOPMOST ELEMENT: MATH
+ math
+
+SEMANTICS HANDLING
+ semantics
+
+BASIC CONTAINER ELEMENTS
+ cn, ci, csymbol
+
+BASIC CONTENT ELEMENTS
+ fn, interval, inverse, sep, condition, declare, lambda, compose, ident
+
+     *NEW: apply, piecewise, domain, codomain, image
+
+ARITHMETIC, ALGEBRA & LOGIC
+ quotient, exp, factorial, max, min, minus, plus, power, rem, divide,
+ times, root, gcd, and, or, xor, not, forall, exists, abs, conjugate,
+ arg, real, imaginary
+
+     *NEW: floor, ceiling, lcm
+
+RELATIONS
+ neq, approx, tendsto, implies, in, notin, notsubset, notprsubset,
+ subset, prsubset, eq, gt, lt, geq, leq, equivalent
+
+CALCULUS
+ ln, log, diff, partialdiff, lowlimit, uplimit, bvar, degree,
+ logbase, divergence, grad, curl, laplacian
+
+SET THEORY
+ set, list, union, intersect, setdiff, card
+
+     *NEW: cartesianproduct
+
+SEQUENCES AND SERIES
+ sum, product, limit
+
+     *NEW: int
+
+TRIGONOMETRY
+ sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth,
+ arcsin, arccos, arctan
+
+     *NEW: arcsec, arccsc, arccot, arcsinh, arccosh, arctanh,
+           arcsech, arccsch, arccoth, 
+
+STATISTICS
+ mean, sdev, variance, median, mode, moment
+
+LINEAR ALGEBRA
+ vector, matrix, matrixrow, determinant, transpose, selector,
+ vectorproduct, scalarproduct, outerproduct
+-->
+
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+
+<!-- ***************** THE TOPMOST ELEMENT: MATH ***************** -->
+
+<xsl:template match = "m:math">
+<!-- HELM:  <m:math> -->
+  <xsl:choose>
+    <xsl:when test="$SEM_SW=$SEM_TOP or $SEM_SW=$SEM_ALL and *[2] or $SEM_SW=$SEM_XREF">             <m:semantics>                                                       
+    <m:mrow>                                                         
+          <xsl:apply-templates mode = "semantics"/>
+        </m:mrow>
+        <m:annotation-xml encoding="MathML">
+          <xsl:copy-of select="*"/>
+        </m:annotation-xml>
+      </m:semantics>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mrow>  
+    </xsl:otherwise>
+  </xsl:choose>
+<!-- HELM: </m:math> -->
+</xsl:template>
+
+
+<!-- ***************** SEMANTICS HANDLING ***************** -->
+
+<!-- This template is called recursively.  At each level   -->
+<!-- in the source tree it decides whether to strip off,   -->
+<!-- pass or add semantics at that level (depending on the -->
+<!-- value of SEM_SW parameter).  Then the actual template -->
+<!-- is applied to the node.                               -->
+
+<xsl:template match = "m:*" mode = "semantics">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$SEM_SW=$SEM_STRIP and self::m:semantics">
+      <xsl:apply-templates select="m:annotation-xml[@encoding='MathML']">
+        <xsl:with-param name="IN_OP" select="$IN_OP"/>
+        <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="($SEM_SW=$SEM_PASS or $SEM_SW=$SEM_TOP) and self::m:semantics">
+      <m:semantics>
+        <xsl:apply-templates select="*[1]">   
+        <xsl:with-param name="IN_OP" select="$IN_OP"/>
+        <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+        <xsl:copy-of select="m:annotation-xml"/>
+      </m:semantics>
+    </xsl:when>
+    <xsl:when test="$SEM_SW=$SEM_ALL">
+      <m:semantics>
+        <xsl:choose>
+          <xsl:when test="self::m:semantics">
+            <xsl:apply-templates select="*[1]">
+              <xsl:with-param name="IN_OP" select="$IN_OP"/>
+              <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+              <xsl:with-param name="PARAM" select="$PARAM"/>
+              <xsl:with-param name="PAREN" select="$PAREN"/>
+              <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+            </xsl:apply-templates>
+            <xsl:copy-of select="m:annotation-xml"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select=".">
+              <xsl:with-param name="IN_OP" select="$IN_OP"/>
+              <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+              <xsl:with-param name="PARAM" select="$PARAM"/>
+              <xsl:with-param name="PAREN" select="$PAREN"/>
+              <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+            </xsl:apply-templates>
+            <m:annotation-xml encoding="MathML">
+              <xsl:copy-of select="."/>
+            </m:annotation-xml>
+          </xsl:otherwise>
+        </xsl:choose>
+      </m:semantics>
+    </xsl:when>
+    <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:choose>
+<!-- HELM: syntax error, was sematics -->
+        <xsl:when test="self::m:semantics">
+          <xsl:copy>
+            <xsl:copy-of select="@*"/>
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+            <xsl:copy-of select="*[1]"/>
+            <xsl:copy-of select="m:annotation-xml"/>
+          </xsl:copy>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select=".">
+            <xsl:with-param name="IN_OP" select="$IN_OP"/>
+            <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+            <xsl:with-param name="PARAM" select="$PARAM"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="self::m:semantics">
+          <xsl:copy-of select="."/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select=".">
+            <xsl:with-param name="IN_OP" select="$IN_OP"/>
+            <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+            <xsl:with-param name="PARAM" select="$PARAM"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:semantics">
+  <xsl:apply-templates select="." mode = "semantics"/>
+</xsl:template>
+
+
+<!-- ***************** BASIC CONTAINER ELEMENTS ***************** -->
+
+<xsl:template match = "m:cn">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test=". &lt; 0 and $IN_PREC &gt; $NO_PREC and $PAREN=$PAR_NO
+                                                   and $PAR_NO_IGNORE=$NO">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cn"/>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:apply-templates select="." mode="cnid"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="." mode="cn"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- HELM: the entity &#x2062; is not defined -->
+<xsl:template match = "m:cn" mode="cn">
+  <xsl:choose>
+    <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+      <m:msub>
+        <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='e-notation' and not(@base) and child::m:sep[1]">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mo>e</m:mo>
+        <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+  </xsl:when>
+    <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+      <m:mfenced separators="">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <xsl:if test="text()[2] &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+        </xsl:if>
+        <xsl:if test="not(text()[2] &lt; 0)">
+          <m:mo>+</m:mo>
+          <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+        </xsl:if>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mo>i</m:mo>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mfenced separators="">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <xsl:if test="text()[2] &lt; 0">
+            <m:mo>-</m:mo>
+            <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+          </xsl:if>
+          <xsl:if test="not(text()[2] &lt; 0)">
+            <m:mo>+</m:mo>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </xsl:if>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+          <m:mo>i</m:mo>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+      <m:mfrac>
+        <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+        <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+      </m:mfrac>
+    </xsl:when>
+    <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mfenced>
+          <m:mfrac>
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfrac>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+      <m:mrow>
+        <m:mo>Polar</m:mo>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mfenced separators=",">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mrow>
+          <m:mo>Polar</m:mo>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+          <m:mfenced separators=",">
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfenced>
+        </m:mrow>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+   </xsl:when>
+    <xsl:otherwise>
+<!-- HELM: cn could contain MathML presentation -->
+<!-- HELM: was
+      <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     Now is: -->
+    <xsl:choose>
+     <xsl:when test="child::text() and not(*[1])">
+      <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:choose>
+       <xsl:when test="not(*[2])">
+        <xsl:copy-of select="*[1]"/>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mrow>
+         <xsl:copy-of select="*|text()"/>
+        </m:mrow>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:otherwise>
+    </xsl:choose>
+<!-- HELM -->
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:cn" mode="cnid">
+  <xsl:choose>
+    <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+      <m:msub xref="{@id}">
+        <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+      <m:mfenced separators="" xref="{@id}">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <xsl:if test="text()[2] &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+        </xsl:if>
+        <xsl:if test="not(text()[2] &lt; 0)">
+          <m:mo>+</m:mo>
+          <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+        </xsl:if>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+        <m:mo>i</m:mo>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mfenced separators="">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <xsl:if test="text()[2] &lt; 0">
+            <m:mo>-</m:mo>
+            <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+          </xsl:if>
+          <xsl:if test="not(text()[2] &lt; 0)">
+            <m:mo>+</m:mo>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </xsl:if>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+          <m:mo>i</m:mo>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+      <m:mfrac xref="{@id}">
+        <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+        <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+      </m:mfrac>
+    </xsl:when>
+    <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mfenced>
+          <m:mfrac>
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfrac>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+      <m:mrow xref="{@id}">
+        <m:mo>Polar</m:mo>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mfenced separators=",">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mrow>
+          <m:mo>Polar</m:mo>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+          <m:mfenced separators=",">
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfenced>
+        </m:mrow>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+   </xsl:when>
+    <xsl:otherwise>
+<!-- HELM: cn could contain MathML presentation -->
+<!-- HELM: was
+      <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     Now is: -->
+    <xsl:choose>
+     <xsl:when test="child::text() and not(*[1])">
+      <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:variable name="id" select="@id"/>
+      <xsl:choose>
+       <xsl:when test="not(*[2])">
+        <xsl:for-each select="*[1]">
+         <xsl:copy>
+          <xsl:attribute name="xref">
+           <xsl:value-of select="$id"/>
+          </xsl:attribute>
+          <xsl:copy-of select="@*|*"/>
+         </xsl:copy>
+        </xsl:for-each>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mrow xref="{$id}">
+         <xsl:copy-of select="*|text()"/>
+        </m:mrow>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:otherwise>
+    </xsl:choose>
+<!-- HELM -->
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci">
+  <xsl:choose>
+    <xsl:when test="@type='vector' or @type=matrix or @type=set">
+      <m:mi mathvariant="bold">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mi>
+    </xsl:when>
+    <xsl:when test="child::text() and not(child::*[1])">
+      <m:mi>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: ERROR, added mode="semantics", it didn't generate identifiers -->
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mi>
+    </xsl:when>
+<!-- HELM: text & markup !!! Not compliant with the specification -->
+    <xsl:when test="child::text() and *[1] and not(*[1]=m:sep)">
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: added semantics mode -->
+        <xsl:apply-templates mode="semantics"/>
+      </m:mrow>
+    </xsl:when>
+<!-- HELM -->
+    <xsl:otherwise>
+      <xsl:if test="*[2]">
+        <m:mrow>
+          <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+          </xsl:if>
+          <xsl:apply-templates select="*"/>
+        </m:mrow>
+      </xsl:if>
+      <xsl:if test="not(*[2])">
+<!-- HELM: ci could contain MathML presentation -->
+<!-- HELM: was
+        <xsl:apply-templates select="*[1]"/>
+     Now is: -->
+       <xsl:variable name="id" select="@id"/>
+        <xsl:for-each select="*[1]">
+         <xsl:copy>
+          <xsl:attribute name="xref">
+           <xsl:value-of select="$id"/>
+          </xsl:attribute>
+         <xsl:copy-of select="@*|*"/>
+         </xsl:copy>
+        </xsl:for-each>
+<!-- HELM -->
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci/m:*[not(self::m:sep)]">
+  <xsl:copy-of select = "."/>
+</xsl:template>
+
+<!-- HELM: revised version previous Version x.xx from Feb. 18, 2000 -->
+<xsl:template match = "m:csymbol">
+<!-- HELM: mrow to maintain csymbol id -->
+   <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+     <xsl:attribute name="xref">
+      <xsl:value-of select="@id"/>
+     </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select="* and text()">
+     <xsl:choose>
+     <xsl:when test="text()">
+      <m:mo><xsl:value-of select="."/></m:mo>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:copy-of select = "."/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:for-each>
+   </m:mrow>
+</xsl:template>
+
+<!-- HELM: csymbol cannot contain ci or cn elements, but only text and/or 
+presentation elements. PCDATA should render as if it were wrapped in 
+an mo. Mixed content: mrow which contains mo + presentation elements --> 
+<!-- <xsl:template match = "m:csymbol/m:*">
+  <xsl:choose>
+    <xsl:when test="self::m:cn or self::m:ci">
+      <xsl:apply-templates mode = "semantics"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select = "."/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:csymbol/text()">
+  <xsl:choose>
+    <xsl:when test=". &lt; 0 or . = 0 or . &gt; 0">
+      <m:mn> <xsl:copy-of select = "."/> </m:mn>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mi> <xsl:copy-of select = "."/> </m:mi>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template> -->
+
+
+<!-- ***************** BASIC CONTENT ELEMENTS ***************** -->
+
+<!-- HELM: the entity &#x2061; is not defined:                -->
+<!-- fn and domainofapplication are rendered as their content -->
+<xsl:template match = "m:apply[m:*[1][self::m:fn]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:fn/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:fn/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- fn has been deprecated, so now we use: -->
+<xsl:template match = "m:apply">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:domainofapplication">
+        <m:msub>
+          <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          </xsl:apply-templates>
+          <xsl:apply-templates select = "*[position()=2]" mode = "semantics"/>
+          </m:msub>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:domainofapplication/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:domainofapplication/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+          <m:mfenced separators=",">
+            <xsl:apply-templates select = "*[position()>2]" mode = "semantics"/>
+            </m:mfenced>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
+              <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+            </xsl:apply-templates>
+            <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+            <m:mfenced separators=",">
+              <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+              </m:mfenced> 
+            </xsl:otherwise>
+          </xsl:choose>
+        </m:mrow>
+      </xsl:template>
+      
+      <xsl:template match = "m:domainofapplication">
+        <xsl:apply-templates select = "*[1]" mode = "semantics"/> 
+        </xsl:template>
+    
+      <xsl:template match = "m:fn">
+        <xsl:apply-templates select = "*[1]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        </xsl:apply-templates>
+      </xsl:template>
+      
+      <xsl:template match = "m:interval">
+        <m:mfenced separators=",">
+          <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+          </xsl:if>
+          <xsl:if test="@closure='closed' or @closure='closed-open'">
+            <xsl:attribute name="open">[</xsl:attribute>
+          </xsl:if>
+          <xsl:if test="@closure='closed' or @closure='open-closed'">
+            <xsl:attribute name="close">]</xsl:attribute>
+          </xsl:if>
+          <xsl:apply-templates select="*" mode = "semantics"/>
+          </m:mfenced>
+        </xsl:template>
+        
+        <xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
+          <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:inverse]]">
+  <xsl:choose>
+    <xsl:when test="*[2]=m:exp or *[2]=m:ln or *[2]=m:sin or *[2]=m:cos or
+                    *[2]=m:tan or *[2]=m:sec or *[2]=m:csc or *[2]=m:cot or
+                    *[2]=m:sinh or *[2]=m:cosh or *[2]=m:tanh or *[2]=m:sech or
+                    *[2]=m:csch or *[2]=m:coth or *[2]=m:arcsin or
+                    *[2]=m:arccos or *[2]=m:arctan">
+      <m:mo>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode="inverse"/>
+      </m:mo>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:msup>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select = "*[2]"/>
+        <m:mfenced>
+<!-- HELM: xref added -->        
+         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:inverse/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:inverse/@id"/>
+          </xsl:attribute>
+         </xsl:if>
+         <m:mn>-1</m:mn>
+        </m:mfenced>
+      </m:msup>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "*" mode="inverse">
+  <xsl:choose>
+    <xsl:when test="self::m:exp">
+      <xsl:value-of select="'ln'"/>
+    </xsl:when>
+    <xsl:when test="self::m:ln">
+      <xsl:value-of select="'exp'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sin">
+      <xsl:value-of select="'arcsin'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cos">
+      <xsl:value-of select="'arccos'"/>
+    </xsl:when>
+    <xsl:when test="self::m:tan">
+      <xsl:value-of select="'arctan'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sec">
+      <xsl:value-of select="'arcsec'"/>
+    </xsl:when>
+    <xsl:when test="self::m:csc">
+      <xsl:value-of select="'arccsc'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cot">
+      <xsl:value-of select="'arccot'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sinh">
+      <xsl:value-of select="'arcsinh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cosh">
+      <xsl:value-of select="'arccosh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:tanh">
+      <xsl:value-of select="'arctanh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sech">
+      <xsl:value-of select="'arcsech'"/>
+    </xsl:when>
+    <xsl:when test="self::m:csch">
+      <xsl:value-of select="'arccsch'"/>
+    </xsl:when>
+    <xsl:when test="self::m:coth">
+      <xsl:value-of select="'arccoth'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arcsin">
+      <xsl:value-of select="'sin'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arccos">
+      <xsl:value-of select="'cos'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arctan">
+      <xsl:value-of select="'tan'"/>
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:sep"/>
+
+<xsl:template match = "m:condition">
+  <xsl:choose>
+    <xsl:when test="parent::m:apply[m:forall[1]]"/>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <m:mrow xref="{@id}">
+            <xsl:apply-templates select="*" mode = "semantics"/>
+          </m:mrow>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="not(*[2])">
+            <xsl:apply-templates select="*" mode = "semantics"/>
+          </xsl:if>
+          <xsl:if test="*[2]">
+            <m:mrow>
+              <xsl:apply-templates select="*" mode = "semantics"/>
+            </m:mrow>
+          </xsl:if>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:declare"/>
+
+<xsl:template match = "m:lambda">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x039B;</xsl:text> </m:mo>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*">
+        <xsl:choose>
+          <xsl:when test="self::m:ci or self::m:cn">
+            <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <m:mrow>
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </m:mrow>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:apply[m:compose[1]]]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:compose]]">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] |
+                                       self::m:fn]" mode="semantics"/>
+    <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] |
+                                                            self::m:fn]">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:compose/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:compose/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2218;</xsl:text></m:mo>
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:ident">
+  <xsl:choose>
+    <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <m:mo xref="{@id}">id</m:mo>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mo>id</m:mo>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:piecewise">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if> 
+    <xsl:element name="m:mfenced">
+      <xsl:attribute name="open">{</xsl:attribute>
+      <xsl:attribute name="close"></xsl:attribute>
+      <m:mtable groupalign="left left left">
+       <xsl:for-each select="m:piece">
+       <m:mtr columnalign="left">
+          <m:mtd>
+            <m:mrow>
+              <xsl:apply-templates select="*[position()=1]" mode = "semantics"/>
+            </m:mrow>
+          </m:mtd>
+          <m:mtd>
+              <m:mrow>
+                <m:mtext>if <m:mspace width="5"/></m:mtext>
+                <xsl:apply-templates select="*[position()=2]" mode = "semantics"/>
+              </m:mrow> 
+            </m:mtd>
+          </m:mtr>
+        </xsl:for-each>
+        <xsl:if test="m:otherwise">
+          <m:mtr columnalign="left">
+            <m:mtd>
+              <m:mrow>
+                <xsl:apply-templates select="m:otherwise/*" mode = "semantics"/>
+              </m:mrow>
+            </m:mtd>
+            <m:mtd>
+              <m:mrow>
+              otherwise  
+            </m:mrow>
+          </m:mtd>
+      </m:mtr>
+    </xsl:if>
+  </m:mtable>
+</xsl:element>
+</m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='domain']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:domain]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>domain</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='codomain']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:codomain]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>codomain</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='image']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:image]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>image</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** ARITHMETIC, ALGEBRA & LOGIC ***************** -->
+
+<xsl:template match = "m:apply[m:quotient[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em">
+      <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
+    </m:mo>
+    <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:quotient/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:quotient/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+      <m:mrow>
+        <xsl:apply-templates select="*[2]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        </xsl:apply-templates>
+      </m:mrow>
+      <m:mrow>
+        <xsl:apply-templates select="*[3]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </m:mfrac>
+    <m:mo form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em">
+     <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
+    </m:mo>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:exp]]">
+  <m:msup>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exp/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exp/@id"/>
+          </xsl:attribute>
+        </xsl:if>e</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:factorial[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorial/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:factorial/@id"/>
+          </xsl:attribute>
+        </xsl:if>!</m:mo>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:max[1] | m:min[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar">
+      <m:munder>
+        <xsl:if test="*[1]=m:max">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+        </xsl:if>
+        <xsl:if test="*[1]=m:min">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:munder>
+      <xsl:if test="*[3]=m:condition">
+        <m:mfenced open="{{" close="}}" separators="">
+          <m:mfenced open="" close="" separators=",">
+            <xsl:for-each select = "*[position()>3]">
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </xsl:for-each>
+          </m:mfenced>
+          <m:mo>|</m:mo>
+          <xsl:apply-templates select="*[3]" mode = "semantics"/>
+        </m:mfenced>
+      </xsl:if>
+      <xsl:if test="not(*[3]=m:condition)">
+        <m:mfenced open="{{" close="}}" separators=",">
+          <xsl:for-each select = "*[position()>2]">
+            <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:for-each>
+        </m:mfenced>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="*[2]=m:condition">
+      <xsl:if test="*[1]=m:max">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:min">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+      </xsl:if>
+      <m:mfenced open="{{" close="}}" separators="">
+        <xsl:if test="*[3]">
+          <m:mfenced open="" close="" separators=",">
+            <xsl:for-each select = "*[position()>2]">
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </xsl:for-each>
+          </m:mfenced>
+          <m:mo>|</m:mo>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
+      <xsl:if test="*[1]=m:max">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:min">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+      </xsl:if>
+      <m:mfenced open="{{" close="}}" separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $MINUS_PREC or $IN_PREC=$MINUS_PREC and
+                                                        $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="minus">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="minus">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="minus">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]" mode="minus">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:if test="not(*[3])">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:minus/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:if>
+  <xsl:if test="*[3]">
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+    </xsl:apply-templates>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:minus/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+    <xsl:apply-templates select="*[3]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and
+                                                      $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="plus">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="plus">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="plus">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]" mode="plus">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:if test="*[2]">
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+    </xsl:apply-templates>
+    <xsl:for-each select = "*[position()>2]">
+      <xsl:choose>
+        <xsl:when test=". &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-."/> </m:mn>
+        </xsl:when>
+        <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
+          <xsl:apply-templates select="." mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:plus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:plus/@id"/>
+          </xsl:attribute>
+        </xsl:if>+</m:mo>
+          <xsl:apply-templates select="." mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:for-each>
+  </xsl:if>
+</xsl:template>
+
+<!-- HELM WARNING: power id is lost!                              -->
+<!-- msup should maintain the power definitionURL info but also the 
+     reference to apply                                           -->
+<xsl:template match = "m:apply[m:power[1]]">
+  <xsl:choose>
+    <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] |
+                         m:gcd[1] | m:lcm[1] | m:sin[1] | m:cos[1] | m:tan[1] |
+                         m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] |
+                         m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] |
+                         m:coth[1] | m:arcsin[1] | m:arccos[1] |
+                         m:arctan[1] | m:arcsec[1] | m:arccsc[1] | 
+                         m:arccot[1] | m:arcsinh[1] | m:arccosh[1] |
+                         m:arctanh[1] | m:arcsech[1] | m:arccsch [1]|
+                         m:arccoth[1] ]">
+      <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:msup>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select = "*[2]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+        </xsl:apply-templates>
+        <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and
+                                                    $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="remdiv">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="remdiv">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="remdiv">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <m:mo>
+    <xsl:if test="m:rem">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rem/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:rem/@id"/>
+          </xsl:attribute>
+        </xsl:if>      
+      <xsl:value-of select="'%'"/>
+    </xsl:if>
+    <xsl:if test="m:divide">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divide/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:divide/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+      <xsl:value-of select="'/'"/>
+    </xsl:if>
+  </m:mo>
+  <xsl:apply-templates select = "*[3]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+    <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+  </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and
+                                                    $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="times">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="times">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="times">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]" mode="times">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:if test="*[3]">
+    <xsl:for-each select = "*[position()>2]">
+<!-- HELM: to distinguish between * and the application -->
+<!-- Was:
+      <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+     Now is: -->
+     <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:times/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:times/@id"/>
+          </xsl:attribute>
+        </xsl:if>*</m:mo>
+      <xsl:apply-templates select="." mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+    </xsl:for-each>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:root[1]]">
+  <m:msqrt>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:degree">
+      <xsl:apply-templates select="*[3]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+      <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree)">
+      <xsl:apply-templates select="*[2]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+      <m:mn>2</m:mn>
+    </xsl:if>
+  </m:msqrt>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:gcd[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:gcd/@id"/>
+          </xsl:attribute>
+        </xsl:if>gcd</m:mo>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:gcd/@id"/>
+          </xsl:attribute>
+        </xsl:if>gcd</m:mo>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:if>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $AND_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="and">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="and">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="and">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]" mode="and">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:and/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:and/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2227;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $OR_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="or">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="or">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="or">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]" mode="or">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo> 
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:or/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:or/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2228;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $XOR_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="xor">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                                                and not($SEM_SW=$SEM_ALL)">
+      <xsl:apply-templates select="." mode="xor">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="xor">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]" mode="xor">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:xor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:xor/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x22BB;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:not[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+<!-- HELM: was <m:mo>not</m:mo> 
+     Now is -->
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:not/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:not/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x000AC;</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:forall[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:forall/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:forall/@id"/>
+          </xsl:attribute>
+        </xsl:if>for all</m:mo>
+    <xsl:if test="count(m:bvar) &gt; 1">
+      <m:mfenced separators=",">
+        <xsl:for-each select = "m:bvar">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="count(m:bvar)=1">
+      <xsl:apply-templates select = "m:bvar" mode="semantics"/>
+    </xsl:if>
+    <xsl:if test="m:condition">
+      <m:mo>:</m:mo>
+      <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+      <m:mo>,</m:mo>
+    </xsl:if>
+    <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
+                                not(self::m:condition)]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:exists[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exists/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exists/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2203;</xsl:text> </m:mo>
+    <xsl:if test="count(m:bvar) &gt; 1">
+      <m:mfenced separators=",">
+        <xsl:for-each select = "m:bvar">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="count(m:bvar)=1">
+      <xsl:apply-templates select = "m:bvar" mode="semantics"/>
+    </xsl:if>
+    <xsl:if test="m:condition">
+      <m:mo>,</m:mo>
+      <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="*[position()>1 and not(self::m:bvar) and not(self::m:condition)]">
+      <m:mo>:</m:mo>
+      <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
+                                not(self::m:condition)]" mode = "semantics"/>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM WARNING: abs id was lost! -->
+<xsl:template match = "m:apply[m:abs[1]]">
+  <xsl:if test="not(parent::m:apply[m:power[1]])">
+<!-- HELM: was
+    <m:mfenced open="|" close="|" separators="">
+     Now is: mrow + mo -->
+     <m:mrow>
+      <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+        <xsl:attribute name="xref">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo>
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+<!-- HELM: </m:mfenced> -->
+     </m:mrow>
+  </xsl:if>
+  <xsl:if test="parent::m:apply[m:power[1]]">
+    <m:msup>
+<!-- HELM: was
+      <m:mfenced open="|" close="|" separators="">
+     Now is: mrow + mo -->
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+        <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+<!-- HELM: </m:mfenced> -->
+      </m:mrow>
+      <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+    </m:msup>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:conjugate[1]]">
+  <m:mover>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mrow>
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mrow>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:conjugate/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:conjugate/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x0332;</xsl:text> </m:mo>
+  </m:mover>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+      <xsl:if test="m:arg">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:arg/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:arg/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Arg'"/>
+      </xsl:if>
+      <xsl:if test="m:real">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:real/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:real/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Re'"/>
+      </xsl:if>
+      <xsl:if test="m:imaginary">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginary/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:imaginary/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Im'"/>
+      </xsl:if>
+    </m:mo>
+    <m:mfenced separators="">
+      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='lcm']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:lcm]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lcm/@id"/>
+          </xsl:attribute>
+        </xsl:if>lcm</m:mo>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lcm/@id"/>
+          </xsl:attribute>
+        </xsl:if>lcm</m:mo>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+        </m:msup>
+      </xsl:if>
+      <m:mfenced separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:for-each>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='floor']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:floor]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:floor/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&LeftFloor;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x230A;</xsl:text>
+    </m:mo>
+    <xsl:apply-templates select="child::*[position()=last()]" mode="semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:floor/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&RightFloor;]]> -->
+<xsl:text disable-output-escaping="yes">&#x230B;</xsl:text>
+    </m:mo>
+</m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='ceiling']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:ceiling]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ceiling/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&LeftCeiling;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x2308;</xsl:text>
+    </m:mo>
+    <xsl:apply-templates select="child::*[position()=last()]"  mode="semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ceiling/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&RightCeiling;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x2309;</xsl:text>
+    </m:mo>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** RELATIONS ***************** -->
+
+<xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies
+                     | m:in | m:notin | m:notsubset | m:notprsubset
+                     | m:subset | m:prsubset | m:eq | m:gt | m:lt
+                     | m:geq | m:leq | m:equivalent | m:factorof]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:factorof or *[1]=m:tendsto or
+                  *[1]=m:implies or *[1]=m:in or *[1]=m:notin or
+                  *[1]=m:notsubset or *[1]=m:notprsubset">
+      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+      <m:mo>
+        <xsl:if test="*[1]=m:neq">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:neq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:neq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2260;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:approx">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:approx/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:approx/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x224A;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:factorof">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorof/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:factorof/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          |
+        </xsl:if>
+        <xsl:if test="*[1]=m:tendsto">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:implies">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:implies/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:implies/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x21D2;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:in">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:in/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:in/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <xsl:text disable-output-escaping='yes'>&#x2208;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notin">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notin/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notin/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2209;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notsubset">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2284;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notprsubset">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notprsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notprsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2288;</xsl:text>
+        </xsl:if>
+      </m:mo>
+      <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>+</m:mo>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt
+               or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
+      <xsl:apply-templates select = "*[2]" mode="semantics"/>
+      <xsl:for-each select = "*[position()>2]">
+        <m:mo>
+          <xsl:if test="../*[self::m:subset][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:subset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:subset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:text disable-output-escaping='yes'>&#x2286;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:prsubset][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:prsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:prsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2282;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:eq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:eq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:eq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'='"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:gt][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:gt/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:gt/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'&gt;'"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:lt][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:lt/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:lt/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'&lt;'"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:geq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:geq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:geq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2265;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:leq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:leq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:leq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2264;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:equivalent][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:equivalent/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:equivalent/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2261;</xsl:text>
+          </xsl:if>
+        </m:mo>
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** CALCULUS ***************** -->
+
+<xsl:template match = "m:apply[*[1][self::m:ln]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="parent::m:apply[m:power[1]]">
+        <m:msup>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ln/@id"/>
+          </xsl:attribute>
+        </xsl:if>ln</m:mo>
+          <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+        </m:msup>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ln/@id"/>
+          </xsl:attribute>
+        </xsl:if>ln</m:mo>
+      </xsl:otherwise>
+    </xsl:choose>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:log[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="parent::m:apply[m:power[1]]">
+        <xsl:if test="not(*[2]=m:logbase)">
+          <m:msup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+          </m:msup>
+        </xsl:if>
+        <xsl:if test="*[2]=m:logbase">
+          <m:msubsup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+            <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+          </m:msubsup>
+        </xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(*[2]=m:logbase)">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+        </xsl:if>
+        <xsl:if test="*[2]=m:logbase">
+          <m:msub>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+          </m:msub>
+        </xsl:if>
+      </xsl:otherwise>
+    </xsl:choose>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:if test="*[2]=m:logbase">
+      <xsl:apply-templates select = "*[3]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      </xsl:apply-templates>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:logbase)">
+      <xsl:apply-templates select = "*[2]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      </xsl:apply-templates>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:diff[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
+      <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:diff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:msup>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+        </m:msup>
+        <m:mrow>
+          <m:mo>d</m:mo>
+          <m:msup>
+            <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+            <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+          </m:msup>
+        </m:mrow>
+      </m:mfrac>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
+      <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:diff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:mo>d</m:mo>
+        <m:mrow>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+        </m:mrow>
+      </m:mfrac>
+    </xsl:if>
+    <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:partialdiff[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select = "m:bvar">
+      <xsl:if test="*[last()]=m:degree">
+        <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:partialdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <m:msup>
+             <m:mo>d</m:mo>
+             <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+          </m:msup>
+          <m:mrow>
+            <m:mo>d</m:mo>
+            <m:msup>
+              <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+              <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+            </m:msup>
+          </m:mrow>
+        </m:mfrac>
+      </xsl:if>
+      <xsl:if test="not(*[last()]=m:degree)">
+        <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:partialdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <m:mo>d</m:mo>
+          <m:mrow>
+            <m:mo>d</m:mo>
+            <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+          </m:mrow>
+        </m:mfrac>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
+  <xsl:apply-templates select="*" mode = "semantics"/>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+      <xsl:if test="*[1]=m:divergence">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divergence/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:divergence/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'div'"/>
+      </xsl:if>
+      <xsl:if test="*[1]=m:grad">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:grad/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:grad/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'grad'"/>
+      </xsl:if>
+      <xsl:if test="*[1]=m:curl">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:curl/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:curl/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'curl'"/>
+      </xsl:if>
+    </m:mo>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:ci">
+        <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mfenced separators="">
+          <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+        </m:mfenced>
+      </xsl:otherwise>
+    </xsl:choose>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:laplacian[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:msup>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:laplacian/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:laplacian/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:text disable-output-escaping='yes'>&#x0394;</xsl:text></m:mo>
+      <m:mn>2</m:mn>
+    </m:msup>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** SET THEORY ***************** -->
+
+<xsl:template match = "m:set | m:list">
+  <m:mfenced open="{{" close="}}" separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
+      <xsl:apply-templates select="m:bvar" mode = "semantics"/>
+      <m:mo>|</m:mo>
+      <xsl:apply-templates select="m:condition" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
+      <m:mfenced open="" close="" separators=",">
+        <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+      <m:mo>|</m:mo>
+      <xsl:apply-templates select="m:condition" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
+      <m:mfenced open="" close="" separators=",">
+        <xsl:for-each select = "*">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC
+                    and $PARAM=$PAR_SAME and not($IN_OP=$UNION_OP)">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="union">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="union">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="union">
+          <xsl:with-param name="IN_OP" select="$UNION_OP"/>
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]" mode="union">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode="semantics">
+    <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:union/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:union/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x22C3;</m:mo>
+<!-- HELM: not rendered correctly <![CDATA[&Union;]]> -->
+  <!--   <xsl:text disable-output-escaping="yes">&#x22C3;</xsl:text></m:mo>-->
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
+      <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+      <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC or $IN_PREC=$INTERSECT_PREC
+                    and $PARAM=$PAR_SAME and not($IN_OP=$INTERSECT_OP)">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="intersect">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="intersect">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="intersect">
+          <xsl:with-param name="IN_OP" select="$INTERSECT_OP"/>
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode="semantics">
+    <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:intersect/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:intersect/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Intersection;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x22C2;</xsl:text></m:mo>
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
+      <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+      <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC
+                    and $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="setdiff">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="setdiff">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="setdiff">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:setdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>\</m:mo>
+  <xsl:apply-templates select = "*[3]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+    <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+  </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:cartesianproduct[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $CARTPROD_PREC or $IN_PREC=$CARTPROD_PREC
+                    and $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cartprod">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="cartprod">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cartprod">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:cartesianproduct[1]]" mode="cartprod">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:cartesianproduct/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:cartesianproduct/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&times;]]> -->
+     <xsl:text disable-output-escaping="yes">&#x00D7;</xsl:text></m:mo>
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<!-- HELM WARNING: card id was lost! -->
+<xsl:template match = "m:apply[m:card[1]]">
+<!-- HELM: was
+  <m:mfenced open="|" close="|" separators=",">
+     Now is: mrow + mo -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:card/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:card/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</mo>
+    <xsl:for-each select = "*[position()>1]">
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+     <mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:setdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</mo>
+  </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+
+<!-- ***************** SEQUENCES AND SERIES ***************** -->
+
+<xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
+        <m:munderover>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sum/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+             <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:product/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+             <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <m:mrow>
+            <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+            <m:mo>=</m:mo>
+            <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
+          </m:mrow>
+          <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
+        </m:munderover>
+        <xsl:apply-templates select = "*[5]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
+        <m:munder>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+             <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+             <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </m:munder>
+        <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:when test="*[2]=m:domainofapplication">
+        <m:munder>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sum/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Sum;]]> -->
+              <xsl:text disable-output-escaping="yes">&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:product/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Product;]]> -->
+              <xsl:text disable-output-escaping="yes">&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <xsl:apply-templates select="m:domainofapplication" mode = "semantics"/>
+        </m:munder>
+        <m:mrow>
+          <xsl:apply-templates select="*[position()=last()]" mode = "semantics"/>
+          </m:mrow>
+        </xsl:when>
+      </xsl:choose>
+    </m:mrow>
+  </xsl:template>
+  
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='int']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:int]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+    <xsl:when test="m:condition">
+      <m:msub>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+        <xsl:apply-templates select="m:condition" mode="semantics"/>
+      </m:msub>
+      <m:mrow>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+      </m:mrow>
+      <m:mrow>
+        <m:mo>d</m:mo>
+        <xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="m:domainofapplication">
+      <m:msub>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+        <xsl:apply-templates select="m:domainofapplication" mode="semantics"/>
+      </m:msub>
+      <m:mrow>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics" />
+      </m:mrow>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="m:interval">
+          <m:msubsup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+             <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+            <xsl:apply-templates select="m:interval/*[position()=1]" mode="semantics" />
+            <xsl:apply-templates select="m:interval/*[position()=2]" mode="semantics"/>
+          </m:msubsup>
+          <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select="m:bvar" mode="semantics"/>
+        </xsl:when>
+        <xsl:when test="m:lowlimit">
+        <m:msubsup>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+           <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+          <m:mrow><xsl:apply-templates select="m:lowlimit" mode="semantics"/></m:mrow>
+          <m:mrow><xsl:apply-templates select="m:uplimit" mode="semantics"/></m:mrow>
+        </m:msubsup>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+        <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+       <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+       <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+    </xsl:choose>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:limit[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:munder>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lim/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lim/@id"/>
+          </xsl:attribute>
+        </xsl:if>lim</m:mo>
+      <m:mrow>
+        <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
+            <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+            <m:mo><xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text></m:mo>
+            <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </xsl:if>
+        <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
+          <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </xsl:if>
+      </m:mrow>
+    </m:munder>
+    <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** TRIGONOMETRY ***************** -->
+
+<xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos |
+                       self::m:tan | self::m:sec | self::m:csc |
+                       self::m:cot | self::m:sinh | self::m:cosh |
+                       self::m:tanh | self::m:sech | self::m:csch |
+                       self::m:coth | self::m:arcsin | self::m:arccos |
+                       self::m:arctan | self::m:arcsec | self::m:arccsc | 
+                       self::m:arccot | self::m:arcsinh | self::m:arccosh |
+                       self::m:arctanh | self::m:arcsech | self::m:arccsch |
+                       self::m:arccoth ] ]">
+                        
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:if>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "*" mode="trigonometry">
+  <m:mo>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="self::m:sin">
+        <xsl:value-of select="'sin'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cos">
+        <xsl:value-of select="'cos'"/>
+      </xsl:when>
+      <xsl:when test="self::m:tan">
+        <xsl:value-of select="'tan'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sec">
+        <xsl:value-of select="'sec'"/>
+      </xsl:when>
+      <xsl:when test="self::m:csc">
+        <xsl:value-of select="'csc'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cot">
+        <xsl:value-of select="'cot'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sinh">
+        <xsl:value-of select="'sinh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cosh">
+        <xsl:value-of select="'cosh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:tanh">
+        <xsl:value-of select="'tanh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sech">
+        <xsl:value-of select="'sech'"/>
+      </xsl:when>
+      <xsl:when test="self::m:csch">
+        <xsl:value-of select="'csch'"/>
+      </xsl:when>
+      <xsl:when test="self::m:coth">
+        <xsl:value-of select="'coth'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsin">
+        <xsl:value-of select="'arcsin'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccos">
+        <xsl:value-of select="'arccos'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arctan">
+        <xsl:value-of select="'arctan'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsec">
+        <xsl:value-of select="'arcsec'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccsc">
+        <xsl:value-of select="'arccsc'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccot">
+        <xsl:value-of select="'arccot'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsinh">
+        <xsl:value-of select="'arcsinh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccosh">
+        <xsl:value-of select="'arccosh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arctanh">
+        <xsl:value-of select="'arctanh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsech">
+        <xsl:value-of select="'arcsech'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccsch">
+        <xsl:value-of select="'arccsch'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccoth">
+        <xsl:value-of select="'arccot'"/>
+      </xsl:when>
+    </xsl:choose>
+  </m:mo>
+</xsl:template>
+
+
+<!-- ***************** STATISTICS ***************** -->
+
+<!-- HELM WARNING: mean id was lost! -->
+<xsl:template match = "m:apply[m:mean[1]]">
+<!-- HELM: was
+  <m:mfenced open="&lt;" close="&gt;" separators=",">
+     Now is: mrow + mo + separator (mo) -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003C;</m:mo>
+    <xsl:for-each select = "*[position()>1]">
+<!-- HELM: if added -->
+      <xsl:if test="position() != 1">
+       <m:mo separator="true">,</m:mo>
+      </xsl:if> 
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003E;</m:mo>
+   </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+<xsl:template match = "m:apply[m:sdev[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sdev/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sdev/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+     <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:variance[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:variance/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:variance/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+     <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
+    <m:msup>
+      <m:mfenced separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+      <m:mn>2</m:mn>
+    </m:msup>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:median[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:median/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:median/@id"/>
+          </xsl:attribute>
+        </xsl:if>median</m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:mode[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mode/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mode/@id"/>
+          </xsl:attribute>
+        </xsl:if>mode</m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM WARNING: mean id was lost! -->
+<xsl:template match = "m:apply[m:moment[1]]">
+<!-- HELM: was
+  <m:mfenced open="&lt;" close="&gt;" separators="">
+     Now is: mrow + mo -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:moment/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:momemt/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003C;</m:mo>
+    <xsl:if test="*[2]=m:degree and not(*[3]=m:momentabout)">
+      <m:msup>
+        <xsl:apply-templates select="*[3]" mode = "semantics"/>
+          <xsl:apply-templates select="*[2]" mode = "semantics"/>
+          </m:msup>
+        </xsl:if>
+        <xsl:if test="*[2]=m:degree and *[3]=m:momentabout">
+          <m:msup>
+            <xsl:apply-templates select="*[4]" mode = "semantics"/>
+            <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:msup>  
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree) and *[2]=m:momentabout">
+       <xsl:for-each select = "*[position()>2]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree) and not(*[2]=m:momentabout)">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003E;</m:mo>
+  </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+
+<!-- ***************** LINEAR ALGEBRA ***************** -->
+
+<xsl:template match="m:vector">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mtable>
+      <xsl:for-each select="*">
+        <m:mtd>
+          <xsl:apply-templates select="." mode = "semantics"/>
+        </m:mtd>
+      </xsl:for-each>
+    </m:mtable>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrix">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mtable>
+      <xsl:apply-templates select="*" mode = "semantics"/>
+    </m:mtable>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrixrow">
+  <m:mtr>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select="*">
+      <m:mtd>
+        <xsl:apply-templates select="." mode = "semantics"/>
+      </m:mtd>
+    </xsl:for-each>
+  </m:mtr>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:determinant[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:determinant/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:determinant/@id"/>
+          </xsl:attribute>
+        </xsl:if>det</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:transpose[1]]">
+  <m:msup>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:transpose/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:transpose/@id"/>
+          </xsl:attribute>
+        </xsl:if>T</m:mo>
+  </m:msup>
+</xsl:template>
+
+<!-- HELM: ERROR, this template generates the selected content elements
+     and doesn't generate the presentation for selector                 -->
+<!--<xsl:template match = "m:apply[m:selector[1]]">
+  <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
+      <xsl:variable name="m" select = "*[3]"/>
+      <xsl:choose>
+        <xsl:when test="*[4]=m:cn">
+          <xsl:variable name="n" select = "*[4]"/>
+          <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:if>
+  <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
+    <xsl:variable name="m" select = "*[3]"/>
+    <xsl:copy-of select = "*[2]/*[position()=$m]"/>
+  </xsl:if>
+</xsl:template> -->
+
+<xsl:template match = "m:apply[m:selector[1]]">
+   <msub>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+     <xsl:attribute name="xref">
+      <xsl:value-of select="@id"/>
+     </xsl:attribute>
+    </xsl:if> 
+    <xsl:apply-templates select = "*[2]" mode="semantics"/>
+    <m:mrow>
+     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:selector/@id">
+      <xsl:attribute name="xref">
+       <xsl:value-of select="m:selector/@id"/>
+      </xsl:attribute>
+     </xsl:if>
+     <xsl:choose>
+     <xsl:when test="*[3]=m:cn">
+      <xsl:apply-templates select = "*[3]" mode="semantics"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <m:mi>*</m:mi>
+     </xsl:otherwise>
+     </xsl:choose> 
+     <xsl:if test="*[2]=m:matrix and *[4]=m:cn">
+      <xsl:apply-templates select = "*[4]" mode="semantics"/>
+     </xsl:if>
+    </m:mrow>
+   </msub>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:vectorproduct[1] |
+                                 m:scalarproduct[1] | m:outerproduct[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    <m:mo>
+      <xsl:if test="m:vectorproduct[1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:vectorproduct/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:vectorproduct/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+       <xsl:text disable-output-escaping='yes'>&#x2A2F;</xsl:text>
+      </xsl:if>
+      <xsl:if test="m:scalarproduct[1] | m:outerproduct[1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and *[1]/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="*[1]/@id"/>
+          </xsl:attribute>
+        </xsl:if>           
+        <xsl:value-of select="'.'"/>
+      </xsl:if>
+    </m:mo>
+    <xsl:apply-templates select="*[3]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** CONSTANT and SYMBOL ELEMENTS ***************** -->
+
+<xsl:template match="m:integers">
+   <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:integers/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:integers/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+    <xsl:text disable-output-escaping='yes'>&#x2124;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:reals">
+   <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:reals/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:reals/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+    <xsl:text disable-output-escaping='yes'>&#x211D;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:rationals">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rationals/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:rationals/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x211A;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:naturalnumbers">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:naturalnumbers/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:naturalnumbers/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2115;</xsl:text></m:mi> 
+</xsl:template>
+
+<xsl:template match="m:complexes">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:complexes/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:complexes/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2102;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:primes">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:primes/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:primes/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2119;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:exponentiale">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exponentiale/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exponentiale/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping="yes">&#x2147;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:imaginaryi">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginaryi/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:imaginaryi/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&ImaginaryI;]]> -->
+   <xsl:text disable-output-escaping="yes">&#xF74E;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:notanumber">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notanumber/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notanumber/@id"/>
+          </xsl:attribute>
+        </xsl:if>NaN</m:mi>  
+</xsl:template>
+
+<xsl:template match="m:true">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:true/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:true/@id"/>
+          </xsl:attribute>
+        </xsl:if>true</m:mi>  
+</xsl:template>
+
+<xsl:template match="m:false">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:false/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:false/@id"/>
+          </xsl:attribute>
+        </xsl:if>false</m:mi>   
+</xsl:template>
+
+<xsl:template match="m:emptyset">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:emptyset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:emptyset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&empty;]]> -->
+   <xsl:text disable-output-escaping="yes">&#xE2D3;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:pi">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:pi/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:pi/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&pi;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x03C0;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:eulergamma">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:eulergamma/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:eulergamma/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&gamma;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x03B3;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:infinity">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:infinity/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:infinity/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&infin;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x221E;</xsl:text></m:mi>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
diff --git a/helm/style/mmlctop2_0.xsl b/helm/style/mmlctop2_0.xsl
new file mode 100644 (file)
index 0000000..0a0e454
--- /dev/null
@@ -0,0 +1,3982 @@
+<?xml version="1.0"?>
+
+<!-- ******************************************************** -->
+<!--   XSL Transform of MathML content to MathML presentation -->
+<!--                                                          -->
+<!--   Authors Igor Rodionov <igor@csd.uwo.ca>,               -->
+<!--           Stephen Watt  <watt@csd.uwo.ca>.               -->  
+<!--                                                          -->
+<!--   (C) Copyright 2000  Symbolic Computation Laboratory,   -->
+<!--                       University of Western Ontario,     -->
+<!--                       London, Canada N6A 5B7.            -->
+<!--                                                          -->
+<!-- ******************************************************** -->
+<!--   Updated Nov. 2001 by:                                  -->
+<!--           S. Huerter <huerter@csd.uwo.ca>.               -->
+<!--                                                          -->
+<!--   Complies with the W3C MathML 2.0 Recommendation of     -->
+<!--   21 February 2001.                                      -->
+<!-- ******************************************************** -->
+
+<!-- ====================================================== -->
+<!--  April, 10 2002 - HELM group:                          -->
+<!--  Added the namespace prefix to all the output elements -->
+<!--  Changed the mml prefix into m                         -->
+<!--  Added xref to every mo element                        -->
+<!--  New csymbol template                                  -->
+<!--  reln is not supported                                 -->
+<!--  First draft: April 10 2002, Irene Schena              -->
+<!-- ====================================================== -->
+
+<xsl:stylesheet id="mmlctop.xsl"
+                version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:m="http://www.w3.org/1998/Math/MathML">
+
+<!-- HELM: we don't have a default namespace.
+     Removed xmlns="http://www.w3.org/1998/Math/MathML" -->
+
+<!-- HELM: was
+<xsl:output method="xml" indent="yes"/>
+-->
+<xsl:output method="xml"/>
+
+<xsl:strip-space elements="apply semantics annotation-xml
+        csymbol fn cn ci interval matrix matrixrow vector
+        lambda bvar condition logbase degree set list
+        lowlimit uplimit"/>
+
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!--         Parameters, variables and constants           -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+<!-- ~~~~~~~~ Semantics related *constants*: ~~~~~~~~ -->
+
+<!-- Strip off semantics -->
+<xsl:variable name="SEM_STRIP" select="-1"/>
+
+<!-- Pass semantics "as is" -->
+<xsl:variable name="SEM_PASS" select="0"/>
+
+<!-- Add semantics at top level only -->
+<xsl:variable name="SEM_TOP" select="1"/>
+
+<!-- Add semantics at all levels -->
+<xsl:variable name="SEM_ALL" select="2"/>
+
+<!-- Semantics at top level only, with id refs -->
+<!-- NOTE: ids have to be already present in the
+           input for this feature to work. -->
+<xsl:variable name="SEM_XREF" select="3"/>
+
+<!-- No semantics at top level, with id refs -->
+<!-- NOTE: ids have to be already present in the
+           input for this feature to work. -->
+<xsl:variable name="SEM_XREF_EXT" select="4"/>
+
+
+<!-- ~~~~~~~~~~ Stylesheet *parameter*: SEM_SW ~~~~~~~~~~~~~~ -->
+<!-- Assumes one of the above values; SEM_PASS is the default -->
+<!-- The default can be overridden by specifying different    -->
+<!-- value on the command line when the stylesheet is invoked -->
+
+<!-- HELM: $SEM_SW was SEM_PASS (error!) -->
+<xsl:param name="SEM_SW" select="$SEM_XREF"/>
+
+
+<!-- ~~~~~~ Operator precedence definitions ~~~~~~ -->
+<xsl:variable name="UNION_OP" select="2"/>
+<xsl:variable name="INTERSECT_OP" select="6"/>
+<xsl:variable name="SETDIFF_OP" select="4"/>
+<xsl:variable name="NO_PREC" select="0"/>
+<xsl:variable name="UNION_PREC" select="1"/>
+<xsl:variable name="SETDIFF_PREC" select="1"/>
+<xsl:variable name="INTERSECT_PREC" select="3"/>
+<xsl:variable name="CARTPROD_PREC" select="3"/>
+<xsl:variable name="OR_PREC" select="5"/>
+<xsl:variable name="XOR_PREC" select="5"/>
+<xsl:variable name="AND_PREC" select="7"/>
+<xsl:variable name="PLUS_PREC" select="9"/>
+<xsl:variable name="MINUS_PREC" select="9"/>
+<xsl:variable name="MUL_PREC" select="11"/>
+<xsl:variable name="DIV_PREC" select="11"/>
+<xsl:variable name="NEG_PREC" select="13"/>
+<xsl:variable name="FUNCTION_PREC" select="99"/>
+
+<!-- ~~~~~ Miscellaneous constant definitions ~~~~~ -->
+
+<xsl:variable name="YES" select="1"/>
+<xsl:variable name="NO" select="0"/>
+<xsl:variable name="NO_PARAM" select="-1"/>
+<xsl:variable name="PAR_SAME" select="-3"/>
+<xsl:variable name="PAR_YES" select="-5"/>
+<xsl:variable name="PAR_NO" select="-7"/>
+<xsl:variable name="DOESNT_MATTER" select="-9"/>
+
+<!-- +++++++++++++++++ INDEX OF TEMPLATES +++++++++++++++++++ -->
+
+<!-- All templates are subdivided into the following categories
+     (listed in the order of appearance in the stylesheet):
+
+THE TOPMOST ELEMENT: MATH
+ math
+
+SEMANTICS HANDLING
+ semantics
+
+BASIC CONTAINER ELEMENTS
+ cn, ci, csymbol
+
+BASIC CONTENT ELEMENTS
+ fn, interval, inverse, sep, condition, declare, lambda, compose, ident
+
+     *NEW: apply, piecewise, domain, codomain, image
+
+ARITHMETIC, ALGEBRA & LOGIC
+ quotient, exp, factorial, max, min, minus, plus, power, rem, divide,
+ times, root, gcd, and, or, xor, not, forall, exists, abs, conjugate,
+ arg, real, imaginary
+
+     *NEW: floor, ceiling, lcm
+
+RELATIONS
+ neq, approx, tendsto, implies, in, notin, notsubset, notprsubset,
+ subset, prsubset, eq, gt, lt, geq, leq, equivalent
+
+CALCULUS
+ ln, log, diff, partialdiff, lowlimit, uplimit, bvar, degree,
+ logbase, divergence, grad, curl, laplacian
+
+SET THEORY
+ set, list, union, intersect, setdiff, card
+
+     *NEW: cartesianproduct
+
+SEQUENCES AND SERIES
+ sum, product, limit
+
+     *NEW: int
+
+TRIGONOMETRY
+ sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth,
+ arcsin, arccos, arctan
+
+     *NEW: arcsec, arccsc, arccot, arcsinh, arccosh, arctanh,
+           arcsech, arccsch, arccoth, 
+
+STATISTICS
+ mean, sdev, variance, median, mode, moment
+
+LINEAR ALGEBRA
+ vector, matrix, matrixrow, determinant, transpose, selector,
+ vectorproduct, scalarproduct, outerproduct
+-->
+
+
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+
+
+<!-- ***************** THE TOPMOST ELEMENT: MATH ***************** -->
+
+<xsl:template match = "m:math">
+<!-- HELM:  <m:math> -->
+  <xsl:choose>
+    <xsl:when test="$SEM_SW=$SEM_TOP or $SEM_SW=$SEM_ALL and *[2] or $SEM_SW=$SEM_XREF">             <m:semantics>                                                       
+    <m:mrow>                                                         
+          <xsl:apply-templates mode = "semantics"/>
+        </m:mrow>
+        <m:annotation-xml encoding="MathML">
+          <xsl:copy-of select="*"/>
+        </m:annotation-xml>
+      </m:semantics>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mrow>  
+    </xsl:otherwise>
+  </xsl:choose>
+<!-- HELM: </m:math> -->
+</xsl:template>
+
+
+<!-- ***************** SEMANTICS HANDLING ***************** -->
+
+<!-- This template is called recursively.  At each level   -->
+<!-- in the source tree it decides whether to strip off,   -->
+<!-- pass or add semantics at that level (depending on the -->
+<!-- value of SEM_SW parameter).  Then the actual template -->
+<!-- is applied to the node.                               -->
+
+<xsl:template match = "m:*" mode = "semantics">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$SEM_SW=$SEM_STRIP and self::m:semantics">
+      <xsl:apply-templates select="m:annotation-xml[@encoding='MathML']">
+        <xsl:with-param name="IN_OP" select="$IN_OP"/>
+        <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:when test="($SEM_SW=$SEM_PASS or $SEM_SW=$SEM_TOP) and self::m:semantics">
+      <m:semantics>
+        <xsl:apply-templates select="*[1]">   
+        <xsl:with-param name="IN_OP" select="$IN_OP"/>
+        <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+        <xsl:copy-of select="m:annotation-xml"/>
+      </m:semantics>
+    </xsl:when>
+    <xsl:when test="$SEM_SW=$SEM_ALL">
+      <m:semantics>
+        <xsl:choose>
+          <xsl:when test="self::m:semantics">
+            <xsl:apply-templates select="*[1]">
+              <xsl:with-param name="IN_OP" select="$IN_OP"/>
+              <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+              <xsl:with-param name="PARAM" select="$PARAM"/>
+              <xsl:with-param name="PAREN" select="$PAREN"/>
+              <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+            </xsl:apply-templates>
+            <xsl:copy-of select="m:annotation-xml"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select=".">
+              <xsl:with-param name="IN_OP" select="$IN_OP"/>
+              <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+              <xsl:with-param name="PARAM" select="$PARAM"/>
+              <xsl:with-param name="PAREN" select="$PAREN"/>
+              <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+            </xsl:apply-templates>
+            <m:annotation-xml encoding="MathML">
+              <xsl:copy-of select="."/>
+            </m:annotation-xml>
+          </xsl:otherwise>
+        </xsl:choose>
+      </m:semantics>
+    </xsl:when>
+    <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:choose>
+<!-- HELM: syntax error, was sematics -->
+        <xsl:when test="self::m:semantics">
+          <xsl:copy>
+            <xsl:copy-of select="@*"/>
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+            <xsl:copy-of select="*[1]"/>
+            <xsl:copy-of select="m:annotation-xml"/>
+          </xsl:copy>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select=".">
+            <xsl:with-param name="IN_OP" select="$IN_OP"/>
+            <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+            <xsl:with-param name="PARAM" select="$PARAM"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="self::m:semantics">
+          <xsl:copy-of select="."/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select=".">
+            <xsl:with-param name="IN_OP" select="$IN_OP"/>
+            <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
+            <xsl:with-param name="PARAM" select="$PARAM"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:semantics">
+  <xsl:apply-templates select="." mode = "semantics"/>
+</xsl:template>
+
+
+<!-- ***************** BASIC CONTAINER ELEMENTS ***************** -->
+
+<xsl:template match = "m:cn">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test=". &lt; 0 and $IN_PREC &gt; $NO_PREC and $PAREN=$PAR_NO
+                                                   and $PAR_NO_IGNORE=$NO">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cn"/>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:apply-templates select="." mode="cnid"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="." mode="cn"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- HELM: the entity &#x2062; is not defined -->
+<xsl:template match = "m:cn" mode="cn">
+  <xsl:choose>
+    <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+      <m:msub>
+        <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='e-notation' and not(@base) and child::m:sep[1]">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mo>e</m:mo>
+        <m:mo> <xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+  </xsl:when>
+    <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+      <m:mfenced separators="">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <xsl:if test="text()[2] &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+        </xsl:if>
+        <xsl:if test="not(text()[2] &lt; 0)">
+          <m:mo>+</m:mo>
+          <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+        </xsl:if>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mo>i</m:mo>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mfenced separators="">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <xsl:if test="text()[2] &lt; 0">
+            <m:mo>-</m:mo>
+            <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+          </xsl:if>
+          <xsl:if test="not(text()[2] &lt; 0)">
+            <m:mo>+</m:mo>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </xsl:if>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+          <m:mo>i</m:mo>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+      <m:mfrac>
+        <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+        <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+      </m:mfrac>
+    </xsl:when>
+    <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mfenced>
+          <m:mfrac>
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfrac>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+      <m:mrow>
+        <m:mo>Polar</m:mo>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mfenced separators=",">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+      <m:msub>
+        <m:mrow>
+          <m:mo>Polar</m:mo>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+          <m:mfenced separators=",">
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfenced>
+        </m:mrow>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+   </xsl:when>
+    <xsl:otherwise>
+<!-- HELM: cn could contain MathML presentation -->
+<!-- HELM: was
+      <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     Now is: -->
+    <xsl:choose>
+     <xsl:when test="child::text() and not(*[1])">
+      <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:choose>
+       <xsl:when test="not(*[2])">
+        <xsl:copy-of select="*[1]"/>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mrow>
+         <xsl:copy-of select="*|text()"/>
+        </m:mrow>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:otherwise>
+    </xsl:choose>
+<!-- HELM -->
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:cn" mode="cnid">
+  <xsl:choose>
+    <xsl:when test="@base and (not(@type) or @type='integer' or @type='real')">
+      <m:msub xref="{@id}">
+        <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='complex' and not(@base) and child::m:sep[1]">
+      <m:mfenced separators="" xref="{@id}">
+        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+        <xsl:if test="text()[2] &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+        </xsl:if>
+        <xsl:if test="not(text()[2] &lt; 0)">
+          <m:mo>+</m:mo>
+          <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+        </xsl:if>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+        <m:mo>i</m:mo>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="@type='complex' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mfenced separators="">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <xsl:if test="text()[2] &lt; 0">
+            <m:mo>-</m:mo>
+            <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+          </xsl:if>
+          <xsl:if test="not(text()[2] &lt; 0)">
+            <m:mo>+</m:mo>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </xsl:if>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+          <m:mo>i</m:mo>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='rational' and not(@base) and child::m:sep[1]">
+      <m:mfrac xref="{@id}">
+        <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+        <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+      </m:mfrac>
+    </xsl:when>
+    <xsl:when test="@type='rational' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mfenced>
+          <m:mfrac>
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfrac>
+        </m:mfenced>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+    </xsl:when>
+    <xsl:when test="@type='polar' and not(@base) and child::m:sep[1]">
+      <m:mrow xref="{@id}">
+        <m:mo>Polar</m:mo>
+        <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+        <m:mfenced separators=",">
+          <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+          <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="@type='polar' and @base and child::m:sep[1]">
+      <m:msub xref="{@id}">
+        <m:mrow>
+          <m:mo>Polar</m:mo>
+          <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text> </m:mo>
+          <m:mfenced separators=",">
+            <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+            <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+          </m:mfenced>
+        </m:mrow>
+        <m:mn> <xsl:value-of select="@base"/> </m:mn>
+      </m:msub>
+   </xsl:when>
+    <xsl:otherwise>
+<!-- HELM: cn could contain MathML presentation -->
+<!-- HELM: was
+      <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     Now is: -->
+    <xsl:choose>
+     <xsl:when test="child::text() and not(*[1])">
+      <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:variable name="id" select="@id"/>
+      <xsl:choose>
+       <xsl:when test="not(*[2])">
+        <xsl:for-each select="*[1]">
+         <xsl:copy>
+          <xsl:attribute name="xref">
+           <xsl:value-of select="$id"/>
+          </xsl:attribute>
+          <xsl:copy-of select="@*|*"/>
+         </xsl:copy>
+        </xsl:for-each>
+       </xsl:when>
+       <xsl:otherwise>
+        <m:mrow xref="{$id}">
+         <xsl:copy-of select="*|text()"/>
+        </m:mrow>
+       </xsl:otherwise>
+      </xsl:choose>
+     </xsl:otherwise>
+    </xsl:choose>
+<!-- HELM -->
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci">
+  <xsl:choose>
+    <xsl:when test="@type='vector' or @type=matrix or @type=set">
+      <m:mi mathvariant="bold">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mi>
+    </xsl:when>
+    <xsl:when test="child::text() and not(child::*[1])">
+      <m:mi>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: ERROR, added mode="semantics", it didn't generate identifiers -->
+        <xsl:apply-templates mode = "semantics"/>
+      </m:mi>
+    </xsl:when>
+<!-- HELM: text & markup !!! Not compliant with the specification -->
+    <xsl:when test="child::text() and *[1] and not(*[1]=m:sep)">
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: added semantics mode -->
+        <xsl:apply-templates mode="semantics"/>
+      </m:mrow>
+    </xsl:when>
+<!-- HELM -->
+    <xsl:otherwise>
+      <xsl:if test="*[2]">
+        <m:mrow>
+          <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+          </xsl:if>
+          <xsl:apply-templates select="*"/>
+        </m:mrow>
+      </xsl:if>
+      <xsl:if test="not(*[2])">
+<!-- HELM: ci could contain MathML presentation -->
+<!-- HELM: was
+        <xsl:apply-templates select="*[1]"/>
+     Now is: -->
+       <xsl:variable name="id" select="@id"/>
+        <xsl:for-each select="*[1]">
+         <xsl:copy>
+          <xsl:attribute name="xref">
+           <xsl:value-of select="$id"/>
+          </xsl:attribute>
+         <xsl:copy-of select="@*|*"/>
+         </xsl:copy>
+        </xsl:for-each>
+<!-- HELM -->
+      </xsl:if>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:ci/m:*[not(self::m:sep)]">
+  <xsl:copy-of select = "."/>
+</xsl:template>
+
+<!-- HELM: revised version previous Version x.xx from Feb. 18, 2000 -->
+<xsl:template match = "m:csymbol">
+<!-- HELM: mrow to maintain csymbol id -->
+   <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+     <xsl:attribute name="xref">
+      <xsl:value-of select="@id"/>
+     </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select="* and text()">
+     <xsl:choose>
+     <xsl:when test="text()">
+      <m:mo><xsl:value-of select="."/></m:mo>
+     </xsl:when>
+     <xsl:otherwise>
+      <xsl:copy-of select = "."/>
+     </xsl:otherwise>
+     </xsl:choose>
+    </xsl:for-each>
+   </m:mrow>
+</xsl:template>
+
+<!-- HELM: csymbol cannot contain ci or cn elements, but only text and/or 
+presentation elements. PCDATA should render as if it were wrapped in 
+an mo. Mixed content: mrow which contains mo + presentation elements --> 
+<!-- <xsl:template match = "m:csymbol/m:*">
+  <xsl:choose>
+    <xsl:when test="self::m:cn or self::m:ci">
+      <xsl:apply-templates mode = "semantics"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select = "."/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:csymbol/text()">
+  <xsl:choose>
+    <xsl:when test=". &lt; 0 or . = 0 or . &gt; 0">
+      <m:mn> <xsl:copy-of select = "."/> </m:mn>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mi> <xsl:copy-of select = "."/> </m:mi>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template> -->
+
+
+<!-- ***************** BASIC CONTENT ELEMENTS ***************** -->
+
+<!-- HELM: the entity &#x2061; is not defined:                -->
+<!-- fn and domainofapplication are rendered as their content -->
+<xsl:template match = "m:apply[m:*[1][self::m:fn]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:fn/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:fn/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- fn has been deprecated, so now we use: -->
+<xsl:template match = "m:apply">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:domainofapplication">
+        <m:msub>
+          <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          </xsl:apply-templates>
+          <xsl:apply-templates select = "*[position()=2]" mode = "semantics"/>
+          </m:msub>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:domainofapplication/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:domainofapplication/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+          <m:mfenced separators=",">
+            <xsl:apply-templates select = "*[position()>2]" mode = "semantics"/>
+            </m:mfenced>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select = "*[position()=1]" mode = "semantics">
+              <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+            </xsl:apply-templates>
+            <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+            <m:mfenced separators=",">
+              <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+              </m:mfenced> 
+            </xsl:otherwise>
+          </xsl:choose>
+        </m:mrow>
+      </xsl:template>
+      
+      <xsl:template match = "m:domainofapplication">
+        <xsl:apply-templates select = "*[1]" mode = "semantics"/> 
+        </xsl:template>
+    
+      <xsl:template match = "m:fn">
+        <xsl:apply-templates select = "*[1]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        </xsl:apply-templates>
+      </xsl:template>
+      
+      <xsl:template match = "m:interval">
+        <m:mfenced separators=",">
+          <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+            <xsl:attribute name="xref">
+              <xsl:value-of select="@id"/>
+            </xsl:attribute>
+          </xsl:if>
+          <xsl:if test="@closure='closed' or @closure='closed-open'">
+            <xsl:attribute name="open">[</xsl:attribute>
+          </xsl:if>
+          <xsl:if test="@closure='closed' or @closure='open-closed'">
+            <xsl:attribute name="close">]</xsl:attribute>
+          </xsl:if>
+          <xsl:apply-templates select="*" mode = "semantics"/>
+          </m:mfenced>
+        </xsl:template>
+        
+        <xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
+          <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:inverse]]">
+  <xsl:choose>
+    <xsl:when test="*[2]=m:exp or *[2]=m:ln or *[2]=m:sin or *[2]=m:cos or
+                    *[2]=m:tan or *[2]=m:sec or *[2]=m:csc or *[2]=m:cot or
+                    *[2]=m:sinh or *[2]=m:cosh or *[2]=m:tanh or *[2]=m:sech or
+                    *[2]=m:csch or *[2]=m:coth or *[2]=m:arcsin or
+                    *[2]=m:arccos or *[2]=m:arctan">
+      <m:mo>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode="inverse"/>
+      </m:mo>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:msup>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select = "*[2]"/>
+        <m:mfenced>
+<!-- HELM: xref added -->        
+         <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:inverse/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:inverse/@id"/>
+          </xsl:attribute>
+         </xsl:if>
+         <m:mn>-1</m:mn>
+        </m:mfenced>
+      </m:msup>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "*" mode="inverse">
+  <xsl:choose>
+    <xsl:when test="self::m:exp">
+      <xsl:value-of select="'ln'"/>
+    </xsl:when>
+    <xsl:when test="self::m:ln">
+      <xsl:value-of select="'exp'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sin">
+      <xsl:value-of select="'arcsin'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cos">
+      <xsl:value-of select="'arccos'"/>
+    </xsl:when>
+    <xsl:when test="self::m:tan">
+      <xsl:value-of select="'arctan'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sec">
+      <xsl:value-of select="'arcsec'"/>
+    </xsl:when>
+    <xsl:when test="self::m:csc">
+      <xsl:value-of select="'arccsc'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cot">
+      <xsl:value-of select="'arccot'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sinh">
+      <xsl:value-of select="'arcsinh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:cosh">
+      <xsl:value-of select="'arccosh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:tanh">
+      <xsl:value-of select="'arctanh'"/>
+    </xsl:when>
+    <xsl:when test="self::m:sech">
+      <xsl:value-of select="'arcsech'"/>
+    </xsl:when>
+    <xsl:when test="self::m:csch">
+      <xsl:value-of select="'arccsch'"/>
+    </xsl:when>
+    <xsl:when test="self::m:coth">
+      <xsl:value-of select="'arccoth'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arcsin">
+      <xsl:value-of select="'sin'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arccos">
+      <xsl:value-of select="'cos'"/>
+    </xsl:when>
+    <xsl:when test="self::m:arctan">
+      <xsl:value-of select="'tan'"/>
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:sep"/>
+
+<xsl:template match = "m:condition">
+  <xsl:choose>
+    <xsl:when test="parent::m:apply[m:forall[1]]"/>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <m:mrow xref="{@id}">
+            <xsl:apply-templates select="*" mode = "semantics"/>
+          </m:mrow>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="not(*[2])">
+            <xsl:apply-templates select="*" mode = "semantics"/>
+          </xsl:if>
+          <xsl:if test="*[2]">
+            <m:mrow>
+              <xsl:apply-templates select="*" mode = "semantics"/>
+            </m:mrow>
+          </xsl:if>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:declare"/>
+
+<xsl:template match = "m:lambda">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x039B;</xsl:text> </m:mo>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text> </m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*">
+        <xsl:choose>
+          <xsl:when test="self::m:ci or self::m:cn">
+            <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <m:mrow>
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </m:mrow>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:apply[m:compose[1]]]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mfenced>
+ </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:compose]]">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "m:*[2][self::m:ci[@type='fn'] |
+                                       self::m:fn]" mode="semantics"/>
+    <xsl:for-each select = "m:*[position()>2][self::m:ci[@type='fn'] |
+                                                            self::m:fn]">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:compose/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:compose/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2218;</xsl:text></m:mo>
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:ident">
+  <xsl:choose>
+    <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <m:mo xref="{@id}">id</m:mo>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mo>id</m:mo>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="m:piecewise">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if> 
+    <xsl:element name="m:mfenced">
+      <xsl:attribute name="open">{</xsl:attribute>
+      <xsl:attribute name="close"></xsl:attribute>
+      <m:mtable groupalign="left left left">
+       <xsl:for-each select="m:piece">
+       <m:mtr columnalign="left">
+          <m:mtd>
+            <m:mrow>
+              <xsl:apply-templates select="*[position()=1]" mode = "semantics"/>
+            </m:mrow>
+          </m:mtd>
+          <m:mtd>
+              <m:mrow>
+                <m:mtext>if <m:mspace width="5"/></m:mtext>
+                <xsl:apply-templates select="*[position()=2]" mode = "semantics"/>
+              </m:mrow> 
+            </m:mtd>
+          </m:mtr>
+        </xsl:for-each>
+        <xsl:if test="m:otherwise">
+          <m:mtr columnalign="left">
+            <m:mtd>
+              <m:mrow>
+                <xsl:apply-templates select="m:otherwise/*" mode = "semantics"/>
+              </m:mrow>
+            </m:mtd>
+            <m:mtd>
+              <m:mrow>
+              otherwise  
+            </m:mrow>
+          </m:mtd>
+      </m:mtr>
+    </xsl:if>
+  </m:mtable>
+</xsl:element>
+</m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='domain']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:domain]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>domain</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='codomain']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:codomain]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>codomain</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='image']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:image]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mi>image</m:mi>
+    <m:mfenced open="(" close=")">
+      <xsl:apply-templates select="*[position()!=1]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** ARITHMETIC, ALGEBRA & LOGIC ***************** -->
+
+<xsl:template match = "m:apply[m:quotient[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em">
+      <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
+    </m:mo>
+    <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:quotient/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:quotient/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+      <m:mrow>
+        <xsl:apply-templates select="*[2]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        </xsl:apply-templates>
+      </m:mrow>
+      <m:mrow>
+        <xsl:apply-templates select="*[3]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </m:mfrac>
+    <m:mo form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em">
+     <xsl:text disable-output-escaping='yes'>&#x230A;</xsl:text>
+    </m:mo>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[*[1][self::m:exp]]">
+  <m:msup>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exp/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exp/@id"/>
+          </xsl:attribute>
+        </xsl:if>e</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:msup>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:factorial[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorial/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:factorial/@id"/>
+          </xsl:attribute>
+        </xsl:if>!</m:mo>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:max[1] | m:min[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar">
+      <m:munder>
+        <xsl:if test="*[1]=m:max">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+        </xsl:if>
+        <xsl:if test="*[1]=m:min">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:munder>
+      <xsl:if test="*[3]=m:condition">
+        <m:mfenced open="{{" close="}}" separators="">
+          <m:mfenced open="" close="" separators=",">
+            <xsl:for-each select = "*[position()>3]">
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </xsl:for-each>
+          </m:mfenced>
+          <m:mo>|</m:mo>
+          <xsl:apply-templates select="*[3]" mode = "semantics"/>
+        </m:mfenced>
+      </xsl:if>
+      <xsl:if test="not(*[3]=m:condition)">
+        <m:mfenced open="{{" close="}}" separators=",">
+          <xsl:for-each select = "*[position()>2]">
+            <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:for-each>
+        </m:mfenced>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="*[2]=m:condition">
+      <xsl:if test="*[1]=m:max">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:min">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+      </xsl:if>
+      <m:mfenced open="{{" close="}}" separators="">
+        <xsl:if test="*[3]">
+          <m:mfenced open="" close="" separators=",">
+            <xsl:for-each select = "*[position()>2]">
+              <xsl:apply-templates select = "." mode="semantics"/>
+            </xsl:for-each>
+          </m:mfenced>
+          <m:mo>|</m:mo>
+        </xsl:if>
+        <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:condition) and not(*[2]=m:bvar)">
+      <xsl:if test="*[1]=m:max">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:max/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:max/@id"/>
+          </xsl:attribute>
+        </xsl:if>max</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:min">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:min/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:min/@id"/>
+          </xsl:attribute>
+        </xsl:if>min</m:mo>
+      </xsl:if>
+      <m:mfenced open="{{" close="}}" separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $MINUS_PREC or $IN_PREC=$MINUS_PREC and
+                                                        $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="minus">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="minus">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="minus">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:minus[1]]" mode="minus">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:if test="not(*[3])">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:minus/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:if>
+  <xsl:if test="*[3]">
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+    </xsl:apply-templates>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:minus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:minus/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+    <xsl:apply-templates select="*[3]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and
+                                                      $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="plus">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="plus">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="plus">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:plus[1]]" mode="plus">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:if test="*[2]">
+    <xsl:apply-templates select="*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+    </xsl:apply-templates>
+    <xsl:for-each select = "*[position()>2]">
+      <xsl:choose>
+        <xsl:when test=". &lt; 0">
+          <m:mo>-</m:mo>
+          <m:mn> <xsl:value-of select="-."/> </m:mn>
+        </xsl:when>
+        <xsl:when test="self::m:apply[m:minus[1]] and not(*[3])">
+          <xsl:apply-templates select="." mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:plus/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:plus/@id"/>
+          </xsl:attribute>
+        </xsl:if>+</m:mo>
+          <xsl:apply-templates select="." mode = "semantics">
+            <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
+            <xsl:with-param name="PAREN" select="$PAREN"/>
+            <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:for-each>
+  </xsl:if>
+</xsl:template>
+
+<!-- HELM WARNING: power id is lost!                              -->
+<!-- msup should maintain the power definitionURL info but also the 
+     reference to apply                                           -->
+<xsl:template match = "m:apply[m:power[1]]">
+  <xsl:choose>
+    <xsl:when test="*[2]=m:apply[m:ln[1] | m:log[1] | m:abs[1] |
+                         m:gcd[1] | m:lcm[1] | m:sin[1] | m:cos[1] | m:tan[1] |
+                         m:sec[1] | m:csc[1] | m:cot[1] | m:sinh[1] |
+                         m:cosh[1] | m:tanh[1] | m:sech[1] | m:csch[1] |
+                         m:coth[1] | m:arcsin[1] | m:arccos[1] |
+                         m:arctan[1] | m:arcsec[1] | m:arccsc[1] | 
+                         m:arccot[1] | m:arcsinh[1] | m:arccosh[1] |
+                         m:arctanh[1] | m:arcsech[1] | m:arccsch [1]|
+                         m:arccoth[1] ]">
+      <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:msup>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select = "*[2]" mode = "semantics">
+          <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+        </xsl:apply-templates>
+        <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and
+                                                    $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="remdiv">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="remdiv">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="remdiv">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:rem[1] | m:divide[1]]" mode="remdiv">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+      <xsl:with-param name="PARAM" select="$PARAM"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <m:mo>
+    <xsl:if test="m:rem">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rem/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:rem/@id"/>
+          </xsl:attribute>
+        </xsl:if>      
+      <xsl:value-of select="'%'"/>
+    </xsl:if>
+    <xsl:if test="m:divide">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divide/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:divide/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+      <xsl:value-of select="'/'"/>
+    </xsl:if>
+  </m:mo>
+  <xsl:apply-templates select = "*[3]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
+    <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+  </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and
+                                                    $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="times">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="times">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="times">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:times[1]]" mode="times">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:if test="*[3]">
+    <xsl:for-each select = "*[position()>2]">
+<!-- HELM: to distinguish between * and the application -->
+<!-- Was:
+      <m:mo><xsl:text disable-output-escaping='yes'>&#x2062;</xsl:text></m:mo>
+     Now is: -->
+     <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:times/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:times/@id"/>
+          </xsl:attribute>
+        </xsl:if>*</m:mo>
+      <xsl:apply-templates select="." mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+    </xsl:for-each>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:root[1]]">
+  <m:msqrt>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:degree">
+      <xsl:apply-templates select="*[3]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+      <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree)">
+      <xsl:apply-templates select="*[2]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+      </xsl:apply-templates>
+      <m:mn>2</m:mn>
+    </xsl:if>
+  </m:msqrt>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:gcd[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:gcd/@id"/>
+          </xsl:attribute>
+        </xsl:if>gcd</m:mo>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:gcd/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:gcd/@id"/>
+          </xsl:attribute>
+        </xsl:if>gcd</m:mo>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:if>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $AND_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="and">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="and">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="and">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:and[1]]" mode="and">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:and/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:and/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2227;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $OR_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="or">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="or">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="or">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:or[1]]" mode="or">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo> 
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:or/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:or/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2228;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $XOR_PREC">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="xor">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAR_YES"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                                                and not($SEM_SW=$SEM_ALL)">
+      <xsl:apply-templates select="." mode="xor">
+        <xsl:with-param name="PARAM" select="$IN_PREC"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="xor">
+          <xsl:with-param name="PARAM" select="$IN_PREC"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:xor[1]]" mode="xor">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select="*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:xor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:xor/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x22BB;</xsl:text></m:mo>
+    <xsl:apply-templates select="." mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:not[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+<!-- HELM: was <m:mo>not</m:mo> 
+     Now is -->
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:not/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:not/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x000AC;</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:forall[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:forall/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:forall/@id"/>
+          </xsl:attribute>
+        </xsl:if>for all</m:mo>
+    <xsl:if test="count(m:bvar) &gt; 1">
+      <m:mfenced separators=",">
+        <xsl:for-each select = "m:bvar">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="count(m:bvar)=1">
+      <xsl:apply-templates select = "m:bvar" mode="semantics"/>
+    </xsl:if>
+    <xsl:if test="m:condition">
+      <m:mo>:</m:mo>
+      <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+      <m:mo>,</m:mo>
+    </xsl:if>
+    <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
+                                not(self::m:condition)]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:exists[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exists/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exists/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x2203;</xsl:text> </m:mo>
+    <xsl:if test="count(m:bvar) &gt; 1">
+      <m:mfenced separators=",">
+        <xsl:for-each select = "m:bvar">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+    <xsl:if test="count(m:bvar)=1">
+      <xsl:apply-templates select = "m:bvar" mode="semantics"/>
+    </xsl:if>
+    <xsl:if test="m:condition">
+      <m:mo>,</m:mo>
+      <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="*[position()>1 and not(self::m:bvar) and not(self::m:condition)]">
+      <m:mo>:</m:mo>
+      <xsl:apply-templates select = "*[position()>1 and not(self::m:bvar) and
+                                not(self::m:condition)]" mode = "semantics"/>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM WARNING: abs id was lost! -->
+<xsl:template match = "m:apply[m:abs[1]]">
+  <xsl:if test="not(parent::m:apply[m:power[1]])">
+<!-- HELM: was
+    <m:mfenced open="|" close="|" separators="">
+     Now is: mrow + mo -->
+     <m:mrow>
+      <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+        <xsl:attribute name="xref">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+      </xsl:if>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo>
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+<!-- HELM: </m:mfenced> -->
+     </m:mrow>
+  </xsl:if>
+  <xsl:if test="parent::m:apply[m:power[1]]">
+    <m:msup>
+<!-- HELM: was
+      <m:mfenced open="|" close="|" separators="">
+     Now is: mrow + mo -->
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+        <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:abs/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:abs/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</m:mo> 
+<!-- HELM: </m:mfenced> -->
+      </m:mrow>
+      <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+    </m:msup>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:conjugate[1]]">
+  <m:mover>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mrow>
+      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
+    </m:mrow>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:conjugate/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:conjugate/@id"/>
+          </xsl:attribute>
+        </xsl:if><xsl:text disable-output-escaping='yes'>&#x0332;</xsl:text> </m:mo>
+  </m:mover>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+      <xsl:if test="m:arg">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:arg/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:arg/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Arg'"/>
+      </xsl:if>
+      <xsl:if test="m:real">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:real/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:real/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Re'"/>
+      </xsl:if>
+      <xsl:if test="m:imaginary">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginary/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:imaginary/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'Im'"/>
+      </xsl:if>
+    </m:mo>
+    <m:mfenced separators="">
+      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='lcm']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:lcm]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lcm/@id"/>
+          </xsl:attribute>
+        </xsl:if>lcm</m:mo>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lcm/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lcm/@id"/>
+          </xsl:attribute>
+        </xsl:if>lcm</m:mo>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+        </m:msup>
+      </xsl:if>
+      <m:mfenced separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+          </xsl:for-each>
+        </m:mfenced>
+      </m:mrow>
+    </xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='floor']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:floor]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:floor/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&LeftFloor;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x230A;</xsl:text>
+    </m:mo>
+    <xsl:apply-templates select="child::*[position()=last()]" mode="semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:floor/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:floor/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&RightFloor;]]> -->
+<xsl:text disable-output-escaping="yes">&#x230B;</xsl:text>
+    </m:mo>
+</m:mrow>
+</xsl:template>
+
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='ceiling']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:ceiling]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ceiling/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&LeftCeiling;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x2308;</xsl:text>
+    </m:mo>
+    <xsl:apply-templates select="child::*[position()=last()]"  mode="semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ceiling/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ceiling/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&RightCeiling;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x2309;</xsl:text>
+    </m:mo>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** RELATIONS ***************** -->
+
+<xsl:template match = "m:apply[m:neq | m:approx | m:tendsto | m:implies
+                     | m:in | m:notin | m:notsubset | m:notprsubset
+                     | m:subset | m:prsubset | m:eq | m:gt | m:lt
+                     | m:geq | m:leq | m:equivalent | m:factorof]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:factorof or *[1]=m:tendsto or
+                  *[1]=m:implies or *[1]=m:in or *[1]=m:notin or
+                  *[1]=m:notsubset or *[1]=m:notprsubset">
+      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+      <m:mo>
+        <xsl:if test="*[1]=m:neq">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:neq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:neq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2260;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:approx">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:approx/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:approx/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x224A;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:factorof">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:factorof/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:factorof/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          |
+        </xsl:if>
+        <xsl:if test="*[1]=m:tendsto">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:implies">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:implies/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:implies/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x21D2;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:in">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:in/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:in/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <xsl:text disable-output-escaping='yes'>&#x2208;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notin">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notin/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notin/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2209;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notsubset">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2284;</xsl:text>
+        </xsl:if>
+        <xsl:if test="*[1]=m:notprsubset">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notprsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notprsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+         <xsl:text disable-output-escaping='yes'>&#x2288;</xsl:text>
+        </xsl:if>
+      </m:mo>
+      <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>-</m:mo>
+      </xsl:if>
+      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:tendsto/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:tendsto/@id"/>
+          </xsl:attribute>
+        </xsl:if>+</m:mo>
+      </xsl:if>
+    </xsl:if>
+    <xsl:if test="*[1]=m:subset or *[1]=m:prsubset or *[1]=m:eq or *[1]=m:gt
+               or *[1]=m:lt or *[1]=m:geq or *[1]=m:leq or *[1]=m:equivalent">
+      <xsl:apply-templates select = "*[2]" mode="semantics"/>
+      <xsl:for-each select = "*[position()>2]">
+        <m:mo>
+          <xsl:if test="../*[self::m:subset][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:subset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:subset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:text disable-output-escaping='yes'>&#x2286;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:prsubset][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:prsubset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:prsubset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2282;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:eq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:eq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:eq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'='"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:gt][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:gt/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:gt/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'&gt;'"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:lt][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:lt/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:lt/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+            <xsl:value-of select="'&lt;'"/>
+          </xsl:if>
+          <xsl:if test="../*[self::m:geq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:geq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:geq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2265;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:leq][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:leq/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:leq/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2264;</xsl:text>
+          </xsl:if>
+          <xsl:if test="../*[self::m:equivalent][1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:equivalent/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:equivalent/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+           <xsl:text disable-output-escaping='yes'>&#x2261;</xsl:text>
+          </xsl:if>
+        </m:mo>
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** CALCULUS ***************** -->
+
+<xsl:template match = "m:apply[*[1][self::m:ln]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="parent::m:apply[m:power[1]]">
+        <m:msup>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ln/@id"/>
+          </xsl:attribute>
+        </xsl:if>ln</m:mo>
+          <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+        </m:msup>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:ln/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:ln/@id"/>
+          </xsl:attribute>
+        </xsl:if>ln</m:mo>
+      </xsl:otherwise>
+    </xsl:choose>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:log[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="parent::m:apply[m:power[1]]">
+        <xsl:if test="not(*[2]=m:logbase)">
+          <m:msup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+          </m:msup>
+        </xsl:if>
+        <xsl:if test="*[2]=m:logbase">
+          <m:msubsup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+            <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+          </m:msubsup>
+        </xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="not(*[2]=m:logbase)">
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+        </xsl:if>
+        <xsl:if test="*[2]=m:logbase">
+          <m:msub>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:log/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:log/@id"/>
+          </xsl:attribute>
+        </xsl:if>log</m:mo>
+            <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
+          </m:msub>
+        </xsl:if>
+      </xsl:otherwise>
+    </xsl:choose>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:if test="*[2]=m:logbase">
+      <xsl:apply-templates select = "*[3]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      </xsl:apply-templates>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:logbase)">
+      <xsl:apply-templates select = "*[2]" mode = "semantics">
+        <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      </xsl:apply-templates>
+    </xsl:if>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:diff[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
+      <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:diff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:msup>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+        </m:msup>
+        <m:mrow>
+          <m:mo>d</m:mo>
+          <m:msup>
+            <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+            <xsl:apply-templates select = "m:bvar/m:degree" mode = "semantics"/>
+          </m:msup>
+        </m:mrow>
+      </m:mfrac>
+    </xsl:if>
+    <xsl:if test="*[2]=m:bvar and not(m:bvar[*[2]=m:degree])">
+      <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:diff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:diff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <m:mo>d</m:mo>
+        <m:mrow>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select = "m:bvar/*[1]" mode = "semantics"/>
+        </m:mrow>
+      </m:mfrac>
+    </xsl:if>
+    <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:partialdiff[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select = "m:bvar">
+      <xsl:if test="*[last()]=m:degree">
+        <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:partialdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <m:msup>
+             <m:mo>d</m:mo>
+             <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+          </m:msup>
+          <m:mrow>
+            <m:mo>d</m:mo>
+            <m:msup>
+              <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+              <xsl:apply-templates select = "m:degree" mode = "semantics"/>
+            </m:msup>
+          </m:mrow>
+        </m:mfrac>
+      </xsl:if>
+      <xsl:if test="not(*[last()]=m:degree)">
+        <m:mfrac>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:partialdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:partialdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+          <m:mo>d</m:mo>
+          <m:mrow>
+            <m:mo>d</m:mo>
+            <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+          </m:mrow>
+        </m:mfrac>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:apply-templates select = "*[last()]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:lowlimit | m:uplimit | m:bvar | m:degree | m:logbase">
+  <xsl:apply-templates select="*" mode = "semantics"/>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+      <xsl:if test="*[1]=m:divergence">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:divergence/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:divergence/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'div'"/>
+      </xsl:if>
+      <xsl:if test="*[1]=m:grad">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:grad/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:grad/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'grad'"/>
+      </xsl:if>
+      <xsl:if test="*[1]=m:curl">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:curl/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:curl/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:value-of select="'curl'"/>
+      </xsl:if>
+    </m:mo>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:ci">
+        <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mfenced separators="">
+          <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+        </m:mfenced>
+      </xsl:otherwise>
+    </xsl:choose>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:laplacian[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:msup>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:laplacian/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:laplacian/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:text disable-output-escaping='yes'>&#x0394;</xsl:text></m:mo>
+      <m:mn>2</m:mn>
+    </m:msup>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** SET THEORY ***************** -->
+
+<xsl:template match = "m:set | m:list">
+  <m:mfenced open="{{" close="}}" separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="*[1]=m:bvar and *[2]=m:condition">
+      <xsl:apply-templates select="m:bvar" mode = "semantics"/>
+      <m:mo>|</m:mo>
+      <xsl:apply-templates select="m:condition" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="*[1]=m:condition and not(child::m:bvar)">
+      <m:mfenced open="" close="" separators=",">
+        <xsl:for-each select = "*[not(self::m:condition) and not(self::m:bvar)]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+      <m:mo>|</m:mo>
+      <xsl:apply-templates select="m:condition" mode = "semantics"/>
+    </xsl:if>
+    <xsl:if test="not(child::m:bvar) and not(child::m:condition)">
+      <m:mfenced open="" close="" separators=",">
+        <xsl:for-each select = "*">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+    </xsl:if>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC
+                    and $PARAM=$PAR_SAME and not($IN_OP=$UNION_OP)">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="union">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="union">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="union">
+          <xsl:with-param name="IN_OP" select="$UNION_OP"/>
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:union[1]]" mode="union">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode="semantics">
+    <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:union/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:union/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x22C3;</m:mo>
+<!-- HELM: not rendered correctly <![CDATA[&Union;]]> -->
+  <!--   <xsl:text disable-output-escaping="yes">&#x22C3;</xsl:text></m:mo>-->
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
+      <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
+      <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC or $IN_PREC=$INTERSECT_PREC
+                    and $PARAM=$PAR_SAME and not($IN_OP=$INTERSECT_OP)">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="intersect">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="intersect">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="intersect">
+          <xsl:with-param name="IN_OP" select="$INTERSECT_OP"/>
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
+  <xsl:param name="IN_OP" select="$DOESNT_MATTER"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode="semantics">
+    <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:intersect/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:intersect/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Intersection;]]> -->
+      <xsl:text disable-output-escaping="yes">&#x22C2;</xsl:text></m:mo>
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>    <!--new-->
+      <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
+      <xsl:with-param name="IN_OP" select="$UNION_OP"/>    <!--new-->
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC
+                    and $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="setdiff">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="setdiff">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="setdiff">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:setdiff[1]]" mode="setdiff">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:setdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>\</m:mo>
+  <xsl:apply-templates select = "*[3]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
+    <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+  </xsl:apply-templates>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:cartesianproduct[1]]">
+  <xsl:param name="IN_PREC" select="$NO_PREC"/>
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:choose>
+    <xsl:when test="$IN_PREC &gt; $CARTPROD_PREC or $IN_PREC=$CARTPROD_PREC
+                    and $PARAM=$PAR_SAME">
+      <m:mfenced separators="">
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cartprod">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mfenced>
+    </xsl:when>
+    <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $FUNCTION_PREC
+                    and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
+                    and not($SEM_SW=$SEM_XREF_EXT)">
+      <xsl:apply-templates select="." mode="cartprod">
+        <xsl:with-param name="PARAM" select="$PARAM"/>
+        <xsl:with-param name="PAREN" select="$PAREN"/>
+        <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <m:mrow>
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="@id"/>
+          </xsl:attribute>
+        </xsl:if>
+        <xsl:apply-templates select="." mode="cartprod">
+          <xsl:with-param name="PARAM" select="$PARAM"/>
+          <xsl:with-param name="PAREN" select="$PAREN"/>
+          <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+        </xsl:apply-templates>
+      </m:mrow>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:cartesianproduct[1]]" mode="cartprod">
+  <xsl:param name="PARAM" select="$NO_PARAM"/>
+  <xsl:param name="PAREN" select="$PAR_NO"/>
+  <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
+  <xsl:apply-templates select = "*[2]" mode = "semantics">
+    <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
+    <xsl:with-param name="PARAM" select="$PARAM"/>
+    <xsl:with-param name="PAREN" select="$PAREN"/>
+    <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
+  </xsl:apply-templates>
+  <xsl:for-each select = "*[position()>2]">
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and ../m:cartesianproduct/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="../m:cartesianproduct/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&times;]]> -->
+     <xsl:text disable-output-escaping="yes">&#x00D7;</xsl:text></m:mo>
+    <xsl:apply-templates select = "." mode="semantics">
+      <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
+      <xsl:with-param name="PARAM" select="$PAR_SAME"/>
+      <xsl:with-param name="PAREN" select="$PAREN"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </xsl:for-each>
+</xsl:template>
+
+<!-- HELM WARNING: card id was lost! -->
+<xsl:template match = "m:apply[m:card[1]]">
+<!-- HELM: was
+  <m:mfenced open="|" close="|" separators=",">
+     Now is: mrow + mo -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:card/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:card/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</mo>
+    <xsl:for-each select = "*[position()>1]">
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+     <mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:setdiff/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:setdiff/@id"/>
+          </xsl:attribute>
+        </xsl:if>|</mo>
+  </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+
+<!-- ***************** SEQUENCES AND SERIES ***************** -->
+
+<xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
+        <m:munderover>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sum/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+             <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:product/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+             <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <m:mrow>
+            <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+            <m:mo>=</m:mo>
+            <xsl:apply-templates select = "m:lowlimit" mode = "semantics"/>
+          </m:mrow>
+          <xsl:apply-templates select = "m:uplimit" mode = "semantics"/>
+        </m:munderover>
+        <xsl:apply-templates select = "*[5]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:when test="*[2]=m:bvar and *[3]=m:condition">
+        <m:munder>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+             <xsl:text disable-output-escaping='yes'>&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+             <xsl:text disable-output-escaping='yes'>&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </m:munder>
+        <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+      </xsl:when>
+      <xsl:when test="*[2]=m:domainofapplication">
+        <m:munder>
+          <m:mo>
+            <xsl:if test="*[1]=m:sum">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sum/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sum/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Sum;]]> -->
+              <xsl:text disable-output-escaping="yes">&#x2211;</xsl:text>
+            </xsl:if>
+            <xsl:if test="*[1]=m:product">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:product/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:product/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Product;]]> -->
+              <xsl:text disable-output-escaping="yes">&#x220F;</xsl:text>
+            </xsl:if>
+          </m:mo>
+          <xsl:apply-templates select="m:domainofapplication" mode = "semantics"/>
+        </m:munder>
+        <m:mrow>
+          <xsl:apply-templates select="*[position()=last()]" mode = "semantics"/>
+          </m:mrow>
+        </xsl:when>
+      </xsl:choose>
+    </m:mrow>
+  </xsl:template>
+  
+<!-- HELM: was (it didn't match with prefixed MathML)
+<xsl:template match="m:apply[child::*[position()=1 and name()='int']]">
+     Now is: -->
+<xsl:template match="m:apply[child::*[position()=1 and self::m:int]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+    <xsl:when test="m:condition">
+      <m:msub>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+        <xsl:apply-templates select="m:condition" mode="semantics"/>
+      </m:msub>
+      <m:mrow>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+      </m:mrow>
+      <m:mrow>
+        <m:mo>d</m:mo>
+        <xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </m:mrow>
+    </xsl:when>
+    <xsl:when test="m:domainofapplication">
+      <m:msub>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+        <xsl:apply-templates select="m:domainofapplication" mode="semantics"/>
+      </m:msub>
+      <m:mrow>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics" />
+      </m:mrow>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="m:interval">
+          <m:msubsup>
+            <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+             <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+            <xsl:apply-templates select="m:interval/*[position()=1]" mode="semantics" />
+            <xsl:apply-templates select="m:interval/*[position()=2]" mode="semantics"/>
+          </m:msubsup>
+          <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+          <m:mo>d</m:mo>
+          <xsl:apply-templates select="m:bvar" mode="semantics"/>
+        </xsl:when>
+        <xsl:when test="m:lowlimit">
+        <m:msubsup>
+          <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+           <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+          <m:mrow><xsl:apply-templates select="m:lowlimit" mode="semantics"/></m:mrow>
+          <m:mrow><xsl:apply-templates select="m:uplimit" mode="semantics"/></m:mrow>
+        </m:msubsup>
+        <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+        <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:int/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:int/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&Integral;]]> -->
+         <xsl:text disable-output-escaping="yes">&#x222B;</xsl:text></m:mo>
+       <xsl:apply-templates select="*[position()=last()]" mode="semantics"/>
+       <m:mo>d</m:mo><xsl:apply-templates select="m:bvar" mode="semantics"/>
+      </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+    </xsl:choose>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:limit[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:munder>
+      <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:lim/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:lim/@id"/>
+          </xsl:attribute>
+        </xsl:if>lim</m:mo>
+      <m:mrow>
+        <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
+            <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+            <m:mo><xsl:text disable-output-escaping='yes'>&#x2192;</xsl:text></m:mo>
+            <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </xsl:if>
+        <xsl:if test="*[2]=m:bvar and *[3]=m:condition">
+          <xsl:apply-templates select = "*[3]" mode = "semantics"/>
+        </xsl:if>
+      </m:mrow>
+    </m:munder>
+    <xsl:apply-templates select = "*[4]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** TRIGONOMETRY ***************** -->
+
+<xsl:template match = "m:apply[*[1][self::m:sin | self::m:cos |
+                       self::m:tan | self::m:sec | self::m:csc |
+                       self::m:cot | self::m:sinh | self::m:cosh |
+                       self::m:tanh | self::m:sech | self::m:csch |
+                       self::m:coth | self::m:arcsin | self::m:arccos |
+                       self::m:arctan | self::m:arcsec | self::m:arccsc | 
+                       self::m:arccot | self::m:arcsinh | self::m:arccosh |
+                       self::m:arctanh | self::m:arcsech | self::m:arccsch |
+                       self::m:arccoth ] ]">
+                        
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:if test="not(parent::m:apply[m:power[1]])">
+      <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+    </xsl:if>
+    <xsl:if test="parent::m:apply[m:power[1]]">
+      <m:msup>
+        <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
+        <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
+      </m:msup>
+    </xsl:if>
+    <m:mo><xsl:text disable-output-escaping='yes'>&#x2061;</xsl:text></m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics">
+      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
+      <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
+    </xsl:apply-templates>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "*" mode="trigonometry">
+  <m:mo>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:choose>
+      <xsl:when test="self::m:sin">
+        <xsl:value-of select="'sin'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cos">
+        <xsl:value-of select="'cos'"/>
+      </xsl:when>
+      <xsl:when test="self::m:tan">
+        <xsl:value-of select="'tan'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sec">
+        <xsl:value-of select="'sec'"/>
+      </xsl:when>
+      <xsl:when test="self::m:csc">
+        <xsl:value-of select="'csc'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cot">
+        <xsl:value-of select="'cot'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sinh">
+        <xsl:value-of select="'sinh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:cosh">
+        <xsl:value-of select="'cosh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:tanh">
+        <xsl:value-of select="'tanh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:sech">
+        <xsl:value-of select="'sech'"/>
+      </xsl:when>
+      <xsl:when test="self::m:csch">
+        <xsl:value-of select="'csch'"/>
+      </xsl:when>
+      <xsl:when test="self::m:coth">
+        <xsl:value-of select="'coth'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsin">
+        <xsl:value-of select="'arcsin'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccos">
+        <xsl:value-of select="'arccos'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arctan">
+        <xsl:value-of select="'arctan'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsec">
+        <xsl:value-of select="'arcsec'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccsc">
+        <xsl:value-of select="'arccsc'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccot">
+        <xsl:value-of select="'arccot'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsinh">
+        <xsl:value-of select="'arcsinh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccosh">
+        <xsl:value-of select="'arccosh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arctanh">
+        <xsl:value-of select="'arctanh'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arcsech">
+        <xsl:value-of select="'arcsech'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccsch">
+        <xsl:value-of select="'arccsch'"/>
+      </xsl:when>
+      <xsl:when test="self::m:arccoth">
+        <xsl:value-of select="'arccot'"/>
+      </xsl:when>
+    </xsl:choose>
+  </m:mo>
+</xsl:template>
+
+
+<!-- ***************** STATISTICS ***************** -->
+
+<!-- HELM WARNING: mean id was lost! -->
+<xsl:template match = "m:apply[m:mean[1]]">
+<!-- HELM: was
+  <m:mfenced open="&lt;" close="&gt;" separators=",">
+     Now is: mrow + mo + separator (mo) -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003C;</m:mo>
+    <xsl:for-each select = "*[position()>1]">
+<!-- HELM: if added -->
+      <xsl:if test="position() != 1">
+       <m:mo separator="true">,</m:mo>
+      </xsl:if> 
+      <xsl:apply-templates select = "." mode="semantics"/>
+    </xsl:for-each>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003E;</m:mo>
+   </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+<xsl:template match = "m:apply[m:sdev[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:sdev/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:sdev/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+     <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:variance[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:variance/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:variance/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+     <xsl:text disable-output-escaping='yes'>&#x03C3;</xsl:text></m:mo>
+    <m:msup>
+      <m:mfenced separators=",">
+        <xsl:for-each select = "*[position()>1]">
+          <xsl:apply-templates select = "." mode="semantics"/>
+        </xsl:for-each>
+      </m:mfenced>
+      <m:mn>2</m:mn>
+    </m:msup>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:median[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:median/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:median/@id"/>
+          </xsl:attribute>
+        </xsl:if>median</m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:mode[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mode/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mode/@id"/>
+          </xsl:attribute>
+        </xsl:if>mode</m:mo>
+    <m:mfenced separators=",">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </m:mfenced>
+  </m:mrow>
+</xsl:template>
+
+<!-- HELM WARNING: mean id was lost! -->
+<xsl:template match = "m:apply[m:moment[1]]">
+<!-- HELM: was
+  <m:mfenced open="&lt;" close="&gt;" separators="">
+     Now is: mrow + mo -->
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:moment/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:momemt/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003C;</m:mo>
+    <xsl:if test="*[2]=m:degree and not(*[3]=m:momentabout)">
+      <m:msup>
+        <xsl:apply-templates select="*[3]" mode = "semantics"/>
+          <xsl:apply-templates select="*[2]" mode = "semantics"/>
+          </m:msup>
+        </xsl:if>
+        <xsl:if test="*[2]=m:degree and *[3]=m:momentabout">
+          <m:msup>
+            <xsl:apply-templates select="*[4]" mode = "semantics"/>
+            <xsl:apply-templates select="*[2]" mode = "semantics"/>
+      </m:msup>  
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree) and *[2]=m:momentabout">
+       <xsl:for-each select = "*[position()>2]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(*[2]=m:degree) and not(*[2]=m:momentabout)">
+      <xsl:for-each select = "*[position()>1]">
+        <xsl:apply-templates select = "." mode="semantics"/>
+      </xsl:for-each>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:mean/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:mean/@id"/>
+          </xsl:attribute>
+        </xsl:if>&#x003E;</m:mo>
+  </m:mrow>
+<!-- HELM:  </m:mfenced> -->
+</xsl:template>
+
+
+<!-- ***************** LINEAR ALGEBRA ***************** -->
+
+<xsl:template match="m:vector">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mtable>
+      <xsl:for-each select="*">
+        <m:mtd>
+          <xsl:apply-templates select="." mode = "semantics"/>
+        </m:mtd>
+      </xsl:for-each>
+    </m:mtable>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrix">
+  <m:mfenced separators="">
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mtable>
+      <xsl:apply-templates select="*" mode = "semantics"/>
+    </m:mtable>
+  </m:mfenced>
+</xsl:template>
+
+<xsl:template match = "m:matrixrow">
+  <m:mtr>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:for-each select="*">
+      <m:mtd>
+        <xsl:apply-templates select="." mode = "semantics"/>
+      </m:mtd>
+    </xsl:for-each>
+  </m:mtr>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:determinant[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:determinant/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:determinant/@id"/>
+          </xsl:attribute>
+        </xsl:if>det</m:mo>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:transpose[1]]">
+  <m:msup>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+    <m:mo>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:transpose/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:transpose/@id"/>
+          </xsl:attribute>
+        </xsl:if>T</m:mo>
+  </m:msup>
+</xsl:template>
+
+<!-- HELM: ERROR, this template generates the selected content elements
+     and doesn't generate the presentation for selector                 -->
+<!--<xsl:template match = "m:apply[m:selector[1]]">
+  <xsl:if test="*[2]=m:matrix and *[3]=m:cn">
+      <xsl:variable name="m" select = "*[3]"/>
+      <xsl:choose>
+        <xsl:when test="*[4]=m:cn">
+          <xsl:variable name="n" select = "*[4]"/>
+          <xsl:copy-of select = "m:matrix/*[position()=$m]/*[position()=$n]"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:copy-of select = "m:matrix/*[position()=$m]"/>
+        </xsl:otherwise>
+      </xsl:choose>
+  </xsl:if>
+  <xsl:if test="(*[2]=m:vector or *[2]=m:list) and *[3]=m:cn">
+    <xsl:variable name="m" select = "*[3]"/>
+    <xsl:copy-of select = "*[2]/*[position()=$m]"/>
+  </xsl:if>
+</xsl:template> -->
+
+<xsl:template match = "m:apply[m:selector[1]]">
+   <msub>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+     <xsl:attribute name="xref">
+      <xsl:value-of select="@id"/>
+     </xsl:attribute>
+    </xsl:if> 
+    <xsl:apply-templates select = "*[2]" mode="semantics"/>
+    <m:mrow>
+     <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:selector/@id">
+      <xsl:attribute name="xref">
+       <xsl:value-of select="m:selector/@id"/>
+      </xsl:attribute>
+     </xsl:if>
+     <xsl:choose>
+     <xsl:when test="*[3]=m:cn">
+      <xsl:apply-templates select = "*[3]" mode="semantics"/>
+     </xsl:when>
+     <xsl:otherwise>
+      <m:mi>*</m:mi>
+     </xsl:otherwise>
+     </xsl:choose> 
+     <xsl:if test="*[2]=m:matrix and *[4]=m:cn">
+      <xsl:apply-templates select = "*[4]" mode="semantics"/>
+     </xsl:if>
+    </m:mrow>
+   </msub>
+</xsl:template>
+
+<xsl:template match = "m:apply[m:vectorproduct[1] |
+                                 m:scalarproduct[1] | m:outerproduct[1]]">
+  <m:mrow>
+    <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+      <xsl:attribute name="xref">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
+    </xsl:if>
+    <xsl:apply-templates select="*[2]" mode = "semantics"/>
+    <m:mo>
+      <xsl:if test="m:vectorproduct[1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:vectorproduct/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:vectorproduct/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+       <xsl:text disable-output-escaping='yes'>&#x2A2F;</xsl:text>
+      </xsl:if>
+      <xsl:if test="m:scalarproduct[1] | m:outerproduct[1]">
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and *[1]/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="*[1]/@id"/>
+          </xsl:attribute>
+        </xsl:if>           
+        <xsl:value-of select="'.'"/>
+      </xsl:if>
+    </m:mo>
+    <xsl:apply-templates select="*[3]" mode = "semantics"/>
+  </m:mrow>
+</xsl:template>
+
+
+<!-- ***************** CONSTANT and SYMBOL ELEMENTS ***************** -->
+
+<xsl:template match="m:integers">
+   <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:integers/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:integers/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+    <xsl:text disable-output-escaping='yes'>&#x2124;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:reals">
+   <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:reals/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:reals/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+    <xsl:text disable-output-escaping='yes'>&#x211D;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:rationals">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:rationals/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:rationals/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x211A;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:naturalnumbers">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:naturalnumbers/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:naturalnumbers/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2115;</xsl:text></m:mi> 
+</xsl:template>
+
+<xsl:template match="m:complexes">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:complexes/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:complexes/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2102;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:primes">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:primes/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:primes/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping='yes'>&#x2119;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:exponentiale">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:exponentiale/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:exponentiale/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+   <xsl:text disable-output-escaping="yes">&#x2147;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:imaginaryi">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:imaginaryi/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:imaginaryi/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&ImaginaryI;]]> -->
+   <xsl:text disable-output-escaping="yes">&#xF74E;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:notanumber">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:notanumber/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:notanumber/@id"/>
+          </xsl:attribute>
+        </xsl:if>NaN</m:mi>  
+</xsl:template>
+
+<xsl:template match="m:true">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:true/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:true/@id"/>
+          </xsl:attribute>
+        </xsl:if>true</m:mi>  
+</xsl:template>
+
+<xsl:template match="m:false">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:false/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:false/@id"/>
+          </xsl:attribute>
+        </xsl:if>false</m:mi>   
+</xsl:template>
+
+<xsl:template match="m:emptyset">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:emptyset/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:emptyset/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&empty;]]> -->
+   <xsl:text disable-output-escaping="yes">&#xE2D3;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:pi">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:pi/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:pi/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&pi;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x03C0;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:eulergamma">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:eulergamma/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:eulergamma/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&gamma;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x03B3;</xsl:text></m:mi>
+</xsl:template>
+
+<xsl:template match="m:infinity">
+  <m:mi>
+<!-- HELM: xref added -->        
+        <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and m:infinity/@id">
+          <xsl:attribute name="xref">
+            <xsl:value-of select="m:infinity/@id"/>
+          </xsl:attribute>
+        </xsl:if>
+<!-- HELM: not rendered correctly <![CDATA[&infin;]]> -->
+   <xsl:text disable-output-escaping="yes">&#x221E;</xsl:text></m:mi>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
index 3ebf23ba7d41069148733fde635a124e6054ea95..babc7f41db0ff8e37626b736269fd2f05e406236 100644 (file)
@@ -36,7 +36,7 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                               xmlns:m="http://www.w3.org/1998/Math/MathML">
 
-<xsl:import href="mmlctop.xsl-0.14"/>
+<xsl:import href="mmlctop.xsl"/>
 
 
 <!-- *********************************** -->
index 8028625ceff8209991ace0b6f472d592500274d6..f2e42135f733b2fd9243f86368cd2b4720fc1d67 100644 (file)
@@ -22,7 +22,7 @@ mk_dep_graph.xsl
 mk_meta_and_dep_graph.xsl
 mk_meta_graph.xsl
 mk_meta_theory.xsl
-mmlctop.xsl-0.14
+mmlctop.xsl
 mmlextension.xsl
 mmlnotation.xsl
 mmltheoryextension.xsl