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 / glayout.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2011-02-15  |  7.3 KB  |  233 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: glayout.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. <!-- 3.3.2 mfrac -->
  15. <xsl:template match="m:mfrac">
  16.     <xsl:choose>
  17.         <xsl:when test="@linethickness">
  18.             <xsl:text>\genfrac{}{}{</xsl:text>
  19.             <xsl:choose>
  20.                 <xsl:when test="number(@linethickness)">
  21.                     <xsl:value-of select="@linethickness div 10"/>
  22.                     <xsl:text>ex</xsl:text>
  23.                 </xsl:when>
  24.                 <xsl:when test="@linethickness='0'">
  25.                     <xsl:text>0ex</xsl:text>
  26.                 </xsl:when>
  27.                 <xsl:when test="@linethickness='thin'">
  28.                     <xsl:text>.05ex</xsl:text>
  29.                 </xsl:when>
  30.                 <xsl:when test="@linethickness='medium'"/>
  31.                 <xsl:when test="@linethickness='thick'">
  32.                     <xsl:text>.2ex</xsl:text>
  33.                 </xsl:when>
  34.                 <xsl:otherwise>
  35.                     <xsl:value-of select="@linethickness"/>
  36.                 </xsl:otherwise>
  37.             </xsl:choose>
  38.             <xsl:text>}{}{</xsl:text>
  39.         </xsl:when>
  40.         <xsl:otherwise>
  41.             <xsl:text>\frac{</xsl:text>
  42.         </xsl:otherwise>
  43.     </xsl:choose>
  44.     <xsl:if test="@numalign='right'">
  45.         <xsl:text>\hfill </xsl:text>
  46.     </xsl:if>
  47.     <xsl:apply-templates select="./*[1]"/>
  48.     <xsl:if test="@numalign='left'">
  49.         <xsl:text>\hfill </xsl:text>
  50.     </xsl:if>
  51.     <xsl:text>}{</xsl:text>    
  52.     <xsl:if test="@denomalign='right'">
  53.         <xsl:text>\hfill </xsl:text>
  54.     </xsl:if>
  55.     <xsl:apply-templates select="./*[2]"/>
  56.         <xsl:if test="@denomalign='left'">
  57.         <xsl:text>\hfill </xsl:text>
  58.     </xsl:if>
  59.     <xsl:text>}</xsl:text>
  60. </xsl:template>
  61.  
  62. <xsl:template match="m:mfrac[@bevelled='true']">
  63.     <xsl:text>\raisebox{1ex}{$</xsl:text>
  64.     <xsl:apply-templates select="./*[1]"/>
  65.     <xsl:text>$}\!\left/ \!\raisebox{-1ex}{$</xsl:text>
  66.     <xsl:apply-templates select="./*[2]"/>
  67.     <xsl:text>$}\right.</xsl:text>
  68. </xsl:template>
  69.  
  70.  
  71. <xsl:template match="m:mroot">
  72.     <xsl:choose>
  73.         <xsl:when test="count(./*)=2">
  74.             <xsl:text>\sqrt[</xsl:text>
  75.             <xsl:apply-templates select="./*[2]"/>
  76.             <xsl:text>]{</xsl:text>    
  77.             <xsl:apply-templates select="./*[1]"/>
  78.             <xsl:text>}</xsl:text>    
  79.         </xsl:when>
  80.         <xsl:otherwise>
  81.         <!-- number of argumnets is not 2 - code 25 -->
  82.             <xsl:message>exception 25:</xsl:message>
  83.             <xsl:text>\text{exception 25:}</xsl:text> 
  84.         </xsl:otherwise>
  85.     </xsl:choose>
  86. </xsl:template>
  87.  
  88. <xsl:template match="m:msqrt">
  89.     <xsl:text>\sqrt{</xsl:text>
  90.     <xsl:apply-templates/>
  91.     <xsl:text>}</xsl:text>
  92. </xsl:template>
  93.  
  94. <xsl:template match="m:mfenced">
  95.     <xsl:choose>
  96.         <xsl:when test="@oomath:open">
  97.             <xsl:if test="translate(@oomath:open,'{}[]()|∣','{{{{{{{{{{')='{'">
  98.                 <xsl:text>\left</xsl:text>
  99.             </xsl:if>
  100.             <xsl:if test="translate(@oomath:open,'{}[]()|∣','{{{{{{{{{{')!='{' and (translate(@oomath:close,'{}[]()|∣','{{{{{{{{{{')='{' or not(@oomath:close))">
  101.                 <xsl:text>\left.</xsl:text>
  102.             </xsl:if>
  103.             <xsl:call-template name="replaceEntities">
  104.                 <xsl:with-param name="content" select="@oomath:open"/>
  105.             </xsl:call-template>
  106.         </xsl:when>
  107.         <xsl:otherwise><xsl:text>\left(</xsl:text></xsl:otherwise>
  108.     </xsl:choose>
  109.             <xsl:variable name="sep">
  110.                 <xsl:choose>
  111.                     <xsl:when test="@separators">
  112.                         <xsl:value-of select="translate(@separators,' ','')"/>
  113.                     </xsl:when>
  114.                     <xsl:otherwise>,</xsl:otherwise>
  115.                 </xsl:choose>
  116.             </xsl:variable>
  117.             <xsl:for-each select="./*">
  118.                 <xsl:apply-templates select="."/>
  119.                 <xsl:if test="not(position()=last())">
  120.                     <xsl:choose>
  121.                         <xsl:when test="position()>string-length($sep)">
  122.                             <xsl:value-of select="substring($sep,string-length($sep))"/>
  123.                         </xsl:when>
  124.                         <xsl:otherwise>
  125.                             <xsl:value-of select="substring($sep,position(),1)"/>
  126.                         </xsl:otherwise>
  127.                     </xsl:choose>
  128.                 </xsl:if>
  129.             </xsl:for-each>
  130.     <xsl:choose>
  131.         <xsl:when test="@oomath:close">
  132.             <xsl:if test="translate(@oomath:close,'{}[]()|∣','{{{{{{{{{{')='{'">
  133.                 <xsl:text>\right</xsl:text>
  134.             </xsl:if>
  135.             <xsl:if test="translate(@oomath:close,'{}[]()|∣','{{{{{{{{{{')!='{' and (translate(@oomath:open,'{}[]()|∣','{{{{{{{{{{')='{' or not(@oomath:open))">
  136.                 <xsl:text>\right.</xsl:text>
  137.             </xsl:if>
  138.             <xsl:call-template name="replaceEntities">
  139.                 <xsl:with-param name="content" select="@oomath:close"/>
  140.             </xsl:call-template>
  141.         </xsl:when>
  142.         <xsl:otherwise><xsl:text>\right)</xsl:text></xsl:otherwise>
  143.     </xsl:choose>    
  144. </xsl:template>
  145.  
  146. <xsl:template match="m:mphantom">
  147. <!-- Not supported by MediaWiki. -->
  148. <!-- 
  149.      <xsl:text>\phantom{</xsl:text>
  150.  -->
  151.     <xsl:apply-templates/>
  152. <!-- 
  153.     <xsl:text>}</xsl:text>
  154.  -->
  155. </xsl:template>
  156.  
  157. <xsl:template match="m:menclose">
  158.     <xsl:choose>
  159.         <xsl:when test="@notation = 'actuarial'">
  160.             <xsl:text>\overline{</xsl:text>
  161.             <xsl:apply-templates/>
  162.             <xsl:text>\hspace{.2em}|}</xsl:text>
  163.         </xsl:when>
  164.         <xsl:when test="@notation = 'radical'">
  165.             <xsl:text>\sqrt{</xsl:text>
  166.             <xsl:apply-templates/>
  167.             <xsl:text>}</xsl:text>
  168.         </xsl:when>
  169.         <xsl:otherwise>
  170.             <xsl:text>\overline{)</xsl:text>
  171.             <xsl:apply-templates/>
  172.             <xsl:text>}</xsl:text>
  173.         </xsl:otherwise>
  174.     </xsl:choose>
  175. </xsl:template>
  176.  
  177. <xsl:template match="m:mrow">
  178.     <xsl:apply-templates/>
  179. </xsl:template>
  180.  
  181. <xsl:template match="m:mstyle">
  182.     <xsl:if test="@displaystyle='true'">
  183.         <xsl:text>{\displaystyle </xsl:text>
  184.     </xsl:if>
  185.     <xsl:if test="@scriptlevel and not(@displaystyle='true')">
  186.         <xsl:text>{</xsl:text>
  187.         <xsl:choose>
  188.             <xsl:when test="@scriptlevel=0"><xsl:text>\textstyle </xsl:text></xsl:when>
  189.             <xsl:when test="@scriptlevel=1"><xsl:text>\scriptstyle </xsl:text></xsl:when>
  190.             <xsl:otherwise><xsl:text>\scriptscriptstyle </xsl:text></xsl:otherwise> 
  191.         </xsl:choose> 
  192.     </xsl:if>    
  193.     <xsl:if test="@background">
  194.         <xsl:text>\colorbox[rgb]{</xsl:text>
  195.         <xsl:call-template name="color">
  196.             <xsl:with-param name="color" select="@background"/>
  197.         </xsl:call-template>
  198.         <xsl:text>}{$</xsl:text>
  199.     </xsl:if>
  200.     <xsl:if test="@color or @mathcolor">
  201.         <xsl:variable name="color">
  202.             <xsl:choose>
  203.                 <xsl:when test="@mathcolor"><xsl:value-of select="@mathcolor"/></xsl:when>
  204.                 <xsl:when test="@color"><xsl:value-of select="@color"/></xsl:when>
  205.             </xsl:choose>
  206.         </xsl:variable>
  207.         <xsl:text>\textcolor[rgb]{</xsl:text>
  208.         <xsl:call-template name="color">
  209.             <xsl:with-param name="color" select="$color"/>
  210.         </xsl:call-template>
  211.         <xsl:text>}{</xsl:text>
  212.     </xsl:if>
  213.     <xsl:apply-templates/>
  214.     <xsl:if test="@color or @mathcolor">
  215.         <xsl:text>}</xsl:text>
  216.     </xsl:if>
  217.     <xsl:if test="@background">
  218.         <xsl:text>$}</xsl:text>
  219.     </xsl:if>
  220.     <xsl:if test="@scriptlevel and not(@displaystyle='true')">
  221.         <xsl:text>}</xsl:text>
  222.     </xsl:if>    
  223.     <xsl:if test="@displaystyle='true'">
  224.         <xsl:text>}</xsl:text>
  225.     </xsl:if>
  226. </xsl:template>
  227.  
  228. <xsl:template match="m:merror">
  229.     <xsl:apply-templates/>
  230. </xsl:template>
  231.  
  232. </xsl:stylesheet>
  233.