home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 Autumn / INTERNET109.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _EC5F663B357640D59F71BBB1BDD96E57 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  10.5 KB  |  318 lines

  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets. Do not edit this file.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  5.  
  6. <!-- ********************************************************************
  7.      $Id: math.xsl,v 1.1.2.3 2002/09/04 13:55:44 jdj Exp $
  8.      ********************************************************************
  9.  
  10.      This file is part of the XSL DocBook Stylesheet distribution.
  11.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  12.      and other information.
  13.  
  14.      ******************************************************************** -->
  15.  
  16. <xsl:template match="inlineequation">
  17.   <xsl:apply-templates/>
  18. </xsl:template>
  19.  
  20. <xsl:template match="alt">
  21. </xsl:template>
  22.  
  23. <!-- "Support" for MathML -->
  24.  
  25. <xsl:template xmlns:mml="http://www.w3.org/1998/Math/MathML" match="mml:*">
  26.   <xsl:copy>
  27.     <xsl:copy-of select="@*"/>
  28.     <xsl:apply-templates/>
  29.   </xsl:copy>
  30. </xsl:template>
  31.  
  32. <!-- Support for TeX math in alt -->
  33.  
  34. <xsl:template match="*" mode="collect.tex.math">
  35.   <xsl:call-template name="write.text.chunk">
  36.     <xsl:with-param name="filename" select="$tex.math.file"/>
  37.     <xsl:with-param name="method" select="'text'"/>
  38.     <xsl:with-param name="content">
  39.       <xsl:choose>
  40.         <xsl:when test="$tex.math.in.alt = 'plain'">
  41.           <xsl:call-template name="tex.math.plain.head"/>
  42.           <xsl:apply-templates select="." mode="collect.tex.math.plain"/>
  43.           <xsl:call-template name="tex.math.plain.tail"/>
  44.         </xsl:when>
  45.         <xsl:when test="$tex.math.in.alt = 'latex'">
  46.           <xsl:call-template name="tex.math.latex.head"/>
  47.           <xsl:apply-templates select="." mode="collect.tex.math.latex"/>
  48.           <xsl:call-template name="tex.math.latex.tail"/>
  49.         </xsl:when>
  50.         <xsl:otherwise>
  51.           <xsl:message>
  52.             Unsupported TeX math notation: 
  53.             <xsl:value-of select="$tex.math.in.alt"/>
  54.           </xsl:message>
  55.         </xsl:otherwise>
  56.       </xsl:choose>
  57.     </xsl:with-param>
  58.     <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
  59.   </xsl:call-template>
  60. </xsl:template>
  61.  
  62. <!-- PlainTeX -->
  63.  
  64. <xsl:template name="tex.math.plain.head">
  65.   <xsl:text>\nopagenumbers 
  66. </xsl:text>
  67. </xsl:template>
  68.  
  69. <xsl:template name="tex.math.plain.tail">
  70.   <xsl:text>\bye 
  71. </xsl:text>
  72. </xsl:template>
  73.  
  74. <xsl:template match="inlineequation" mode="collect.tex.math.plain">
  75.   <xsl:variable name="filename">
  76.     <xsl:choose>
  77.       <xsl:when test="graphic">
  78.         <xsl:call-template name="mediaobject.filename">
  79.           <xsl:with-param name="object" select="graphic"/>
  80.         </xsl:call-template>
  81.       </xsl:when>
  82.       <xsl:otherwise>
  83.         <xsl:call-template name="select.mediaobject.filename">
  84.           <xsl:with-param name="olist" select="inlinemediaobject/*"/>
  85.         </xsl:call-template>
  86.       </xsl:otherwise>
  87.     </xsl:choose>
  88.   </xsl:variable>
  89.   <xsl:variable name="output.delims">
  90.     <xsl:call-template name="tex.math.output.delims"/>
  91.   </xsl:variable>
  92.   <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
  93.   <xsl:if test="$tex">
  94.     <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
  95.     <xsl:value-of select="$filename"/>
  96.     <xsl:text>} 
  97. </xsl:text>
  98.     <xsl:if test="$output.delims != 0">
  99.       <xsl:text>$</xsl:text>
  100.     </xsl:if>
  101.     <xsl:value-of select="$tex"/>
  102.     <xsl:if test="$output.delims != 0">
  103.       <xsl:text>$ 
  104. </xsl:text>
  105.     </xsl:if>
  106.     <xsl:text>\vfill\eject 
  107. </xsl:text>
  108.   </xsl:if>
  109. </xsl:template>
  110.  
  111. <xsl:template match="equation|informalequation" mode="collect.tex.math.plain">
  112.   <xsl:variable name="filename">
  113.     <xsl:choose>
  114.       <xsl:when test="graphic">
  115.         <xsl:call-template name="mediaobject.filename">
  116.           <xsl:with-param name="object" select="graphic"/>
  117.         </xsl:call-template>
  118.       </xsl:when>
  119.       <xsl:otherwise>
  120.         <xsl:call-template name="select.mediaobject.filename">
  121.           <xsl:with-param name="olist" select="mediaobject/*"/>
  122.         </xsl:call-template>
  123.       </xsl:otherwise>
  124.     </xsl:choose>
  125.   </xsl:variable>
  126.   <xsl:variable name="output.delims">
  127.     <xsl:call-template name="tex.math.output.delims"/>
  128.   </xsl:variable>
  129.   <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
  130.   <xsl:if test="$tex">
  131.     <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
  132.     <xsl:value-of select="$filename"/>
  133.     <xsl:text>} 
  134. </xsl:text>
  135.     <xsl:if test="$output.delims != 0">
  136.       <xsl:text>$$</xsl:text>
  137.     </xsl:if>
  138.     <xsl:value-of select="$tex"/>
  139.     <xsl:if test="$output.delims != 0">
  140.       <xsl:text>$$ 
  141. </xsl:text>
  142.     </xsl:if>
  143.     <xsl:text>\vfill\eject 
  144. </xsl:text>
  145.   </xsl:if>
  146. </xsl:template>
  147.  
  148. <xsl:template match="text()" mode="collect.tex.math.plain"/>
  149.  
  150. <!-- LaTeX -->
  151.  
  152. <xsl:template name="tex.math.latex.head">
  153.   <xsl:text>\documentclass{article} 
  154. </xsl:text>
  155.   <xsl:text>\pagestyle{empty} 
  156. </xsl:text>
  157.   <xsl:text>\begin{document} 
  158. </xsl:text>
  159. </xsl:template>
  160.  
  161. <xsl:template name="tex.math.latex.tail">
  162.   <xsl:text>\end{document} 
  163. </xsl:text>
  164. </xsl:template>
  165.  
  166. <xsl:template match="inlineequation" mode="collect.tex.math.latex">
  167.   <xsl:variable name="filename">
  168.     <xsl:choose>
  169.       <xsl:when test="graphic">
  170.         <xsl:call-template name="mediaobject.filename">
  171.           <xsl:with-param name="object" select="graphic"/>
  172.         </xsl:call-template>
  173.       </xsl:when>
  174.       <xsl:otherwise>
  175.         <xsl:call-template name="select.mediaobject.filename">
  176.           <xsl:with-param name="olist" select="inlinemediaobject/*"/>
  177.         </xsl:call-template>
  178.       </xsl:otherwise>
  179.     </xsl:choose>
  180.   </xsl:variable>
  181.   <xsl:variable name="output.delims">
  182.     <xsl:call-template name="tex.math.output.delims"/>
  183.   </xsl:variable>
  184.   <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
  185.   <xsl:if test="$tex">
  186.     <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
  187.     <xsl:value-of select="$filename"/>
  188.     <xsl:text>} 
  189. </xsl:text>
  190.     <xsl:if test="$output.delims != 0">  
  191.       <xsl:text>$</xsl:text>
  192.     </xsl:if>
  193.     <xsl:value-of select="$tex"/>
  194.     <xsl:if test="$output.delims != 0">  
  195.       <xsl:text>$ 
  196. </xsl:text>
  197.     </xsl:if>
  198.     <xsl:text>\newpage 
  199. </xsl:text>
  200.   </xsl:if>
  201. </xsl:template>
  202.  
  203. <xsl:template match="equation|informalequation" mode="collect.tex.math.latex">
  204.   <xsl:variable name="filename">
  205.     <xsl:choose>
  206.       <xsl:when test="graphic">
  207.         <xsl:call-template name="mediaobject.filename">
  208.           <xsl:with-param name="object" select="graphic"/>
  209.         </xsl:call-template>
  210.       </xsl:when>
  211.       <xsl:otherwise>
  212.         <xsl:call-template name="select.mediaobject.filename">
  213.           <xsl:with-param name="olist" select="mediaobject/*"/>
  214.         </xsl:call-template>
  215.       </xsl:otherwise>
  216.     </xsl:choose>
  217.   </xsl:variable>
  218.   <xsl:variable name="output.delims">
  219.     <xsl:call-template name="tex.math.output.delims"/>
  220.   </xsl:variable>
  221.   <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
  222.   <xsl:if test="$tex">
  223.     <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
  224.     <xsl:value-of select="$filename"/>
  225.     <xsl:text>} 
  226. </xsl:text>
  227.     <xsl:if test="$output.delims != 0">
  228.       <xsl:text>$$</xsl:text>
  229.     </xsl:if>
  230.     <xsl:value-of select="$tex"/>
  231.     <xsl:if test="$output.delims != 0">
  232.       <xsl:text>$$ 
  233. </xsl:text>
  234.     </xsl:if>
  235.     <xsl:text>\newpage 
  236. </xsl:text>
  237.   </xsl:if>
  238. </xsl:template>
  239.  
  240. <xsl:template match="text()" mode="collect.tex.math.latex"/>
  241.  
  242. <!-- Extracting image filename from mediaobject and graphic elements -->
  243.  
  244. <xsl:template name="select.mediaobject.filename">
  245.   <xsl:param name="olist" select="imageobject|imageobjectco                      |videoobject|audioobject|textobject"/>
  246.   <xsl:param name="count">1</xsl:param>
  247.  
  248.   <xsl:if test="$count <= count($olist)">
  249.     <xsl:variable name="object" select="$olist[position()=$count]"/>
  250.  
  251.     <xsl:variable name="useobject">
  252.       <xsl:choose>
  253.     <!-- The phrase is never used -->
  254.         <xsl:when test="name($object)='textobject' and $object/phrase">
  255.           <xsl:text>0</xsl:text>
  256.         </xsl:when>
  257.     <!-- The first textobject is not a reasonable fallback for equation image -->
  258.         <xsl:when test="name($object)='textobject'">
  259.           <xsl:text>0</xsl:text>
  260.         </xsl:when>
  261.     <!-- If there's only one object, use it -->
  262.     <xsl:when test="$count = 1 and count($olist) = 1">
  263.       <xsl:text>1</xsl:text>
  264.     </xsl:when>
  265.     <!-- Otherwise, see if this one is a useable graphic -->
  266.         <xsl:otherwise>
  267.           <xsl:choose>
  268.             <!-- peek inside imageobjectco to simplify the test -->
  269.             <xsl:when test="local-name($object) = 'imageobjectco'">
  270.               <xsl:call-template name="is.acceptable.mediaobject">
  271.                 <xsl:with-param name="object" select="$object/imageobject"/>
  272.               </xsl:call-template>
  273.             </xsl:when>
  274.             <xsl:otherwise>
  275.               <xsl:call-template name="is.acceptable.mediaobject">
  276.                 <xsl:with-param name="object" select="$object"/>
  277.               </xsl:call-template>
  278.             </xsl:otherwise>
  279.           </xsl:choose>
  280.         </xsl:otherwise>
  281.       </xsl:choose>
  282.     </xsl:variable>
  283.  
  284.     <xsl:choose>
  285.       <xsl:when test="$useobject='1'">
  286.         <xsl:call-template name="mediaobject.filename">
  287.           <xsl:with-param name="object" select="$object"/>
  288.         </xsl:call-template>
  289.       </xsl:when>
  290.       <xsl:otherwise>
  291.         <xsl:call-template name="select.mediaobject">
  292.           <xsl:with-param name="olist" select="$olist"/>
  293.           <xsl:with-param name="count" select="$count + 1"/>
  294.         </xsl:call-template>
  295.       </xsl:otherwise>
  296.     </xsl:choose>
  297.   </xsl:if>
  298. </xsl:template>
  299.  
  300. <xsl:template name="tex.math.output.delims">
  301.   <xsl:variable name="pi.delims">
  302.     <xsl:call-template name="pi-attribute">
  303.       <xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
  304.       <xsl:with-param name="attribute" select="'delims'"/>
  305.     </xsl:call-template>
  306.   </xsl:variable>
  307.   <xsl:variable name="result">
  308.     <xsl:choose>
  309.       <xsl:when test="$pi.delims = 'no'">0</xsl:when>
  310.       <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
  311.       <xsl:otherwise>1</xsl:otherwise>
  312.     </xsl:choose>
  313.   </xsl:variable>
  314.   <xsl:value-of select="$result"/>
  315. </xsl:template>
  316.  
  317. </xsl:stylesheet>
  318.