5 Over and Under Limit Scripts
<xsl:template match="span[
(@class = ’limits-msub-msup’)
and
child::*[ (position() = 1)
and (@class = ’limits-mrow-base’)
and child::*[ (position() = 1)
and (@class = ’limits-msub-msup’)
] ]
]" >
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="
*[1]
/ *[1]
/ *[ not(@class=’limits-mrow-super’) ] " />
<xsl:apply-templates select=" *[
preceding-sibling::*
and
not(@class=’limits-mrow-super’) ]" />
<xsl:apply-templates select="
*[1]
/ *[1]
/ *[@class=’limits-mrow-super’ ] " />
<xsl:apply-templates select=" *[
preceding-sibling::*
and
(@class=’limits-mrow-super’) ]" />
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="span[ @class = ’end-limits-script’ ]" >
<xsl:if test=" parent::*[ not(following-sibling::*) ] ">
<xsl:copy>
<xsl:apply-templates select=" @* " />
<xsl:choose>
<xsl:when test="
parent::*[ preceding-sibling::span[
@class != ’limits-mrow-base’
] ]
" >
<xsl:text> end scripts </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> end script </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:if>
</xsl:template>
-_-_-
<xsl:template match="span[ @class = ’begin-limits-script’ ]" >
<xsl:copy>
<xsl:apply-templates select=" @* " />
<xsl:choose>
<xsl:when test="
parent::*[ @class = ’limits-mrow-super’ ]
" >
<xsl:apply-templates
select=" parent::*
/ preceding-sibling::*[1] "
mode = "extra-over" />
</xsl:when>
<xsl:when test="
parent::*[ @class = ’limits-mrow-sub’ ]
" >
<xsl:apply-templates
select=" parent::*
/ preceding-sibling::*[1] "
mode = "extra-under" />
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="*|text()|comment()" />
</xsl:copy>
</xsl:template>
-_-_-
<xsl:template match="*" mode="extra-over" >
<xsl:if test = " self::span[ @class = ’limits-mrow-super’ ] " >
<xsl:text> over </xsl:text>
<xsl:apply-templates select=" preceding-sibling::*[1] "
mode = "extra-over" />
</xsl:if>
</xsl:template>
-_-_-
<xsl:template match="*" mode="extra-under" >
<xsl:if test = " self::span[ @class = ’limits-mrow-sub’ ] " >
<xsl:text> under </xsl:text>
<xsl:apply-templates select=" preceding-sibling::*[1] "
mode = "extra-under" />
</xsl:if>
</xsl:template>
-_-_-