+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="child::text() and not(*[1])">
+ <m:mn xref="{@id}"> <xsl:apply-templates mode = "semantics"/> </m:mn>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="id" select="@id"/>
+ <xsl:choose>
+ <xsl:when test="not(*[2])">
+ <xsl:for-each select="*[1]">
+ <xsl:copy>
+ <xsl:attribute name="xref">
+ <xsl:value-of select="$id"/>
+ </xsl:attribute>
+ <xsl:copy-of select="@*|*"/>
+ </xsl:copy>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <m:mrow xref="{$id}">
+ <xsl:copy-of select="*|text()"/>
+ </m:mrow>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>