2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
<!-- ********************************************************************
6
$Id: math.xsl,v 1.1.1.1 2004/06/22 02:10:10 f8dy Exp $
7
********************************************************************
9
This file is part of the XSL DocBook Stylesheet distribution.
10
See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11
and other information.
13
******************************************************************** -->
15
<xsl:template match="inlineequation">
16
<xsl:apply-templates/>
19
<xsl:template match="alt">
22
<!-- "Support" for MathML -->
24
<xsl:template match="mml:*" xmlns:mml="http://www.w3.org/1998/Math/MathML">
26
<xsl:copy-of select="@*"/>
27
<xsl:apply-templates/>
31
<!-- Support for TeX math in alt -->
33
<xsl:template match="*" mode="collect.tex.math">
34
<xsl:call-template name="write.text.chunk">
35
<xsl:with-param name="filename" select="$tex.math.file"/>
36
<xsl:with-param name="method" select="'text'"/>
37
<xsl:with-param name="content">
39
<xsl:when test="$tex.math.in.alt = 'plain'">
40
<xsl:call-template name="tex.math.plain.head"/>
41
<xsl:apply-templates select="." mode="collect.tex.math.plain"/>
42
<xsl:call-template name="tex.math.plain.tail"/>
44
<xsl:when test="$tex.math.in.alt = 'latex'">
45
<xsl:call-template name="tex.math.latex.head"/>
46
<xsl:apply-templates select="." mode="collect.tex.math.latex"/>
47
<xsl:call-template name="tex.math.latex.tail"/>
51
Unsupported TeX math notation:
52
<xsl:value-of select="$tex.math.in.alt"/>
57
<xsl:with-param name="encoding" select="$chunker.output.encoding"/>
63
<xsl:template name="tex.math.plain.head">
64
<xsl:text>\nopagenumbers 
</xsl:text>
67
<xsl:template name="tex.math.plain.tail">
68
<xsl:text>\bye 
</xsl:text>
71
<xsl:template match="inlineequation" mode="collect.tex.math.plain">
72
<xsl:variable name="filename">
74
<xsl:when test="graphic">
75
<xsl:call-template name="mediaobject.filename">
76
<xsl:with-param name="object" select="graphic"/>
80
<xsl:call-template name="select.mediaobject.filename">
81
<xsl:with-param name="olist" select="inlinemediaobject/*"/>
86
<xsl:variable name="output.delims">
87
<xsl:call-template name="tex.math.output.delims"/>
89
<xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
91
<xsl:text>\special{dvi2bitmap outputfile </xsl:text>
92
<xsl:value-of select="$filename"/>
93
<xsl:text>} 
</xsl:text>
94
<xsl:if test="$output.delims != 0">
95
<xsl:text>$</xsl:text>
97
<xsl:value-of select="$tex"/>
98
<xsl:if test="$output.delims != 0">
99
<xsl:text>$ 
</xsl:text>
101
<xsl:text>\vfill\eject 
</xsl:text>
105
<xsl:template match="equation|informalequation" mode="collect.tex.math.plain">
106
<xsl:variable name="filename">
108
<xsl:when test="graphic">
109
<xsl:call-template name="mediaobject.filename">
110
<xsl:with-param name="object" select="graphic"/>
114
<xsl:call-template name="select.mediaobject.filename">
115
<xsl:with-param name="olist" select="mediaobject/*"/>
120
<xsl:variable name="output.delims">
121
<xsl:call-template name="tex.math.output.delims"/>
123
<xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
125
<xsl:text>\special{dvi2bitmap outputfile </xsl:text>
126
<xsl:value-of select="$filename"/>
127
<xsl:text>} 
</xsl:text>
128
<xsl:if test="$output.delims != 0">
129
<xsl:text>$$</xsl:text>
131
<xsl:value-of select="$tex"/>
132
<xsl:if test="$output.delims != 0">
133
<xsl:text>$$ 
</xsl:text>
135
<xsl:text>\vfill\eject 
</xsl:text>
139
<xsl:template match="text()" mode="collect.tex.math.plain"/>
143
<xsl:template name="tex.math.latex.head">
144
<xsl:text>\documentclass{article} 
</xsl:text>
145
<xsl:text>\pagestyle{empty} 
</xsl:text>
146
<xsl:text>\begin{document} 
</xsl:text>
149
<xsl:template name="tex.math.latex.tail">
150
<xsl:text>\end{document} 
</xsl:text>
153
<xsl:template match="inlineequation" mode="collect.tex.math.latex">
154
<xsl:variable name="filename">
156
<xsl:when test="graphic">
157
<xsl:call-template name="mediaobject.filename">
158
<xsl:with-param name="object" select="graphic"/>
162
<xsl:call-template name="select.mediaobject.filename">
163
<xsl:with-param name="olist" select="inlinemediaobject/*"/>
168
<xsl:variable name="output.delims">
169
<xsl:call-template name="tex.math.output.delims"/>
171
<xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
173
<xsl:text>\special{dvi2bitmap outputfile </xsl:text>
174
<xsl:value-of select="$filename"/>
175
<xsl:text>} 
</xsl:text>
176
<xsl:if test="$output.delims != 0">
177
<xsl:text>$</xsl:text>
179
<xsl:value-of select="$tex"/>
180
<xsl:if test="$output.delims != 0">
181
<xsl:text>$ 
</xsl:text>
183
<xsl:text>\newpage 
</xsl:text>
187
<xsl:template match="equation|informalequation" mode="collect.tex.math.latex">
188
<xsl:variable name="filename">
190
<xsl:when test="graphic">
191
<xsl:call-template name="mediaobject.filename">
192
<xsl:with-param name="object" select="graphic"/>
196
<xsl:call-template name="select.mediaobject.filename">
197
<xsl:with-param name="olist" select="mediaobject/*"/>
202
<xsl:variable name="output.delims">
203
<xsl:call-template name="tex.math.output.delims"/>
205
<xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
207
<xsl:text>\special{dvi2bitmap outputfile </xsl:text>
208
<xsl:value-of select="$filename"/>
209
<xsl:text>} 
</xsl:text>
210
<xsl:if test="$output.delims != 0">
211
<xsl:text>$$</xsl:text>
213
<xsl:value-of select="$tex"/>
214
<xsl:if test="$output.delims != 0">
215
<xsl:text>$$ 
</xsl:text>
217
<xsl:text>\newpage 
</xsl:text>
221
<xsl:template match="text()" mode="collect.tex.math.latex"/>
223
<!-- Extracting image filename from mediaobject and graphic elements -->
225
<xsl:template name="select.mediaobject.filename">
226
<xsl:param name="olist"
227
select="imageobject|imageobjectco
228
|videoobject|audioobject|textobject"/>
230
<xsl:variable name="mediaobject.index">
231
<xsl:call-template name="select.mediaobject.index">
232
<xsl:with-param name="olist" select="$olist"/>
233
<xsl:with-param name="count" select="1"/>
237
<xsl:if test="$mediaobject.index != ''">
238
<xsl:call-template name="mediaobject.filename">
239
<xsl:with-param name="object"
240
select="$olist[position() = $mediaobject.index]"/>
245
<xsl:template name="tex.math.output.delims">
246
<xsl:variable name="pi.delims">
247
<xsl:call-template name="pi-attribute">
248
<xsl:with-param name="pis" select=".//processing-instruction('dbtex')"/>
249
<xsl:with-param name="attribute" select="'delims'"/>
252
<xsl:variable name="result">
254
<xsl:when test="$pi.delims = 'no'">0</xsl:when>
255
<xsl:when test="$pi.delims = '' and $tex.math.delims = 0">0</xsl:when>
256
<xsl:otherwise>1</xsl:otherwise>
259
<xsl:value-of select="$result"/>