1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="mml" version="1.0">
6 <!-- ********************************************************************
7 $Id: math.xsl 9297 2012-04-22 03:56:16Z bobstayton $
8 ********************************************************************
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
14 ******************************************************************** -->
16 <xsl:template match="inlineequation">
17 <xsl:apply-templates/>
20 <xsl:template match="alt">
23 <xsl:template match="mathphrase">
25 <xsl:apply-templates select="." mode="common.html.attributes"/>
26 <xsl:call-template name="id.attribute"/>
27 <xsl:apply-templates/>
31 <!-- "Support" for MathML -->
33 <xsl:template match="mml:*">
35 <xsl:copy-of select="@*"/>
36 <xsl:apply-templates/>
40 <!-- Support for TeX math in alt -->
42 <xsl:template match="*" mode="collect.tex.math">
43 <xsl:call-template name="write.text.chunk">
44 <xsl:with-param name="filename" select="$tex.math.file"/>
45 <xsl:with-param name="method" select="'text'"/>
46 <xsl:with-param name="content">
48 <xsl:when test="$tex.math.in.alt = 'plain'">
49 <xsl:call-template name="tex.math.plain.head"/>
50 <xsl:apply-templates select="." mode="collect.tex.math.plain"/>
51 <xsl:call-template name="tex.math.plain.tail"/>
53 <xsl:when test="$tex.math.in.alt = 'latex'">
54 <xsl:call-template name="tex.math.latex.head"/>
55 <xsl:apply-templates select="." mode="collect.tex.math.latex"/>
56 <xsl:call-template name="tex.math.latex.tail"/>
60 Unsupported TeX math notation:
61 <xsl:value-of select="$tex.math.in.alt"/>
66 <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
72 <xsl:template name="tex.math.plain.head">
73 <xsl:text>\nopagenumbers
77 <xsl:template name="tex.math.plain.tail">
82 <xsl:template match="inlineequation" mode="collect.tex.math.plain">
83 <xsl:variable name="filename">
85 <xsl:when test="graphic">
86 <xsl:call-template name="mediaobject.filename">
87 <xsl:with-param name="object" select="graphic"/>
91 <xsl:call-template name="select.mediaobject.filename">
92 <xsl:with-param name="olist" select="inlinemediaobject/*"/>
97 <xsl:variable name="output.delims">
98 <xsl:call-template name="tex.math.output.delims"/>
100 <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
102 <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
103 <xsl:value-of select="$filename"/>
106 <xsl:if test="$output.delims != 0">
107 <xsl:text>$</xsl:text>
109 <xsl:value-of select="$tex"/>
110 <xsl:if test="$output.delims != 0">
114 <xsl:text>\vfill\eject
119 <xsl:template match="equation|informalequation" mode="collect.tex.math.plain">
120 <xsl:variable name="filename">
122 <xsl:when test="graphic">
123 <xsl:call-template name="mediaobject.filename">
124 <xsl:with-param name="object" select="graphic"/>
128 <xsl:call-template name="select.mediaobject.filename">
129 <xsl:with-param name="olist" select="mediaobject/*"/>
134 <xsl:variable name="output.delims">
135 <xsl:call-template name="tex.math.output.delims"/>
137 <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
139 <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
140 <xsl:value-of select="$filename"/>
143 <xsl:if test="$output.delims != 0">
144 <xsl:text>$$</xsl:text>
146 <xsl:value-of select="$tex"/>
147 <xsl:if test="$output.delims != 0">
151 <xsl:text>\vfill\eject
156 <xsl:template match="text()" mode="collect.tex.math.plain"/>
160 <xsl:template name="tex.math.latex.head">
161 <xsl:text>\documentclass{article}
163 <xsl:text>\pagestyle{empty}
165 <xsl:text>\begin{document}
169 <xsl:template name="tex.math.latex.tail">
170 <xsl:text>\end{document}
174 <xsl:template match="inlineequation" mode="collect.tex.math.latex">
175 <xsl:variable name="filename">
177 <xsl:when test="graphic">
178 <xsl:call-template name="mediaobject.filename">
179 <xsl:with-param name="object" select="graphic"/>
183 <xsl:call-template name="select.mediaobject.filename">
184 <xsl:with-param name="olist" select="inlinemediaobject/*"/>
189 <xsl:variable name="output.delims">
190 <xsl:call-template name="tex.math.output.delims"/>
192 <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
194 <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
195 <xsl:value-of select="$filename"/>
198 <xsl:if test="$output.delims != 0">
199 <xsl:text>$</xsl:text>
201 <xsl:value-of select="$tex"/>
202 <xsl:if test="$output.delims != 0">
211 <xsl:template match="equation|informalequation" mode="collect.tex.math.latex">
212 <xsl:variable name="filename">
214 <xsl:when test="graphic">
215 <xsl:call-template name="mediaobject.filename">
216 <xsl:with-param name="object" select="graphic"/>
220 <xsl:call-template name="select.mediaobject.filename">
221 <xsl:with-param name="olist" select="mediaobject/*"/>
226 <xsl:variable name="output.delims">
227 <xsl:call-template name="tex.math.output.delims"/>
229 <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
231 <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
232 <xsl:value-of select="$filename"/>
235 <xsl:if test="$output.delims != 0">
236 <xsl:text>$$</xsl:text>
238 <xsl:value-of select="$tex"/>
239 <xsl:if test="$output.delims != 0">
248 <xsl:template match="text()" mode="collect.tex.math.latex"/>
250 <!-- Extracting image filename from mediaobject and graphic elements -->
252 <xsl:template name="select.mediaobject.filename">
253 <xsl:param name="olist" select="imageobject|imageobjectco |videoobject|audioobject|textobject"/>
255 <xsl:variable name="mediaobject.index">
256 <xsl:call-template name="select.mediaobject.index">
257 <xsl:with-param name="olist" select="$olist"/>
258 <xsl:with-param name="count" select="1"/>
262 <xsl:if test="$mediaobject.index != ''">
263 <xsl:call-template name="mediaobject.filename">
264 <xsl:with-param name="object" select="$olist[position() = $mediaobject.index]"/>
269 <xsl:template name="tex.math.output.delims">
270 <xsl:variable name="pi.delims">
271 <xsl:call-template name="pi.dbtex_delims">
272 <xsl:with-param name="node" select="descendant-or-self::*"/>
275 <xsl:variable name="result">
277 <xsl:when test="$pi.delims = 'no'">0</xsl:when>
278 <xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
279 <xsl:otherwise>1</xsl:otherwise>
282 <xsl:value-of select="$result"/>