]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/style/style_prima_del_linguaggio_naturale/mml2mmlv1_0.xsl
This commit was manufactured by cvs2svn to create branch 'helm'.
[helm.git] / helm / style / style_prima_del_linguaggio_naturale / mml2mmlv1_0.xsl
diff --git a/helm/style/style_prima_del_linguaggio_naturale/mml2mmlv1_0.xsl b/helm/style/style_prima_del_linguaggio_naturale/mml2mmlv1_0.xsl
deleted file mode 100644 (file)
index 67e1acc..0000000
+++ /dev/null
@@ -1,1957 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- ====================================================== -->
-<!-- XSL Transform of MathML content to MathML presentation -->
-<!--    By Igor Rodionov, Computer Science Department of    -->
-<!--   the University of Western Ontario, London, Canada    -->
-<!--  Complies with the W3C Working Draft from Dec.3, 1999  -->
-<!--             Version x.xx from Feb. 18, 2000            -->
-<!--              Comments to:  igor@csd.uwo.ca             -->
-<!--                                                        -->
-<!-- (C) Copyright 1999, 2000 Symbolic Computation          -->
-<!--     Laboratory, University of Western Ontario.         -->
-<!-- ====================================================== -->
-
-<!-- ====================================================== -->
-<!--  May 11, 2000 - HELM group:                            -->
-<!--  Added the namespace prefix to all the output elements -->
-<!--  Changed the mml prefix into m                         -->
-<!--  Swapped math element out of the semantic element      -->
-<!--  Added the declaration of the xlink namespace          --> 
-<!-- ====================================================== -->
-
-<xsl:stylesheet id="mml2mml"
-                version="1.0"
-                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:m="http://www.w3.org/1998/Math/MathML"
-                xmlns:xlink="http://www.w3.org/1999/xlink"
-                xmlns:helm="http://www.cs.unibo.it/helm">
-
-<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
-
-<!-- ***************************************************** -->
-<!--  Parameters affectin' stylesheet's run-time behavior  -->
-<!-- ***************************************************** -->
-
-<!-- SEM_SW: -1 - strip off all semantics
-             0  - pass semantics "as is" (default)
-             1  - add semantics at top level only
-             2  - add semantics at all levels
-             3  - semantics at top level with cross-references
--->
-<!-- HELM: SEM_SW was 0 -->
-<xsl:param name="SEM_SW" select="1"/>
-
-<!-- Miscellaneous Variable Definitions -->
-
-<xsl:variable name="NO" select="0"/>
-<xsl:variable name="YES" select="1"/>
-<xsl:variable name="PAR_NO" select="-7"/>
-<xsl:variable name="PAR_YES" select="-5"/>
-<xsl:variable name="PAR_SAME" select="-3"/>
-<xsl:variable name="NO_PARAM" select="-1"/>
-
-<!-- Operator Precedence Definitions -->
-
-<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="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"/>
-
-<!-- AUXILIARY FUNCTIONS FOR BACKWARD POINTERS AND REFS (by andrea) -->
-
-<xsl:template name = "insert_xref">
- <xsl:if test="@helm:xref">
-  <xsl:attribute name="helm:xref">
-   <xsl:value-of select="@helm:xref"/>
-  </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<xsl:template name = "insert">
- <xsl:if test="@definitionURL">
-  <xsl:attribute name="xlink:href">
-   <xsl:value-of select="@definitionURL"/>
-  </xsl:attribute>
- </xsl:if>
- <xsl:if test="@helm:xref">
-  <xsl:attribute name="helm:xref">
-   <xsl:value-of select="@helm:xref"/>
-  </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<!-- for use inside m:apply -->
-<xsl:template name = "insert1">
- <xsl:if test="*[1]/@definitionURL">
-  <xsl:attribute name="xlink:href">
-   <xsl:value-of select="*[1]/@definitionURL"/>
-  </xsl:attribute>
- </xsl:if>
- <xsl:if test="*[1]/@helm:xref">
-  <xsl:attribute name="helm:xref">
-   <xsl:value-of select="*[1]/@helm:xref"/>
-  </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<!-- For use inside "for-each" -->
-<xsl:template name = "insert2">
- <xsl:if test="../*[1]/@definitionURL">
-  <xsl:attribute name="xlink:href">
-   <xsl:value-of select="../*[1]/@definitionURL"/>
-  </xsl:attribute>
- </xsl:if>
- <xsl:if test="../*[1]/@helm:xref">
-  <xsl:attribute name="helm:xref">
-   <xsl:value-of select="../*[1]/@helm:xref"/>
-  </xsl:attribute>
- </xsl:if>
-</xsl:template>
-
-<!-- THE TOPMOST ELEMENT: MATH -->
-
-<xsl:template match = "m:math">
-  <xsl:choose>
-    <xsl:when test="$SEM_SW>0">
-<!-- HELM: deleted math (we have already inserted at object level) -->
-     <!--<m:math>-->
-      <m:semantics>
-          <xsl:apply-templates mode = "semantics"/>
-       <m:annotation-xml encoding="MathML">
-          <xsl:copy-of select = "*"/>
-       </m:annotation-xml>
-      </m:semantics>
-     <!--</m:math>-->
-    </xsl:when>
-    <xsl:otherwise>
-      <!--<m:math>-->
-        <xsl:apply-templates mode = "semantics"/>
-      <!--</m:math>-->  
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<!-- SEMANTICS -->
-
-<xsl:template match = "m:*" mode = "semantics">
-  <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=-1 and self::m:semantics">
-      <xsl:apply-templates select="*[1]">
-        <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=0 and self::m:semantics">
-      <m:semantics>
-        <xsl:apply-templates select="*[1]">
-          <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=2">
-      <m:semantics>
-        <xsl:choose>
-          <xsl:when test="self::m:semantics">
-            <xsl:apply-templates select="*[1]">
-              <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_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=3 and @id">
-      <m:mrow idref="{@id}">
-        <xsl:apply-templates select=".">
-          <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:mrow>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:apply-templates select=".">
-        <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:template>
-
-<xsl:template match = "m:semantics">
-  <xsl:apply-templates select="*[1]" mode = "semantics"/>
-</xsl:template>
-
-
-<!-- BASIC 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; 0 and $PAREN=$PAR_NO and $PAR_NO_IGNORE=$NO">
-      <m:mfenced separators="">
-        <xsl:apply-templates select="." mode="cn"/>
-      </m:mfenced>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:apply-templates select="." mode="cn"/>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<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='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>
-          <xsl:apply-templates select="text()[2]" mode = "semantics"/>
-        </xsl:if>
-        <m:mo> <mchar name="InvisibleTimes"/> </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]" 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:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
-          </xsl:if>
-          <m:mo> <mchar name="InvisibleTimes"/> </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:mrow>
-        <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
-        <m:mo>/</m:mo>
-        <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
-      </m:mrow>
-    </xsl:when>
-    <xsl:when test="@type='rational' and @base and child::m:sep[1]">
-      <m:msub>
-        <m:mfenced separators="">
-          <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
-          <m:mo>/</m:mo>
-          <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
-        </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:mfenced separators=",">
-          <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
-          <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </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:mfenced separators=",">
-            <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
-            <m:mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </m:mn>
-          </m:mfenced>
-        </m:mrow>
-        <m:mn> <xsl:value-of select="@base"/> </m:mn>
-      </m:msub>
-   </xsl:when>
-    <xsl:otherwise>
-      <m:mn> 
-       <xsl:call-template name="insert"/>
-       <xsl:apply-templates mode = "semantics"/> 
-      </m:mn>
-    </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 fontweight="bold"> <xsl:apply-templates mode = "semantics"/> </m:mi>
-    </xsl:when>
-    <xsl:otherwise>
-     <m:mi> 
-      <xsl:call-template name="insert"/>
-      <xsl:apply-templates mode = "semantics"/> 
-     </m:mi>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match = "m:csymbol">
-  <xsl:choose>
-    <xsl:when test="*[1]">
-      <xsl:copy-of select = "*"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <m:mo> <xsl:apply-templates mode = "semantics"/> </m:mo>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-
-<!-- BASIC CONTENT ELEMENTS -->
-
-<xsl:template match = "m:apply[m:fn[1]]">
-  <m:mrow>
-    <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
-    <m:mfenced separators=",">
-      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
-    </m:mfenced>
-  </m:mrow>
-</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">
-  <xsl:choose>
-    <xsl:when test="@closure='closed'">
-      <m:mfenced open="[" close="]" separators=",">
-        <xsl:apply-templates mode = "semantics"/>
-      </m:mfenced>
-    </xsl:when>
-    <xsl:when test="@closure='open'">
-      <m:mfenced separators=",">
-        <xsl:apply-templates mode = "semantics"/>
-      </m:mfenced>
-    </xsl:when>
-    <xsl:when test="@closure='open-closed'">
-      <m:mfenced open="(" close="]" separators=",">
-        <xsl:apply-templates mode = "semantics"/>
-      </m:mfenced>
-    </xsl:when>
-    <xsl:when test="@closure='closed-open'">
-      <m:mfenced open="[" close=")" separators=",">
-        <xsl:apply-templates mode = "semantics"/>
-      </m:mfenced>
-    </xsl:when>
-    <xsl:otherwise>
-      <m:mfenced open="[" close="]" separators=",">
-        <xsl:apply-templates mode = "semantics"/>
-      </m:mfenced>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:*[1][self::m:apply[m:inverse[1]]]]">
-  <m:mrow>
-    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
-    <m:mfenced separators=",">
-      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
-    </m:mfenced>
- </m:mrow>
-</xsl:template>
-
-<!-- These "semantical" Transformations are REALLY questionable.
-     Andrea -->
-
-<xsl:template match = "m:apply[*[1][self::m:inverse]]">
-  <xsl:choose>
-    <xsl:when test="*[2]=m:exp">
-      <m:mo>ln</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:ln | m:log">
-      <m:mo>exp</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:sin">
-      <m:mo>arcsin</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:cos">
-      <m:mo>arccos</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:tan">
-      <m:mo>arctan</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:sec">
-      <m:mo>arcsec</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:csc">
-      <m:mo>arccsc</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:cot">
-      <m:mo>arccot</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:sinh">
-      <m:mo>arcsinh</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:cosh">
-      <m:mo>arccosh</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:tanh">
-      <m:mo>arctanh</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:sech">
-      <m:mo>arcsech</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:csch">
-      <m:mo>arccsch</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:coth">
-      <m:mo>arccoth</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:arcsin">
-      <m:mo>sin</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:arccos">
-      <m:mo>cos</m:mo>
-    </xsl:when>
-    <xsl:when test="*[2]=m:arctan">
-      <m:mo>tan</m:mo>
-    </xsl:when>
-    <xsl:otherwise>
-      <m:msup>
-        <xsl:apply-templates select = "*[2]" mode = "semantics"/>
-        <m:mfenced>
-          <m:mn>-1</m:mn>
-        </m:mfenced>
-      </m:msup>
-    </xsl:otherwise>
-  </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:if test="not(*[2])">
-        <xsl:apply-templates mode = "semantics"/>
-      </xsl:if>
-      <xsl:if test="*[2]">
-        <m:mrow>
-          <xsl:apply-templates mode = "semantics"/>
-        </m:mrow>
-      </xsl:if>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match = "m:declare"/>
-
-<xsl:template match = "m:lambda">
-  <m:mrow>
-    <m:mo> &#x039b; </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[m:*[1][self::m:apply[m:compose[1]]]]">
-  <m:mrow>
-    <xsl:apply-templates select = "*[1]" mode = "semantics"/>
-    <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: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> <xsl:call-template name="insert2"/> <mchar name="SmallCircle"/> </m:mo>
-      <xsl:apply-templates select = "." mode="semantics"/>
-    </xsl:for-each>
-  </m:mfenced>
-</xsl:template>
-
-<xsl:template match = "m:ident">
-  <m:mo>id</m:mo>
-</xsl:template>
-
-
-<!-- ARITHMETIC, ALGEBRA & LOGIC -->
-
-<xsl:template match = "m:apply[m:quotient[1]]">
-  <m:mfenced open="&#x230a;" close="&#x230b;" separators="">
-    <xsl:call-template name="insert_xref"/>
-    <xsl:apply-templates select="*[2]" mode = "semantics">
-      <xsl:with-param name="IN_PREC" select="$FUNCTION_PREC"/>
-    </xsl:apply-templates>
-    <m:mo><xsl:call-template name="insert1"/>/</m:mo>
-    <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:mfenced>
-</xsl:template>
-
-<xsl:template match = "m:apply[*[1][self::m:exp]]">
-  <m:msup>
-    <m:mo>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:call-template name="insert_xref"/>
-    <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><xsl:call-template name="insert1"/>!</m:mo>
-  </m:mrow>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:max[1] | m:min[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:if test="*[2]=m:bvar">
-      <m:munder>
-        <xsl:if test="*[1]=m:max">
-          <m:mo><xsl:call-template name="insert1"/>max</m:mo>
-        </xsl:if>
-        <xsl:if test="*[1]=m:min">
-          <m:mo>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>max</m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:min">
-        <m:mo>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>max</m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:min">
-        <m:mo><xsl:call-template name="insert1"/>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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert1"/>-</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><xsl:call-template name="insert1"/>-</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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert2"/>+</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>
-
-<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: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]]">
-      <xsl:apply-templates select="*[2]" mode = "semantics"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <m:msup>
-        <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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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>
-  <xsl:if test="m:rem">
-    <m:mo><xsl:call-template name="insert1"/>%</m:mo>
-  </xsl:if>
-  <xsl:if test="m:divide">
-    <m:mo><xsl:call-template name="insert1"/>/</m:mo>
-  </xsl:if>
-  <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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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]">
-<!-- MODIFICA PROVVISORIA -->
-<!--      <m:mo><xsl:call-template name="insert2"/>
-                <mchar name="InvisibleTimes"/> </m:mo> -->
-      <m:mo><xsl:call-template name="insert2"/>*</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>
-
-<!-- COMMENTO : dove metto la uri della definizione di radice ???? -->
-
-<xsl:template match = "m:apply[m:root[1]]">
-  <m:msqrt>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:if test="*[2]=m:degree">
-      <xsl:apply-templates select="*[3]" mode = "semantics"/>
-      <xsl:apply-templates select="*[2]" mode = "semantics"/>
-    </xsl:if>
-    <xsl:if test="not(*[2]=m:degree)">
-      <xsl:apply-templates select="*[2]" mode = "semantics"/>
-      <m:mn>2</m:mn>
-    </xsl:if>
-  </m:msqrt>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:gcd[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:if test="not(parent::m:apply[m:power[1]])">
-      <m:mo><xsl:call-template name="insert1"/>gcd</m:mo>
-    </xsl:if>
-    <xsl:if test="parent::m:apply[m:power[1]]">
-      <m:msup>
-        <m:mo><xsl:call-template name="insert1"/>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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert2"/> <mchar name="wedge"/> </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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert2"/> <mchar name="vee"/> </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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert2"/> <mchar name="xor"/> </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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/>not</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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/>for all</m:mo>
-    <m:mfenced separators=",">
-      <xsl:for-each select = "m:bvar">
-        <xsl:apply-templates select = "." mode="semantics"/>
-      </xsl:for-each>
-    </m:mfenced>
-    <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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/> <mchar name="Exists"/> </m:mo>
-    <m:mfenced separators=",">
-      <xsl:for-each select = "m:bvar">
-        <xsl:apply-templates select = "." mode="semantics"/>
-      </xsl:for-each>
-    </m:mfenced>
-    <xsl:if test="m:condition">
-      <m:mo>,</m:mo>
-      <xsl:apply-templates select = "m:condition/*" mode = "semantics"/>
-    </xsl:if>
-    <m:mo>:</m:mo>
-    <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:abs[1]]">
-  <xsl:if test="not(parent::m:apply[m:power[1]])">
-    <m:mfenced open="|" close="|" separators="">
-      <xsl:call-template name="insert_xref"/>
-      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
-    </m:mfenced>
-  </xsl:if>
-  <xsl:if test="parent::m:apply[m:power[1]]">
-    <m:msup>
-      <m:mfenced open="|" close="|" separators="">
-        <xsl:call-template name="insert_xref"/>
-        <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
-      </m:mfenced>
-      <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
-    </m:msup>
-  </xsl:if>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:conjugate[1]]">
-  <m:mover>
-    <m:mrow>
-      <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
-    </m:mrow>
-    <m:mo><xsl:call-template name="insert1"/> <mchar name="UnderBar"/> </m:mo>
-  </m:mover>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:arg[1] | m:real[1] | m:imaginary[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:choose>
-      <xsl:when test="m:arg">
-        <m:mo><xsl:call-template name="insert1"/>arg</m:mo>
-      </xsl:when>
-      <xsl:when test="m:real">
-        <m:mo><xsl:call-template name="insert1"/>Real</m:mo>
-      </xsl:when>
-      <xsl:when test="m:imaginary">
-        <m:mo><xsl:call-template name="insert1"/>Imaginary</m:mo>
-      </xsl:when>
-    </xsl:choose>
-    <m:mfenced separators="">
-      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
-    </m:mfenced>
-  </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:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:if test="*[1]=m:neq or *[1]=m:approx or *[1]=m:tendsto or *[1]=m:implies or *[1]=m:in or *[1]=m:notin or *[1]=m:notsubset or *[1]=m:notprsubset">
-      <xsl:apply-templates select = "*[2]" mode = "semantics"/>
-      <xsl:if test="*[1]=m:neq">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="NotEqual"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:approx">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="approxeq"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:tendsto">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="RightArrow"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:implies">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="DoubleRightArrow"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:in">
-        <m:mo><xsl:call-template name="insert1"/>
-        <mchar name="Element"/> 
-       </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:notin">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="NotElement"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:notsubset">
-        <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubset"/> </m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:notprsubset">
-        <m:mo> <xsl:call-template name="insert1"/> <mchar name="NotSubsetEqual"/> </m:mo>
-      </xsl:if>
-      <xsl:apply-templates select = "*[3]" mode = "semantics"/>
-      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='below']">
-        <m:mo><xsl:call-template name="insert1"/>-</m:mo>
-      </xsl:if>
-      <xsl:if test="*[1]=m:tendsto and m:tendsto[1][@type='above']">
-        <m:mo><xsl:call-template name="insert1"/>+</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]">
-        <xsl:if test="../*[self::m:subset][1]">
-          <m:mo> <xsl:call-template name="insert2"/> <mchar name="SubsetEqual"/> </m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:prsubset][1]">
-          <m:mo> <xsl:call-template name="insert2"/><mchar name="subset"/> </m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:eq][1]">
-          <m:mo><xsl:call-template name="insert2"/>=</m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:gt][1]">
-          <m:mo><xsl:call-template name="insert2"/>&gt;</m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:lt][1]">
-          <m:mo><xsl:call-template name="insert2"/>&lt;</m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:geq][1]">
-          <m:mo><xsl:call-template name="insert2"/> <mchar name="geq"/> </m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:leq][1]">
-          <m:mo><xsl:call-template name="insert2"/> <mchar name="leq"/> </m:mo>
-        </xsl:if>
-        <xsl:if test="../*[self::m:equivalent][1]">
-          <m:mo><xsl:call-template name="insert2"/> <mchar name="Congruent"/> </m:mo>
-        </xsl:if>
-        <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:call-template name="insert_xref"/>
-    <xsl:choose>
-      <xsl:when test="parent::m:apply[m:power[1]]">
-        <m:msup>
-          <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
-          <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
-        </m:msup>
-      </xsl:when>
-      <xsl:otherwise>
-        <m:mo><xsl:call-template name="insert1"/>ln</m:mo>
-      </xsl:otherwise>
-    </xsl:choose>
-    <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:call-template name="insert_xref"/>
-    <xsl:choose>
-      <xsl:when test="parent::m:apply[m:power[1]]">
-        <xsl:if test="not(*[2]=m:logbase)">
-          <m:msup>
-            <m:mo><xsl:call-template name="insert1"/>log</m:mo>
-            <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
-          </m:msup>
-        </xsl:if>
-        <xsl:if test="*[2]=m:logbase">
-          <m:msubsup>
-            <m:mo><xsl:call-template name="insert1"/>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><xsl:call-template name="insert1"/>log</m:mo>
-        </xsl:if>
-        <xsl:if test="*[2]=m:logbase">
-          <m:msub>
-            <m:mo><xsl:call-template name="insert1"/>log</m:mo>
-            <xsl:apply-templates select = "m:logbase" mode = "semantics"/>
-          </m:msub>
-        </xsl:if>
-      </xsl:otherwise>
-    </xsl:choose>
-    <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:call-template name="insert_xref"/>
-    <xsl:if test="*[2]=m:bvar and m:bvar[*[2]=m:degree]">
-      <m:mfrac><xsl:call-template name="insert1"/>
-        <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><xsl:call-template name="insert1"/>
-        <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:call-template name="insert_xref"/>
-    <xsl:for-each select = "m:bvar">
-      <xsl:if test="*[last()]=m:degree">
-        <m:mfrac><xsl:call-template name="insert1"/>
-          <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><xsl:call-template name="insert1"/>
-          <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 mode = "semantics"/>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:divergence[1] | m:grad[1] | m:curl[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:if test="*[1]=m:divergence">
-      <m:mo><xsl:call-template name="insert1"/>div</m:mo>
-    </xsl:if>
-    <xsl:if test="*[1]=m:grad">
-    <m:mo><xsl:call-template name="insert1"/>grad</m:mo>
-    </xsl:if>
-    <xsl:if test="*[1]=m:curl">
-    <m:mo><xsl:call-template name="insert1"/>curl</m:mo>
-    </xsl:if>
-    <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:call-template name="insert_xref"/>
-    <m:msup><xsl:call-template name="insert1"/>
-      <m:mo> &#x0394; </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:call-template name="insert_xref"/>
-    <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_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">
-      <m:mfenced separators="" helm:xref="{@helm:xref}">
-        <xsl:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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:mrow>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:union[1]]" mode="union">
-  <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><xsl:call-template name="insert2"/> <mchar name="Union"/> </m:mo>
-    <xsl:apply-templates select = "." mode="semantics">
-      <xsl:with-param name="IN_PREC" select="$UNION_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:intersect[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; $INTERSECT_PREC">
-      <m:mfenced separators="" helm:xref="{@helm:xref}">
-        <xsl:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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:mrow>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:intersect[1]]" mode="intersect">
-  <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><xsl:call-template name="insert2"/> <mchar name="Intersection"/> </m:mo>
-    <xsl:apply-templates select = "." mode="semantics">
-      <xsl:with-param name="IN_PREC" select="$INTERSECT_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: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:call-template name="insert_xref"/>
-        <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=2)">
-      <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:call-template name="insert_xref"/>
-        <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><xsl:call-template name="insert1"/>\</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:card[1]]">
-  <m:mfenced open="|" close="|" separators=",">
-    <xsl:call-template name="insert_xref"/>
-    <xsl:for-each select = "*[position()>1]">
-      <xsl:apply-templates select = "." mode="semantics"/>
-    </xsl:for-each>
-  </m:mfenced>
-</xsl:template>
-
-
-<!-- SEQUENCES AND SERIES -->
-
-<xsl:template match = "m:apply[m:sum[1] | m:product[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:choose>
-      <xsl:when test="*[2]=m:bvar and m:lowlimit and m:uplimit">
-        <m:munderover>
-          <xsl:if test="*[1]=m:sum">
-            <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
-          </xsl:if>
-          <xsl:if test="*[1]=m:product">
-            <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
-          </xsl:if>
-          <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>
-          <xsl:if test="*[1]=m:sum">
-            <m:mo><xsl:call-template name="insert1"/> <mchar name="Sum"/> </m:mo>
-          </xsl:if>
-          <xsl:if test="*[1]=m:product">
-            <m:mo><xsl:call-template name="insert1"/> <mchar name="Product"/> </m:mo>
-          </xsl:if>
-          <xsl:apply-templates select = "*[3]" mode = "semantics"/>
-        </m:munder>
-        <xsl:apply-templates select = "*[4]" mode = "semantics"/>
-      </xsl:when>
-    </xsl:choose>
-  </m:mrow>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:limit[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <m:munder>
-      <m:mo><xsl:call-template name="insert1"/>lim</m:mo>
-      <m:mrow>
-        <xsl:if test="*[2]=m:bvar and *[3]=m:lowlimit">
-            <xsl:apply-templates select = "*[2]" mode = "semantics"/>
-            <m:mo> <mchar name="RightArrow"/> </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]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <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>
-    <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 = "m:*" mode = "trigonometry">
-    <xsl:choose>
-      <xsl:when test="self::m:sin">
-        <m:mo>sin</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:cos">
-        <m:mo>cos</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:tan">
-        <m:mo>tan</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:sec">
-        <m:mo>sec</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:csc">
-        <m:mo>csc</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:cot">
-        <m:mo>cot</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:sinh">
-        <m:mo>sinh</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:cosh">
-        <m:mo>cosh</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:tanh">
-        <m:mo>tanh</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:sech">
-        <m:mo>sech</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:csch">
-        <m:mo>csch</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:coth">
-        <m:mo>coth</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:arcsin">
-        <m:mo>arcsin</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:arccos">
-        <m:mo>arccos</m:mo>
-      </xsl:when>
-      <xsl:when test="self::m:arctan">
-        <m:mo>arctan</m:mo>
-      </xsl:when>
-    </xsl:choose>
-</xsl:template>
-
-
-<!-- STATISTICS -->
-
-<xsl:template match = "m:apply[m:mean[1]]">
-  <m:mfenced open="&lt;" close="&gt;" separators=",">
-    <xsl:call-template name="insert_xref"/>
-    <xsl:for-each select = "*[position()>1]">
-      <xsl:apply-templates select = "." mode="semantics"/>
-    </xsl:for-each>
-  </m:mfenced>
-</xsl:template>
-
-<xsl:template match = "m:apply[m:sdev[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/> &#x03c3; </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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/> &#x03c3; </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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/>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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/>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>
-
-<xsl:template match = "m:apply[m:moment[1]]">
-  <xsl:call-template name="insert_xref"/>
-  <m:mfenced open="&lt;" close="&gt;" separators="">
-    <xsl:if test="*[2]=m:degree">
-      <m:msup>
-        <xsl:apply-templates select="*[3]" mode = "semantics"/>
-        <xsl:apply-templates select="*[2]" mode = "semantics"/>
-      </m:msup>
-    </xsl:if>
-    <xsl:if test="not(*[2]=m:degree)">
-      <xsl:for-each select = "*[position()>1]">
-        <xsl:apply-templates select = "." mode="semantics"/>
-      </xsl:for-each>
-    </xsl:if>
-  </m:mfenced>
-</xsl:template>
-
-
-<!-- LINEAR ALGEBRA -->
-
-<xsl:template match="m:vector">
-  <m:mfenced separators="">
-    <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="">
-    <m:mtable>
-      <xsl:apply-templates mode = "semantics"/>
-    </m:mtable>
-  </m:mfenced>
-</xsl:template>
-
-<xsl:template match = "m:matrixrow">
-  <m:mtr>
-    <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:call-template name="insert_xref"/>
-    <m:mo><xsl:call-template name="insert1"/>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:apply-templates select = "*[2]" mode = "semantics"/>
-    <m:mo>T</m:mo>
-  </m:msup>
-</xsl:template>
-
-<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:vectorproduct[1] | m:scalarproduct[1] | m:outerproduct[1]]">
-  <m:mrow>
-    <xsl:call-template name="insert_xref"/>
-    <xsl:apply-templates select="*[2]" mode = "semantics"/>
-    <xsl:choose>
-      <xsl:when test="m:vectorproduct[1]">
-        <m:mo><xsl:call-template name="insert1"/> <mchar name="Cross"/> </m:mo>
-      </xsl:when>
-      <xsl:when test="m:scalarproduct[1] | m:outerproduct[1]">
-        <m:mo><xsl:call-template name="insert1"/>.</m:mo>
-      </xsl:when>
-    </xsl:choose>
-    <xsl:apply-templates select="*[3]" mode = "semantics"/>
-  </m:mrow>
-</xsl:template>
-
-</xsl:stylesheet>