7.1 Squared
<xsl:template match="msup[
(normalize-space(
child::mrow[ (@class = ’mrow-super’) ]
/ child::*[ not (@class = ’begin-script’)
and
not (@class = ’end-script’)
]
) = ’2’)
and <.su verbose not on op.>
and (normalize-space(mrow[@class = ’mrow-base’]) != ’’ )
]" >
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()"
mode="squared" />
</xsl:copy>
</xsl:template> -_-_-
not(
child::mrow[ @class = ’mrow-base’ ]
/ child::span[ not( @title = ’speech-extra’ ) ]
[ position() = last() ]
/ self::* [ @class = ’mo-op’ ]
)
-_-_-
<xsl:template match="*|@*|text()|comment()"
mode="squared" >
<xsl:copy>
<xsl:choose>
<xsl:when test=" @class = ’mrow-super’ ">
<xsl:apply-templates select="@*" />
<mo class="mo-op">
<xsl:text> squared </xsl:text>
</mo>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<msup>
<mrow class="mrow-base">
<mo class="mo-op">cos</mo>
</mrow>
<mrow class="mrow-super">
<span class="begin-script"> superscript </span>
<span class="mn">2</span>
<span class="end-script"> baseline </span>
</mrow>
</msup>
<xsl:template match="msup[
(normalize-space(
child::mrow[ (@class = ’mrow-super’) ]
/ child::*[ not (@class = ’begin-script’)
and
not (@class = ’end-script’)
]
) = ’3’)
and <.su verbose not on op.>
and (normalize-space(mrow[@class = ’mrow-base’]) != ’’ )
]" >
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()"
mode="cube" />
</xsl:copy>
</xsl:template> -_-_-
<xsl:template match="*|@*|text()|comment()"
mode="cube" >
<xsl:copy>
<xsl:choose>
<xsl:when test=" @class = ’mrow-super’ ">
<xsl:apply-templates select="@*" />
<mo class="mo-op">
<xsl:text> cube </xsl:text>
</mo>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="msubsup[
(normalize-space(
child::mrow[ (@class = ’mrow-super’) ]
/ child::span[ (@class != ’mid-script’)
and
(@class != ’end-script’)
]
) = ’2’)
and <.su verbose not on op.>
]" >
<xsl:copy>
<xsl:attribute name="class" >
<xsl:text>msub</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="*|text()|comment()"
mode="sub-squared" />
</xsl:copy>
</xsl:template> -_-_-
<xsl:template match="*|@*|text()|comment()"
mode="sub-squared" >
<xsl:copy>
<xsl:choose>
<xsl:when test=" @class = ’mrow-sub’ ">
<xsl:apply-templates select="*[
not( @class = ’end-script’ )
]
|@*|text()|comment()" />
<xsl:apply-templates select="
following-sibling::*[1] / *[
@class = ’end-script’
] " />
</xsl:when>
<xsl:when test=" @class = ’mrow-super’ ">
<xsl:attribute name="class" >
<xsl:text>squared-super</xsl:text>
</xsl:attribute>
<mo class="mo-op">
<xsl:text> squared </xsl:text>
</mo>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="msubsup[
(normalize-space(
child::mrow[ (@class = ’mrow-super’) ]
/ child::span[ (@class != ’mid-script’)
and
(@class != ’end-script’)
]
) = ’3’)
and <.su verbose not on op.>
]" >
<xsl:copy>
<xsl:attribute name="class" >
<xsl:text>msub</xsl:text>
</xsl:attribute>
<xsl:apply-templates select="*|text()|comment()"
mode="sub-cube" />
</xsl:copy>
</xsl:template> -_-_-
<xsl:template match="*|@*|text()|comment()"
mode="sub-cube" >
<xsl:copy>
<xsl:choose>
<xsl:when test=" @class = ’mrow-sub’ ">
<xsl:apply-templates select="*[
not( @class = ’end-script’ )
]
|@*|text()|comment()" />
<xsl:apply-templates select="
following-sibling::*[1] / *[
@class = ’end-script’
] " />
</xsl:when>
<xsl:when test=" @class = ’mrow-super’ ">
<xsl:attribute name="class" >
<xsl:text>cube-super</xsl:text>
</xsl:attribute>
<mo class="mo-op">
<xsl:text> cube </xsl:text>
</mo>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-