+++ /dev/null
-<?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 -->
-<!-- ====================================================== -->
-
-<!-- ====================================================== -->
-<!-- June, 2000 - HELM group: -->
-<!-- Added auxiliary function to insert: -->
-<!-- 1) backwards pointers: helm:xref -->
-<!-- 2) references to definitions: xlink:href -->
-<!-- Added call-templates to the functions: -->
-<!-- insert_xref, insert, insert1, insert2 -->
-<!-- ====================================================== -->
-
-
-<!-- HELM: namespace helm added -->
-<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"/>
-
-<!-- HELM: auxiliary functions for backwards pointers and refs -->
-
-<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>
-
-<!-- HELM: 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>
-
-<!-- HELM: 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 -->
-
-<!-- HELM: cn could not contain MAthMl presentation -->
-<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"/>
-<!-- HELM: added -->
-<xsl:choose>
- <xsl:when test="child::text()">
-<!-- HELM -->
- <xsl:choose>
- <xsl:when test=". < 0 and $IN_PREC > 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>
-<!-- HELM: added -->
-</xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="*"/>
- </xsl:otherwise>
- </xsl:choose>
-<!-- HELM -->
-</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] < 0">
- <m:mo>-</m:mo>
- <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
- </xsl:if>
- <xsl:if test="not(text()[2] < 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] < 0">
- <m:mo>-</m:mo>
- <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
- </xsl:if>
- <xsl:if test="not(text()[2] < 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>
-<!-- HELM: ci could not contain MathML presentation
- <m:mi>
- <xsl:call-template name="insert"/>
- <xsl:apply-templates mode = "semantics"/>
- </m:mi>
--->
- <xsl:choose>
- <!-- HELM: or the opposite test <xsl:when test="*[1]"> -->
- <xsl:when test="child::text()">
- <m:mi>
- <xsl:call-template name="insert"/>
- <xsl:apply-templates mode = "semantics"/>
- </m:mi>
- </xsl:when>
- <xsl:otherwise>
- <m:mrow>
- <xsl:call-template name="insert"/>
- <xsl:copy-of select="*"/>
- </m:mrow>
- </xsl:otherwise>
- </xsl:choose>
- </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>
-
-<!-- HELM: 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> Λ </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="⌊" close="⌋" 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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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=". < 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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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]">
-<!-- HELM: to distinguish between * and the application -->
-<!-- <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>
-
-
-<xsl:template match = "m:apply[m:root[1]]">
- <m:msqrt>
- <xsl:call-template name="insert1"/>
- <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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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"/>
-<!-- CSC, per estetica!
- <m:mo><xsl:call-template name="insert1"/>not</m:mo>
--->
- <m:mo><xsl:call-template name="insert1"/><m:mchar name="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"/>></m:mo>
- </xsl:if>
- <xsl:if test="../*[self::m:lt][1]">
- <m:mo><xsl:call-template name="insert2"/><</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> Δ </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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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 > $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 > $NO_PREC and $IN_PREC < $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="<" 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>
-
-<xsl:template match = "m:apply[m:sdev[1]]">
- <m:mrow>
- <xsl:call-template name="insert_xref"/>
- <m:mo><xsl:call-template name="insert1"/> σ </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"/> σ </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="<" close=">" 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>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- /dev/null
+<?xml version="1.0"?>
+
+<!-- ******************************************************
+
+ XSL Transform of MathML content to MathML presentation
+
+ Version 0.14, Dec. 13, 2000
+ 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.
+ ****************************************************** -->
+
+
+<!-- ====================================================== -->
+<!-- April,28 2001 - HELM group: -->
+<!-- Added the namespace prefix to all the output elements -->
+<!-- Added the namespace prefix to all the xref attributes -->
+<!-- Changed the mml prefix into m -->
+<!-- Added m:xref to every mo element -->
+<!-- First draft: April 27 2001, Irene Schena -->
+<!-- ====================================================== -->
+
+<!-- Mostly complies with the W3C MathML 2.0 Candidate Recommenation
+ of November 13, 2000. The main difference is the use of <mchar>
+ which was removed from MathML 2.0 in the last working draft.
+ -->
+
+<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" -->
+
+<xsl:output method="xml" indent="yes"/>
+
+<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="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"/>
+
+<!-- ~~~~~ 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"/>
+
+
+<!-- +++++++++++++++++ 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
+
+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
+
+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
+
+SEQUENCES AND SERIES
+ sum, product, limit
+
+TRIGONOMETRY
+ sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth,
+ arcsin, arccos, arctan
+
+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">
+ <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>
+</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_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_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_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_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=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:choose>
+<!-- HELM: syntax error: sematics -->
+ <xsl:when test="self::m:semantics">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:attribute name="m: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_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_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 ***************** -->
+
+<!-- HELM: cn could not contain MAthML presentation -->
+<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"/>
+<!-- HELM: added -->
+<xsl:choose>
+ <xsl:when test="child::text()">
+<!-- HELM -->
+ <xsl:choose>
+ <xsl:when test=". < 0 and $IN_PREC > $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="m: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>
+<!-- HELM: added -->
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ <xsl:copy-of select="*"/>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+<!-- HELM -->
+</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] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+ </xsl:if>
+ <m:mo> <m: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]"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+ </xsl:if>
+ <m:mo> <m: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: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> <m:mchar name="InvisibleTimes"/> </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> <m:mchar name="InvisibleTimes"/> </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>
+ <m:mn> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ </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 m: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="" m:xref="{@id}">
+ <m:mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:value-of select="text()[2]"/> </m:mn>
+ </xsl:if>
+ <m:mo> <m: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:xref="{@id}">
+ <m:mfenced separators="">
+ <m:mn> <xsl:apply-templates select="text()[1]"/> </m:mn>
+ <xsl:if test="text()[2] < 0">
+ <m:mo>-</m:mo>
+ <m:mn> <xsl:value-of select="-text()[2]"/> </m:mn>
+ </xsl:if>
+ <xsl:if test="not(text()[2] < 0)">
+ <m:mo>+</m:mo>
+ <m:mn> <xsl:apply-templates select="text()[2]"/> </m:mn>
+ </xsl:if>
+ <m:mo> <m: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:mfrac m: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 m: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 m:xref="{@id}">
+ <m:mo>Polar</m:mo>
+ <m:mo> <m:mchar name="InvisibleTimes"/> </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:xref="{@id}">
+ <m:mrow>
+ <m:mo>Polar</m:mo>
+ <m:mo> <m:mchar name="InvisibleTimes"/> </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>
+ <m:mn m:xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- HELM: ci could not contain MAthML presentation -->
+<xsl:template match = "m:ci">
+<!-- HELM: added -->
+<xsl:choose>
+ <xsl:when test="child::text()">
+<!-- HELM -->
+ <xsl:choose>
+ <xsl:when test="@type='vector' or @type=matrix or @type=set">
+ <m:mi fontweight="bold">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+<!-- HELM: added mode=semantics -->
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mi>
+ </xsl:when>
+ <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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+<!-- HELM: added mode=semantics -->
+ <xsl:apply-templates mode = "semantics"/>
+ </m:mrow>
+ </xsl:when>
+ <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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="*"/>
+ </m:mrow>
+ </xsl:if>
+ <xsl:if test="not(*[2])">
+ <xsl:apply-templates select="*[1]"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+<!-- HELM: added -->
+</xsl:when>
+ <xsl:otherwise>
+ <m:mrow>
+ <xsl:copy-of select="*"/>
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+<!-- HELM -->
+</xsl:template>
+
+<xsl:template match = "m:ci/m:*[not(self::m:sep)]">
+ <xsl:copy-of select = "."/>
+</xsl:template>
+
+<!-- HELM: previous Version x.xx from Feb. 18, 2000 -->
+<xsl:template match = "m:csymbol">
+<!-- HELM: added -->
+ <m:mrow>
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+<!-- HELM -->
+ <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>
+ </m:mrow>
+</xsl:template>
+
+
+<!-- HELM: csymbol cannot contain ci or cn elements, but only text 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=". < 0 or . = 0 or . > 0">
+ <mn> <xsl:copy-of select = "."/> </mn>
+ </xsl:when>
+ <xsl:otherwise>
+ <mi> <xsl:copy-of select = "."/> </mi>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>-->
+
+
+<!-- ***************** BASIC CONTENT ELEMENTS ***************** -->
+
+<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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select = "m:fn[1]" mode = "semantics"/>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:fn/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name='ApplyFunction'/> </m:mo>
+ <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">
+ <m:mfenced separators=",">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mo> <m:mchar name='ApplyFunction'/> </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="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select = "*[2]"/>
+ <m:mfenced>
+ <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 m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo> <m:mchar name='Lambda'/> </m:mo>
+ <m:mo> <m:mchar name='ApplyFunction'/> </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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select = "*[1]" mode = "semantics"/>
+ <m:mo> <m:mchar name='ApplyFunction'/> </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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:compose/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="SmallCircle"/> </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 m:xref="{@id}">id</m:mo>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mo>id</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+</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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em">
+ <m:mchar name="LeftFloor"/>
+ </m:mo>
+ <m:mfrac>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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">
+ <m:mchar name="LeftFloor"/>
+ </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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+ <!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>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>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 > $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="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $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="m: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 > $NO_PREC and $IN_PREC < $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="m: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=". < 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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>
+
+<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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $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="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:rem/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:value-of select="'%'"/>
+ </xsl:if>
+ <xsl:if test="m:divide">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $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="m: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 > $NO_PREC and $IN_PREC < $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="m: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 -->
+<!-- <m:mo> <mchar name="InvisibleTimes"/> </m:mo> -->
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $AND_PREC">
+ <m:mfenced separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:and/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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 > $OR_PREC">
+ <m:mfenced separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:or/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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 > $XOR_PREC">
+ <m:mfenced separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:xor/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+<!-- HELM: was <m:mo>not</m:mo> -->
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:not/@id"/>
+ </xsl:attribute>
+ </xsl:if><m:mchar name="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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:forall/@id"/>
+ </xsl:attribute>
+ </xsl:if>for all</m:mo>
+ <xsl:if test="count(m:bvar) > 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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:exists/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Exists"/> </m:mo>
+ <xsl:if test="count(m:bvar) > 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>
+
+<xsl:template match = "m:apply[m:abs[1]]">
+ <xsl:if test="not(parent::m:apply[m:power[1]])">
+ <m:mfenced open="|" close="|" separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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>
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:conjugate/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+ <xsl:if test="m:arg">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>
+
+
+<!-- ***************** 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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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"/>
+ <m:mo>
+ <xsl:if test="*[1]=m:neq">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:neq/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="NotEqual"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:approx">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:approx/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="approxeq"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:tendsto">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:tendsto/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="RightArrow"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:implies">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:implies/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="DoubleRightArrow"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:in">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:in/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Element"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notin">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:notin/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="NotElement"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notsubset">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:notsubset/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="NotSubset"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:notprsubset">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:notprsubset/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="NotSubsetEqual"/>
+ </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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:subset/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="SubsetEqual"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:prsubset][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:prsubset/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="subset"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:eq][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:gt/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:value-of select="'>'"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:lt][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:lt/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:value-of select="'<'"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:geq][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:geq/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="geq"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:leq][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:leq/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="leq"/>
+ </xsl:if>
+ <xsl:if test="../*[self::m:equivalent][1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:equivalent/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Congruent"/>
+ </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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:ln/@id"/>
+ </xsl:attribute>
+ </xsl:if>ln</m:mo>
+ </xsl:otherwise>
+ </xsl:choose>
+ <m:mo> <m:mchar name='ApplyFunction'/> </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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>log</m:mo>
+ </xsl:if>
+ <xsl:if test="*[2]=m:logbase">
+ <m:msub>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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> <m:mchar name='ApplyFunction'/> </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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+ <xsl:if test="*[1]=m:divergence">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:msup>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:laplacian/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo> <m:mchar name="Delta"/> </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="m: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_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 > $UNION_PREC or $IN_PREC=$UNION_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="m: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 > $NO_PREC and $IN_PREC < $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="m: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: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>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:union/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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 > $INTERSECT_PREC">
+ <m:mfenced separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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 > $NO_PREC and $IN_PREC < $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="m: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: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>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="../m:intersect/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m: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 > $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="m: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 > $NO_PREC and $IN_PREC < $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="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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:card[1]]">
+ <m:mfenced open="|" close="|" separators=",">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:sum/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Sum"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:product/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Product"/>
+ </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">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:sum/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Sum"/>
+ </xsl:if>
+ <xsl:if test="*[1]=m:product">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:product/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Product"/>
+ </xsl:if>
+ </m:mo>
+ <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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:munder>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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> <m: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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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> <m:mchar name='ApplyFunction'/> </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="m: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:choose>
+ </m:mo>
+</xsl:template>
+
+
+<!-- ***************** STATISTICS ***************** -->
+
+<xsl:template match = "m:apply[m:mean[1]]">
+ <m:mfenced open="<" close=">" separators=",">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:sdev/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="sigma"/> </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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:variance/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="sigma"/> </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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>
+
+<xsl:template match = "m:apply[m:moment[1]]">
+ <m:mfenced open="<" close=">" separators="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <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="">
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m: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="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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="m:xref">
+ <xsl:value-of select="@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select = "*[2]" mode = "semantics"/>
+ <m:mo>
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:transpose/@id"/>
+ </xsl:attribute>
+ </xsl:if>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:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m:xref">
+ <xsl:value-of select="m:vectorproduct/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+ <m:mchar name="Cross"/>
+ </xsl:if>
+ <xsl:if test="m:scalarproduct[1] | m:outerproduct[1]">
+<!-- HELM: added -->
+ <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
+ <xsl:attribute name="m: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>
+
+</xsl:stylesheet>