<?xml version='1.0' encoding=“UTF-8”?> <xsl:stylesheet xmlns:xsl=“www.w3.org/1999/XSL/Transform

xmlns:m="http://www.w3.org/1998/Math/MathML"
version='1.0'>
<xsl:template match="m:mmultiscripts" mode="mprescripts">
  <xsl:for-each select="m:mprescripts/following-sibling::*">
    <xsl:if test="position() mod 2 and local-name(.)!='none'">
      <xsl:text>{}_{</xsl:text>
      <xsl:apply-templates select="."/>
      <xsl:text>}</xsl:text>
    </xsl:if>
    <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
      <xsl:text>{}^{</xsl:text>
      <xsl:apply-templates select="."/>
      <xsl:text>}</xsl:text>
    </xsl:if>
  </xsl:for-each>
  <xsl:apply-templates select="./*[1]"/>
  <xsl:for-each select="m:mprescripts/preceding-sibling::*[position()!=last()]">
    <xsl:if test="position()>2 and local-name(.)!='none'">
      <xsl:text>{}</xsl:text>
    </xsl:if>
    <xsl:if test="position() mod 2 and local-name(.)!='none'">
      <xsl:text>_{</xsl:text>
      <xsl:apply-templates select="."/>
      <xsl:text>}</xsl:text>
    </xsl:if>
    <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
      <xsl:text>^{</xsl:text>
      <xsl:apply-templates select="."/>
      <xsl:text>}</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:template>
<xsl:template match="m:mmultiscripts">
  <xsl:choose>
    <xsl:when test="m:mprescripts">
      <xsl:apply-templates select="." mode="mprescripts"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:apply-templates select="./*[1]"/>
      <xsl:for-each select="*[position()>1]">
        <xsl:if test="position()>2 and local-name(.)!='none'">
          <xsl:text>{}</xsl:text>
        </xsl:if>
        <xsl:if test="position() mod 2 and local-name(.)!='none'">
          <xsl:text>_{</xsl:text>
          <xsl:apply-templates select="."/>
          <xsl:text>}</xsl:text>
        </xsl:if>
        <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
          <xsl:text>^{</xsl:text>
          <xsl:apply-templates select="."/>
          <xsl:text>}</xsl:text>
        </xsl:if>
      </xsl:for-each>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>