4.6 Squared
<xsl:template match="span[
(@class = ’msup’)
and
(normalize-space(
child::span[ (@class = ’mrow-super’) ]
/ child::span[ (@class != ’begin-script’)
and
(@class != ’end-script’)
]
) = ’2’)
and <.su verbose not on op.>
]" >
<xsl:copy>
<xsl:apply-templates select="*|@*|text()|comment()"
mode="squared" />
</xsl:copy>
</xsl:template> -_-_-
not(
child::span[ (@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="@*" />
<span class="mo-op">
<xsl:text> squared </xsl:text>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<span class="msup">
<span class="mrow-base">
<span class="mo-op">cos</span>
</span>
<span class="mrow-super">
<span class="begin-script"> superscript </span>
<span class="mn">2</span>
<span class="end-script"> baseline </span>
</span>
</span>
<xsl:template match="span[
(@class = ’msup’)
and
(normalize-space(
child::span[ (@class = ’mrow-super’) ]
/ child::span[ (@class != ’begin-script’)
and
(@class != ’end-script’)
]
) = ’3’)
and <.su verbose not on op.>
]" >
<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="@*" />
<span class="mo-op">
<xsl:text> cube </xsl:text>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="span[
(@class = ’msubsup’)
and
(normalize-space(
child::span[ (@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>
<span class="mo-op">
<xsl:text> squared </xsl:text>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="span[
(@class = ’msubsup’)
and
(normalize-space(
child::span[ (@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>
<span class="mo-op">
<xsl:text> cube </xsl:text>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*|@*|text()|comment()" />
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
-_-_-