7.2 Numeric Subscripts (Rule 77)

<..compress numeric subscripts..>
   <set name="num-sub" >
      <.open xslt script.>
      <.num sub.>
      <.close xslt script.>
   </set>
   <xslt name="." xml="." xsl="num-sub" />
-_-_-

<..num sub..>
 <xsl:template match="msub[
   (
     <.num sub on non-primed base.>
     or
     <.num sub on primed base.>
   )
   and
     child::mrow[ @class = ’mrow-sub’ ]
     / child::*[ not(@title = ’speech-extra’) ][1]
     / self::*[
           normalize-space(.)
           = normalize-space( descendant::mn ) ]
 ]" >
   <xsl:copy>
      <xsl:apply-templates select="@*" />
      <BREAK SIZE="small"/>
      <xsl:apply-templates select="*[1]" />
      <mrow class="mrow-sub">
         <xsl:apply-templates
            select="*[2] / *[
                     not(@title = ’speech-extra’)
           ]" />
         <BREAK SIZE="small"/>
      </mrow>
   </xsl:copy>
 </xsl:template>
-_-_-

<..num sub on non-primed base..>
 (count( child::mrow[ @class = ’mrow-base’ ]
            / child::* ) = 1 )
   and child::mrow[ @class = ’mrow-base’ ] / descendant::mi
   and not( ancestor::*[
       self::msub or self::msup or self::msubsup
     ] )
-_-_-

<..num sub on primed base..>
 (
   count( child::mrow[ @class = ’mrow-base’ ]
         / child::* [
           not(self::BREAK)
         ]
   ) = 2 )
   and child::mrow[ @class = ’mrow-base’ ] [
          child::*[1][ self::mi ]
          and
          child::*[
            (position() &gt; 1)
            and
            (normalize-space(.) =
             normalize-space(
                descendant-or-self::span[
                   (@class = ’ch 2032’) or (@class = ’ch 2033’)
                                  or (@class = ’ch 2034’)
                ]
             ))
          ]
       ]
    and not( ancestor::*[
       self::msub or self::msup or self::msubsup
     ] )
-_-_-
<msub>  
  <mrow class="mrow-base">  
    <mi>x</mi>  
  </mrow>  
  <mrow class="mrow-sub">  
    <span class="begin-script" title="speech-extra"> subscript </span>  
    <mn>1</mn>  
    <span class="end-script" title="speech-extra"> baseline </span>  
  </mrow>  
</msub>

<..num sub..>+
 <xsl:template match="msubsup[
   (
     <.num sub on non-primed base.>
   )
   and
     child::mrow[ @class = ’mrow-sub’ ]
     / child::*[ not(@title = ’speech-extra’) ][1]
     / self::*[
           normalize-space(.)
           = normalize-space( descendant::mn ) ]
 ]" >
   <msup>
      <BREAK SIZE="small"/>
      <xsl:apply-templates select="*[1]" />
      <mrow class="mrow-sub">
         <xsl:apply-templates
            select="*[2] / *[
                     not(@title = ’speech-extra’)
           ]" />
         <BREAK SIZE="small"/>
      </mrow>
      <xsl:apply-templates select="*[3]" />
   </msup>
 </xsl:template>
-_-_-