11.1 Over and Under Limit Scripts

<..over and under scripts..>
 <script element="msub::limits-msub-msup" >
   <set name="smash" >
      <.open xslt script.>
      <.smash over and under scripts.>
      <.close xslt script.>
   </set>
   <xslt name="." xml="." xsl="smash" />
 </script>
-_-_-

<..over and under scripts..>+
 <script element="msup::limits-msub-msup" >
   <set name="smash" >
      <.open xslt script.>
      <.smash over and under scripts.>
      <.close xslt script.>
   </set>
   <xslt name="." xml="." xsl="smash" />
 </script>
-_-_-

<..over and under scripts..>+
 <script element="msubsup::limits-msub-msup" >
   <set name="smash" >
      <.open xslt script.>
      <.smash over and under scripts.>
      <.close xslt script.>
   </set>
   <xslt name="." xml="." xsl="smash" />
 </script>
-_-_-

<..smash over and under scripts..>
 <xsl:template match="*[
        (@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>
-_-_-

<..compress limit script..>
 <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::mrow[
                                   @class != ’limits-mrow-base’
                          ]  ]
             " >
             <BREAK SIZE="small"/>
             <xsl:text> end scripts </xsl:text>
             <BREAK SIZE="small"/>
           </xsl:when>
           <xsl:otherwise>
             <BREAK SIZE="small"/>
             <xsl:text> end script </xsl:text>
             <BREAK SIZE="small"/>
           </xsl:otherwise>
        </xsl:choose>
     </xsl:copy>
   </xsl:if>
 </xsl:template>
-_-_-

<..compress limit script..>+
 <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>
-_-_-

<..compress limit script..>+
 <xsl:template match="*" mode="extra-over" >
    <xsl:if   test = " self::mrow[ @class = ’limits-mrow-super’ ] " >
      <xsl:text> over </xsl:text>
      <xsl:apply-templates select=" preceding-sibling::*[1] "
                     mode = "extra-over" />
    </xsl:if>
 </xsl:template>
-_-_-

<..compress limit script..>+
 <xsl:template match="*" mode="extra-under" >
    <xsl:if   test = " self::mrow[ @class = ’limits-mrow-sub’ ] " >
      <xsl:text> under </xsl:text>
      <xsl:apply-templates select=" preceding-sibling::*[1] "
                     mode = "extra-under" />
    </xsl:if>
 </xsl:template>
-_-_-