7.1 Squared

<..superscript 2 and 3 into verbose..>
 <set name="m-sup-2-3" >
   <.open xslt script.>
   <.superscript into squared and cube.>
   <.close xslt script.>
 </set>
 <xslt name="." xml="." xsl="m-sup-2-3" />
-_-_-

<..superscript into squared and cube..>
 <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>
-_-_-

<..su verbose not on op..>
 not(
   child::mrow[ @class = ’mrow-base’ ]
     / child::span[ not( @title = ’speech-extra’ ) ]
                  [ position() = last() ]
     / self::* [ @class = ’mo-op’ ]
 )
-_-_-

<..superscript into squared and cube..>+
 <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>

<..superscript into squared and cube..>+
 <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>
-_-_-

<..superscript into squared and cube..>+
 <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>
-_-_-

<..sub superscript 2 and 3 into verbose..>
 <set name="m-subsup-2-3" >
   <.open xslt script.>
   <.subsup into sub squared and cube.>
   <.close xslt script.>
 </set>
 <xslt name="." xml="." xsl="m-subsup-2-3" />
-_-_-

<..subsup into sub squared and cube..>
 <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>
-_-_-

<..subsup into sub squared and cube..>+
 <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>
-_-_-

<..subsup into sub squared and cube..>+
 <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>
-_-_-

<..subsup into sub squared and cube..>+
 <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>
-_-_-