home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / scripts.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2011-02-15  |  14.9 KB  |  413 lines

  1. <?xml version='1.0' encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.         xmlns:m="http://www.w3.org/1998/Math/MathML"
  4.         xmlns:oomath="http://www.w3.org/1998/Math/MathML"
  5.                 version='1.0'>
  6.                 
  7. <!-- ====================================================================== -->
  8. <!-- $Id: scripts.xsl 2755 2008-03-07 20:35:56Z hauma $
  9.      This file is part of the XSLT MathML Library distribution.
  10.      See ./README or http://xsltml.sf.net for
  11.      copyright and other information                                        -->
  12. <!-- ====================================================================== -->
  13.  
  14. <xsl:template match="m:munderover">
  15.     <xsl:variable name="base" select="translate(./*[1],' ','')"/>
  16.     <xsl:variable name="under" select="translate(./*[2],' ','')"/>
  17.     <xsl:variable name="over" select="translate(./*[3],' ','')"/>
  18.     <xsl:choose>
  19.         <xsl:when test="$over='¯'">    <!-- OverBar - over bar -->
  20.             <xsl:text>\overline{</xsl:text>
  21.             <xsl:call-template name="munder">
  22.                 <xsl:with-param name="base" select="$base"/>
  23.                 <xsl:with-param name="under" select="$under"/>
  24.             </xsl:call-template>
  25.             <xsl:text>}</xsl:text>
  26.         </xsl:when>
  27.         <xsl:when test="$over='︷' or $over=''">    <!-- OverBrace - over brace -->
  28.             <xsl:text>\overbrace{</xsl:text>
  29.             <xsl:call-template name="munder">
  30.                 <xsl:with-param name="base" select="$base"/>
  31.                 <xsl:with-param name="under" select="$under"/>
  32.             </xsl:call-template>
  33.             <xsl:text>}</xsl:text>
  34.         </xsl:when>
  35.         <xsl:when test="$over='←'">    <!--/leftarrow /gets A: =leftward arrow -->
  36.             <xsl:text>\overleftarrow{</xsl:text>
  37.             <xsl:call-template name="munder">
  38.                 <xsl:with-param name="base" select="$base"/>
  39.                 <xsl:with-param name="under" select="$under"/>
  40.             </xsl:call-template>
  41.             <xsl:text>}</xsl:text>
  42.         </xsl:when>
  43.         <xsl:when test="$over='→'">    <!--/rightarrow /to A: =rightward arrow -->
  44.             <xsl:text>\overrightarrow{</xsl:text>
  45.             <xsl:call-template name="munder">
  46.                 <xsl:with-param name="base" select="$base"/>
  47.                 <xsl:with-param name="under" select="$under"/>
  48.             </xsl:call-template>
  49.             <xsl:text>}</xsl:text>
  50.         </xsl:when>
  51.         <xsl:when test="$over='↔'">    <!--/leftrightarrow A: l&r arrow -->
  52.             <xsl:text>\overleftrightarrow{</xsl:text>
  53.             <xsl:call-template name="munder">
  54.                 <xsl:with-param name="base" select="$base"/>
  55.                 <xsl:with-param name="under" select="$under"/>
  56.             </xsl:call-template>
  57.             <xsl:text>}</xsl:text>
  58.         </xsl:when>
  59.         <xsl:when test="$under='̲'">    <!-- UnderBar - combining low line -->
  60.             <xsl:text>\underline{</xsl:text>
  61.             <xsl:call-template name="mover">
  62.                 <xsl:with-param name="base" select="$base"/>
  63.                 <xsl:with-param name="over" select="$over"/>
  64.                 <xsl:with-param name="pos_over" select="3"/>
  65.             </xsl:call-template>
  66.             <xsl:text>}</xsl:text>
  67.         </xsl:when>
  68.         <xsl:when test="$under='︸' or $under=''">    <!-- UnderBrace - under brace -->
  69.             <xsl:text>\underbrace{</xsl:text>
  70.             <xsl:call-template name="mover">
  71.                 <xsl:with-param name="base" select="$base"/>
  72.                 <xsl:with-param name="over" select="$over"/>
  73.                 <xsl:with-param name="pos_over" select="3"/>
  74.             </xsl:call-template>
  75.             <xsl:text>}</xsl:text>
  76.         </xsl:when>
  77.         <xsl:when test="$under='←'">    <!--/leftarrow /gets A: =leftward arrow -->
  78.             <xsl:text>\underleftarrow{</xsl:text>
  79.             <xsl:call-template name="mover">
  80.                 <xsl:with-param name="base" select="$base"/>
  81.                 <xsl:with-param name="over" select="$over"/>
  82.                 <xsl:with-param name="pos_over" select="3"/>
  83.             </xsl:call-template>
  84.             <xsl:text>}</xsl:text>
  85.         </xsl:when>
  86.         <xsl:when test="$under='→'">    <!--/rightarrow /to A: =rightward arrow -->
  87.             <xsl:text>\underrightarrow{</xsl:text>
  88.             <xsl:call-template name="mover">
  89.                 <xsl:with-param name="base" select="$base"/>
  90.                 <xsl:with-param name="over" select="$over"/>
  91.                 <xsl:with-param name="pos_over" select="3"/>
  92.             </xsl:call-template>
  93.             <xsl:text>}</xsl:text>
  94.         </xsl:when>
  95.         <xsl:when test="$under='↔'">    <!--/leftrightarrow A: l&r arrow -->
  96.             <xsl:text>\underleftrightarrow{</xsl:text>
  97.             <xsl:call-template name="mover">
  98.                 <xsl:with-param name="base" select="$base"/>
  99.                 <xsl:with-param name="over" select="$over"/>
  100.                 <xsl:with-param name="pos_over" select="3"/>
  101.             </xsl:call-template>
  102.             <xsl:text>}</xsl:text>
  103.         </xsl:when>        
  104.         <xsl:when test="translate($base,'∏∐⋂⋃⊔',
  105.                         '∑∑∑∑∑')='∑'">
  106. <!-- if $base is operator, such as
  107.             ∑    /sum L: summation operator
  108.             ∏    /prod L: product operator
  109.             ∐    /coprod L: coproduct operator
  110.             ⋂    /bigcap
  111.             ⋃    /bigcup
  112.             ⊔    /bigsqcup
  113. -->
  114.             <xsl:apply-templates select="./*[1]"/>
  115.             <xsl:text>_{</xsl:text>
  116.             <xsl:apply-templates select="./*[2]"/>
  117.             <xsl:text>}^{</xsl:text>
  118.             <xsl:apply-templates select="./*[3]"/>
  119.             <xsl:text>}</xsl:text>
  120.         </xsl:when>
  121.         <xsl:otherwise>
  122.             <xsl:text>\underset{</xsl:text>
  123.             <xsl:apply-templates select="./*[2]"/>
  124.             <xsl:text>}{\overset{</xsl:text>
  125.             <xsl:apply-templates select="./*[3]"/>
  126.             <xsl:text>}{</xsl:text>
  127.             <xsl:apply-templates select="./*[1]"/>
  128.             <xsl:text>}}</xsl:text>
  129.         </xsl:otherwise>
  130.     </xsl:choose>
  131. </xsl:template>
  132.  
  133. <xsl:template match="m:mover">
  134.     <xsl:call-template name="mover">
  135.         <xsl:with-param name="base" select="translate(./*[1],' ','')"/>
  136.         <xsl:with-param name="over" select="translate(./*[2],' ','')"/>
  137.     </xsl:call-template>
  138. </xsl:template>
  139.  
  140. <xsl:template match="m:munder">
  141.     <xsl:call-template name="munder">
  142.         <xsl:with-param name="base" select="translate(./*[1],' ','')"/>
  143.         <xsl:with-param name="under" select="translate(./*[2],' ','')"/>
  144.     </xsl:call-template>
  145. </xsl:template>
  146.  
  147. <xsl:template name="mover">
  148.     <xsl:param name="base"/>
  149.     <xsl:param name="over"/>
  150.     <xsl:param name="pos_over" select="2"/>
  151.     <xsl:choose>
  152.         <xsl:when test="$over='¯'">    <!-- OverBar - over bar -->
  153.             <xsl:text>\overline{</xsl:text>
  154.             <xsl:apply-templates select="./*[1]"/>
  155.             <xsl:text>}</xsl:text>
  156.         </xsl:when>
  157.         <xsl:when test="$over='︷' or $over=''">    <!-- OverBrace - over brace -->
  158.             <xsl:text>\overbrace{</xsl:text>
  159.             <xsl:apply-templates select="./*[1]"/>
  160.             <xsl:text>}</xsl:text>
  161.         </xsl:when>
  162.         <xsl:when test="$over='←'">    <!--/leftarrow /gets A: =leftward arrow -->
  163.             <xsl:text>\overleftarrow{</xsl:text>
  164.             <xsl:apply-templates select="./*[1]"/>
  165.             <xsl:text>}</xsl:text>
  166.         </xsl:when>
  167.         <xsl:when test="$over='→'">    <!--/rightarrow /to A: =rightward arrow -->
  168.             <xsl:text>\overrightarrow{</xsl:text>
  169.             <xsl:apply-templates select="./*[1]"/>
  170.             <xsl:text>}</xsl:text>
  171.         </xsl:when>
  172.         <xsl:when test="$over='↔'">    <!--/leftrightarrow A: l&r arrow -->
  173.             <xsl:text>\overleftrightarrow{</xsl:text>
  174.             <xsl:apply-templates select="./*[1]"/>
  175.             <xsl:text>}</xsl:text>
  176.         </xsl:when>
  177.         <xsl:when test="$over='˜'">    <!-- small tilde -->
  178.             <xsl:text>\tilde{</xsl:text>
  179.             <xsl:apply-templates select="./*[1]"/>
  180.             <xsl:text>}</xsl:text>
  181.         </xsl:when>
  182.         <xsl:when test="$over='✓'">    <!-- /checkmark =tick, check mark -->
  183.             <xsl:text>\check{</xsl:text>
  184.             <xsl:apply-templates select="./*[1]"/>
  185.             <xsl:text>}</xsl:text>
  186.         </xsl:when>
  187.             <xsl:when test="$over='˙'">    <!-- dot above -->
  188.             <xsl:text>\dot{</xsl:text>
  189.             <xsl:apply-templates select="./*[1]"/>
  190.             <xsl:text>}</xsl:text>
  191.         </xsl:when>
  192.         <xsl:when test="$over='¨'">    <!-- DoubleDot - dieresis or umlaut mark -->
  193.             <xsl:text>\ddot{</xsl:text>
  194.              <xsl:apply-templates select="./*[1]"/>
  195.              <xsl:text>}</xsl:text>
  196.          </xsl:when>
  197.          <xsl:when test="$over='´'"> <!-- Acute accent "┬┤" -->
  198.             <xsl:text>\acute{</xsl:text>
  199.              <xsl:apply-templates select="./*[1]"/>
  200.              <xsl:text>}</xsl:text>
  201.          </xsl:when>
  202.          <xsl:when test="$over='`'"> <!-- Grave accent "`" -->
  203.             <xsl:text>\grave{</xsl:text>
  204.              <xsl:apply-templates select="./*[1]"/>
  205.              <xsl:text>}</xsl:text>
  206.          </xsl:when>
  207.          <xsl:when test="$over='ˇ'"> <!-- Caron (Mandarin Chinese third tone) "╦ç" -->
  208.             <xsl:text>\check{</xsl:text>
  209.              <xsl:apply-templates select="./*[1]"/>
  210.              <xsl:text>}</xsl:text>
  211.          </xsl:when>
  212.          <xsl:when test="$over='˘'"> <!-- Breve accent "╦ÿ" -->
  213.             <xsl:text>\breve{</xsl:text>
  214.              <xsl:apply-templates select="./*[1]"/>
  215.              <xsl:text>}</xsl:text>
  216.          </xsl:when>
  217.          <xsl:when test="$over='˚'"> <!-- ring above "╦Ü" -->
  218.             <xsl:text>\overset{\circ}{</xsl:text>
  219.              <xsl:apply-templates select="./*[1]"/>
  220.             <xsl:text>}</xsl:text>
  221.          </xsl:when>
  222.          <xsl:when test="$over='ˉ'"> <!-- modifier letter Macron (Mandarin Chinese first tone) "╦ë" -->
  223.             <xsl:text>\bar{</xsl:text>
  224.              <xsl:apply-templates select="./*[1]"/>
  225.              <xsl:text>}</xsl:text>
  226.          </xsl:when>
  227.          <xsl:when test="$over='¨'"> <!--  Diaeresis "┬¿" -->
  228.             <xsl:text>\ddot{</xsl:text>
  229.              <xsl:apply-templates select="./*[1]"/>
  230.              <xsl:text>}</xsl:text>
  231.          </xsl:when>
  232.          
  233.          <xsl:when test="$over='̂' or $over='^' or $over='ˆ'"> <!-- Hat or circ - circumflex accent -->
  234.             <xsl:choose>
  235.                 <xsl:when test="@oomath:accent='true'">
  236.                     <xsl:text>\widehat{</xsl:text>
  237.                 </xsl:when>
  238.                 <xsl:otherwise>
  239.                     <xsl:text>\hat{</xsl:text>
  240.                 </xsl:otherwise>
  241.             </xsl:choose>
  242.             <xsl:apply-templates select="./*[1]"/><xsl:text>}</xsl:text>
  243.         </xsl:when>
  244.         <xsl:when test="translate($base,'∏∐⋂⋃⊔',
  245.                         '∑∑∑∑∑')='∑'">
  246. <!-- if $base is operator, such as
  247.             ∑    /sum L: summation operator
  248.             ∏    /prod L: product operator
  249.             ∐    /coprod L: coproduct operator
  250.             ⋂    /bigcap
  251.             ⋃    /bigcup
  252.             ⊔    /bigsqcup
  253. -->
  254.             <xsl:apply-templates select="./*[1]"/>
  255.             <xsl:text>^{</xsl:text>
  256.             <xsl:apply-templates select="./*[$pos_over]"/>
  257.             <xsl:text>}</xsl:text>
  258.         </xsl:when>
  259.         <xsl:otherwise>
  260.             <xsl:text>\stackrel{</xsl:text>
  261.             <xsl:apply-templates select="./*[$pos_over]"/>
  262.             <xsl:text>}{</xsl:text>
  263.             <xsl:apply-templates select="./*[1]"/>
  264.             <xsl:text>}</xsl:text>
  265.             <!--
  266.             <xsl:text>\overset{</xsl:text>
  267.             <xsl:apply-templates select="./*[$pos_over]"/>
  268.             <xsl:text>}{</xsl:text>    
  269.             <xsl:apply-templates select="./*[1]"/>
  270.             <xsl:text>}</xsl:text>-->
  271.         </xsl:otherwise>
  272.     </xsl:choose>
  273. </xsl:template>
  274.  
  275. <xsl:template name="munder">
  276.     <xsl:param name="base"/>
  277.     <xsl:param name="under"/>
  278.     <xsl:choose>
  279.         <xsl:when test="$under='̲'">    <!-- UnderBar - combining low line -->
  280.             <xsl:text>\underline{</xsl:text>
  281.             <xsl:apply-templates select="./*[1]"/>
  282.             <xsl:text>}</xsl:text>
  283.         </xsl:when>
  284.         <xsl:when test="$under='︸' or $under=''">    <!-- UnderBrace - under brace -->
  285.             <xsl:text>\underbrace{</xsl:text>
  286.             <xsl:apply-templates select="./*[1]"/>
  287.             <xsl:text>}</xsl:text>
  288.         </xsl:when>
  289.         <xsl:when test="$under='←'">    <!--/leftarrow /gets A: =leftward arrow -->
  290.             <xsl:text>\underleftarrow{</xsl:text>
  291.             <xsl:apply-templates select="./*[1]"/>
  292.             <xsl:text>}</xsl:text>
  293.         </xsl:when>
  294.         <xsl:when test="$under='→'">    <!--/rightarrow /to A: =rightward arrow -->
  295.             <xsl:text>\underrightarrow{</xsl:text>
  296.             <xsl:apply-templates select="./*[1]"/>
  297.             <xsl:text>}</xsl:text>
  298.         </xsl:when>
  299.         <xsl:when test="$under='↔'">    <!--/leftrightarrow A: l&r arrow -->
  300.             <xsl:text>\underleftrightarrow{</xsl:text>
  301.             <xsl:apply-templates select="./*[1]"/>
  302.             <xsl:text>}</xsl:text>
  303.         </xsl:when>
  304.         <xsl:when test="translate($base,'∏∐⋂⋃⊔',
  305.                         '∑∑∑∑∑')='∑'">
  306. <!-- if $base is operator, such as
  307.             ∑    /sum L: summation operator
  308.             ∏    /prod L: product operator
  309.             ∐    /coprod L: coproduct operator
  310.             ⋂    /bigcap
  311.             ⋃    /bigcup
  312.             ⊔    /bigsqcup
  313. -->
  314.             <xsl:apply-templates select="./*[1]"/>
  315.             <xsl:text>_{</xsl:text>
  316.             <xsl:apply-templates select="./*[2]"/>
  317.             <xsl:text>}</xsl:text>
  318.         </xsl:when>
  319.         <xsl:otherwise>
  320.             <xsl:text>\underset{</xsl:text>        <!-- Required AmsMath package -->
  321.             <xsl:apply-templates select="./*[2]"/>
  322.             <xsl:text>}{</xsl:text>    
  323.             <xsl:apply-templates select="./*[1]"/>
  324.             <xsl:text>}</xsl:text>    
  325.         </xsl:otherwise>
  326.     </xsl:choose>
  327. </xsl:template>
  328.  
  329. <xsl:template match="m:msubsup">
  330.     <xsl:text>{</xsl:text>    
  331.     <xsl:apply-templates select="./*[1]"/>
  332.     <xsl:text>}_{</xsl:text>
  333.     <xsl:apply-templates select="./*[2]"/>
  334.     <xsl:text>}^{</xsl:text>    
  335.     <xsl:apply-templates select="./*[3]"/>
  336.     <xsl:text>}</xsl:text>    
  337. </xsl:template>
  338.  
  339. <xsl:template match="m:msup">
  340.     <xsl:text>{</xsl:text>    
  341.     <xsl:apply-templates select="./*[1]"/>
  342.     <xsl:text>}^{</xsl:text>    
  343.     <xsl:apply-templates select="./*[2]"/>
  344.     <xsl:text>}</xsl:text>    
  345. </xsl:template>
  346.  
  347. <xsl:template match="m:msub">
  348.     <xsl:text>{</xsl:text>    
  349.     <xsl:apply-templates select="./*[1]"/>
  350.     <xsl:text>}_{</xsl:text>    
  351.     <xsl:apply-templates select="./*[2]"/>
  352.     <xsl:text>}</xsl:text>    
  353. </xsl:template>
  354.  
  355. <xsl:template match="m:mmultiscripts" mode="mprescripts">
  356.     <xsl:for-each select="m:mprescripts/following-sibling::*">
  357.         <xsl:if test="position() mod 2 and local-name(.)!='none'">
  358.             <xsl:text>{}_{</xsl:text>    
  359.             <xsl:apply-templates select="."/>
  360.             <xsl:text>}</xsl:text>    
  361.         </xsl:if>
  362.         <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
  363.             <xsl:text>{}^{</xsl:text>    
  364.             <xsl:apply-templates select="."/>
  365.             <xsl:text>}</xsl:text>    
  366.         </xsl:if>
  367.     </xsl:for-each>
  368.     <xsl:apply-templates select="./*[1]"/>
  369.     <xsl:for-each select="m:mprescripts/preceding-sibling::*[position()!=last()]">
  370.         <xsl:if test="position()>2 and local-name(.)!='none'">
  371.             <xsl:text>{}</xsl:text>    
  372.         </xsl:if>
  373.         <xsl:if test="position() mod 2 and local-name(.)!='none'">
  374.             <xsl:text>_{</xsl:text>    
  375.             <xsl:apply-templates select="."/>
  376.             <xsl:text>}</xsl:text>    
  377.         </xsl:if>
  378.         <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
  379.             <xsl:text>^{</xsl:text>    
  380.             <xsl:apply-templates select="."/>
  381.             <xsl:text>}</xsl:text>    
  382.         </xsl:if>
  383.     </xsl:for-each>
  384. </xsl:template>
  385.  
  386. <xsl:template match="m:mmultiscripts">
  387.     <xsl:choose>
  388.         <xsl:when test="m:mprescripts">
  389.             <xsl:apply-templates select="." mode="mprescripts"/>
  390.         </xsl:when>
  391.         <xsl:otherwise>
  392.             <xsl:apply-templates select="./*[1]"/>
  393.             <xsl:for-each select="*[position()>1]">
  394.                 <xsl:if test="position()>2 and local-name(.)!='none'">
  395.                     <xsl:text>{}</xsl:text>    
  396.                 </xsl:if>
  397.                 <xsl:if test="position() mod 2 and local-name(.)!='none'">
  398.                     <xsl:text>_{</xsl:text>    
  399.                     <xsl:apply-templates select="."/>
  400.                     <xsl:text>}</xsl:text>    
  401.                 </xsl:if>
  402.                 <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
  403.                     <xsl:text>^{</xsl:text>    
  404.                     <xsl:apply-templates select="."/>
  405.                     <xsl:text>}</xsl:text>    
  406.                 </xsl:if>
  407.             </xsl:for-each>
  408.         </xsl:otherwise>
  409.     </xsl:choose>
  410. </xsl:template>
  411.  
  412. </xsl:stylesheet>
  413.