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">
|
---|
5 |
|
---|
6 | <!-- ********************************************************************
|
---|
7 | $Id: math.xsl 9297 2012-04-22 03:56:16Z bobstayton $
|
---|
8 | ********************************************************************
|
---|
9 |
|
---|
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.
|
---|
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 | <xsl:template match="mathphrase">
|
---|
24 | <span>
|
---|
25 | <xsl:apply-templates select="." mode="common.html.attributes"/>
|
---|
26 | <xsl:call-template name="id.attribute"/>
|
---|
27 | <xsl:apply-templates/>
|
---|
28 | </span>
|
---|
29 | </xsl:template>
|
---|
30 |
|
---|
31 | <!-- "Support" for MathML -->
|
---|
32 |
|
---|
33 | <xsl:template match="mml:*">
|
---|
34 | <xsl:copy>
|
---|
35 | <xsl:copy-of select="@*"/>
|
---|
36 | <xsl:apply-templates/>
|
---|
37 | </xsl:copy>
|
---|
38 | </xsl:template>
|
---|
39 |
|
---|
40 | <!-- Support for TeX math in alt -->
|
---|
41 |
|
---|
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">
|
---|
47 | <xsl:choose>
|
---|
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"/>
|
---|
52 | </xsl:when>
|
---|
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"/>
|
---|
57 | </xsl:when>
|
---|
58 | <xsl:otherwise>
|
---|
59 | <xsl:message>
|
---|
60 | Unsupported TeX math notation:
|
---|
61 | <xsl:value-of select="$tex.math.in.alt"/>
|
---|
62 | </xsl:message>
|
---|
63 | </xsl:otherwise>
|
---|
64 | </xsl:choose>
|
---|
65 | </xsl:with-param>
|
---|
66 | <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
|
---|
67 | </xsl:call-template>
|
---|
68 | </xsl:template>
|
---|
69 |
|
---|
70 | <!-- PlainTeX -->
|
---|
71 |
|
---|
72 | <xsl:template name="tex.math.plain.head">
|
---|
73 | <xsl:text>\nopagenumbers
|
---|
74 | </xsl:text>
|
---|
75 | </xsl:template>
|
---|
76 |
|
---|
77 | <xsl:template name="tex.math.plain.tail">
|
---|
78 | <xsl:text>\bye
|
---|
79 | </xsl:text>
|
---|
80 | </xsl:template>
|
---|
81 |
|
---|
82 | <xsl:template match="inlineequation" mode="collect.tex.math.plain">
|
---|
83 | <xsl:variable name="filename">
|
---|
84 | <xsl:choose>
|
---|
85 | <xsl:when test="graphic">
|
---|
86 | <xsl:call-template name="mediaobject.filename">
|
---|
87 | <xsl:with-param name="object" select="graphic"/>
|
---|
88 | </xsl:call-template>
|
---|
89 | </xsl:when>
|
---|
90 | <xsl:otherwise>
|
---|
91 | <xsl:call-template name="select.mediaobject.filename">
|
---|
92 | <xsl:with-param name="olist" select="inlinemediaobject/*"/>
|
---|
93 | </xsl:call-template>
|
---|
94 | </xsl:otherwise>
|
---|
95 | </xsl:choose>
|
---|
96 | </xsl:variable>
|
---|
97 | <xsl:variable name="output.delims">
|
---|
98 | <xsl:call-template name="tex.math.output.delims"/>
|
---|
99 | </xsl:variable>
|
---|
100 | <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
|
---|
101 | <xsl:if test="$tex">
|
---|
102 | <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
|
---|
103 | <xsl:value-of select="$filename"/>
|
---|
104 | <xsl:text>}
|
---|
105 | </xsl:text>
|
---|
106 | <xsl:if test="$output.delims != 0">
|
---|
107 | <xsl:text>$</xsl:text>
|
---|
108 | </xsl:if>
|
---|
109 | <xsl:value-of select="$tex"/>
|
---|
110 | <xsl:if test="$output.delims != 0">
|
---|
111 | <xsl:text>$
|
---|
112 | </xsl:text>
|
---|
113 | </xsl:if>
|
---|
114 | <xsl:text>\vfill\eject
|
---|
115 | </xsl:text>
|
---|
116 | </xsl:if>
|
---|
117 | </xsl:template>
|
---|
118 |
|
---|
119 | <xsl:template match="equation|informalequation" mode="collect.tex.math.plain">
|
---|
120 | <xsl:variable name="filename">
|
---|
121 | <xsl:choose>
|
---|
122 | <xsl:when test="graphic">
|
---|
123 | <xsl:call-template name="mediaobject.filename">
|
---|
124 | <xsl:with-param name="object" select="graphic"/>
|
---|
125 | </xsl:call-template>
|
---|
126 | </xsl:when>
|
---|
127 | <xsl:otherwise>
|
---|
128 | <xsl:call-template name="select.mediaobject.filename">
|
---|
129 | <xsl:with-param name="olist" select="mediaobject/*"/>
|
---|
130 | </xsl:call-template>
|
---|
131 | </xsl:otherwise>
|
---|
132 | </xsl:choose>
|
---|
133 | </xsl:variable>
|
---|
134 | <xsl:variable name="output.delims">
|
---|
135 | <xsl:call-template name="tex.math.output.delims"/>
|
---|
136 | </xsl:variable>
|
---|
137 | <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
|
---|
138 | <xsl:if test="$tex">
|
---|
139 | <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
|
---|
140 | <xsl:value-of select="$filename"/>
|
---|
141 | <xsl:text>}
|
---|
142 | </xsl:text>
|
---|
143 | <xsl:if test="$output.delims != 0">
|
---|
144 | <xsl:text>$$</xsl:text>
|
---|
145 | </xsl:if>
|
---|
146 | <xsl:value-of select="$tex"/>
|
---|
147 | <xsl:if test="$output.delims != 0">
|
---|
148 | <xsl:text>$$
|
---|
149 | </xsl:text>
|
---|
150 | </xsl:if>
|
---|
151 | <xsl:text>\vfill\eject
|
---|
152 | </xsl:text>
|
---|
153 | </xsl:if>
|
---|
154 | </xsl:template>
|
---|
155 |
|
---|
156 | <xsl:template match="text()" mode="collect.tex.math.plain"/>
|
---|
157 |
|
---|
158 | <!-- LaTeX -->
|
---|
159 |
|
---|
160 | <xsl:template name="tex.math.latex.head">
|
---|
161 | <xsl:text>\documentclass{article}
|
---|
162 | </xsl:text>
|
---|
163 | <xsl:text>\pagestyle{empty}
|
---|
164 | </xsl:text>
|
---|
165 | <xsl:text>\begin{document}
|
---|
166 | </xsl:text>
|
---|
167 | </xsl:template>
|
---|
168 |
|
---|
169 | <xsl:template name="tex.math.latex.tail">
|
---|
170 | <xsl:text>\end{document}
|
---|
171 | </xsl:text>
|
---|
172 | </xsl:template>
|
---|
173 |
|
---|
174 | <xsl:template match="inlineequation" mode="collect.tex.math.latex">
|
---|
175 | <xsl:variable name="filename">
|
---|
176 | <xsl:choose>
|
---|
177 | <xsl:when test="graphic">
|
---|
178 | <xsl:call-template name="mediaobject.filename">
|
---|
179 | <xsl:with-param name="object" select="graphic"/>
|
---|
180 | </xsl:call-template>
|
---|
181 | </xsl:when>
|
---|
182 | <xsl:otherwise>
|
---|
183 | <xsl:call-template name="select.mediaobject.filename">
|
---|
184 | <xsl:with-param name="olist" select="inlinemediaobject/*"/>
|
---|
185 | </xsl:call-template>
|
---|
186 | </xsl:otherwise>
|
---|
187 | </xsl:choose>
|
---|
188 | </xsl:variable>
|
---|
189 | <xsl:variable name="output.delims">
|
---|
190 | <xsl:call-template name="tex.math.output.delims"/>
|
---|
191 | </xsl:variable>
|
---|
192 | <xsl:variable name="tex" select="alt[@role='tex'] | inlinemediaobject/textobject[@role='tex']"/>
|
---|
193 | <xsl:if test="$tex">
|
---|
194 | <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
|
---|
195 | <xsl:value-of select="$filename"/>
|
---|
196 | <xsl:text>}
|
---|
197 | </xsl:text>
|
---|
198 | <xsl:if test="$output.delims != 0">
|
---|
199 | <xsl:text>$</xsl:text>
|
---|
200 | </xsl:if>
|
---|
201 | <xsl:value-of select="$tex"/>
|
---|
202 | <xsl:if test="$output.delims != 0">
|
---|
203 | <xsl:text>$
|
---|
204 | </xsl:text>
|
---|
205 | </xsl:if>
|
---|
206 | <xsl:text>\newpage
|
---|
207 | </xsl:text>
|
---|
208 | </xsl:if>
|
---|
209 | </xsl:template>
|
---|
210 |
|
---|
211 | <xsl:template match="equation|informalequation" mode="collect.tex.math.latex">
|
---|
212 | <xsl:variable name="filename">
|
---|
213 | <xsl:choose>
|
---|
214 | <xsl:when test="graphic">
|
---|
215 | <xsl:call-template name="mediaobject.filename">
|
---|
216 | <xsl:with-param name="object" select="graphic"/>
|
---|
217 | </xsl:call-template>
|
---|
218 | </xsl:when>
|
---|
219 | <xsl:otherwise>
|
---|
220 | <xsl:call-template name="select.mediaobject.filename">
|
---|
221 | <xsl:with-param name="olist" select="mediaobject/*"/>
|
---|
222 | </xsl:call-template>
|
---|
223 | </xsl:otherwise>
|
---|
224 | </xsl:choose>
|
---|
225 | </xsl:variable>
|
---|
226 | <xsl:variable name="output.delims">
|
---|
227 | <xsl:call-template name="tex.math.output.delims"/>
|
---|
228 | </xsl:variable>
|
---|
229 | <xsl:variable name="tex" select="alt[@role='tex'] | mediaobject/textobject[@role='tex']"/>
|
---|
230 | <xsl:if test="$tex">
|
---|
231 | <xsl:text>\special{dvi2bitmap outputfile </xsl:text>
|
---|
232 | <xsl:value-of select="$filename"/>
|
---|
233 | <xsl:text>}
|
---|
234 | </xsl:text>
|
---|
235 | <xsl:if test="$output.delims != 0">
|
---|
236 | <xsl:text>$$</xsl:text>
|
---|
237 | </xsl:if>
|
---|
238 | <xsl:value-of select="$tex"/>
|
---|
239 | <xsl:if test="$output.delims != 0">
|
---|
240 | <xsl:text>$$
|
---|
241 | </xsl:text>
|
---|
242 | </xsl:if>
|
---|
243 | <xsl:text>\newpage
|
---|
244 | </xsl:text>
|
---|
245 | </xsl:if>
|
---|
246 | </xsl:template>
|
---|
247 |
|
---|
248 | <xsl:template match="text()" mode="collect.tex.math.latex"/>
|
---|
249 |
|
---|
250 | <!-- Extracting image filename from mediaobject and graphic elements -->
|
---|
251 |
|
---|
252 | <xsl:template name="select.mediaobject.filename">
|
---|
253 | <xsl:param name="olist" select="imageobject|imageobjectco |videoobject|audioobject|textobject"/>
|
---|
254 |
|
---|
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"/>
|
---|
259 | </xsl:call-template>
|
---|
260 | </xsl:variable>
|
---|
261 |
|
---|
262 | <xsl:if test="$mediaobject.index != ''">
|
---|
263 | <xsl:call-template name="mediaobject.filename">
|
---|
264 | <xsl:with-param name="object" select="$olist[position() = $mediaobject.index]"/>
|
---|
265 | </xsl:call-template>
|
---|
266 | </xsl:if>
|
---|
267 | </xsl:template>
|
---|
268 |
|
---|
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::*"/>
|
---|
273 | </xsl:call-template>
|
---|
274 | </xsl:variable>
|
---|
275 | <xsl:variable name="result">
|
---|
276 | <xsl:choose>
|
---|
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>
|
---|
280 | </xsl:choose>
|
---|
281 | </xsl:variable>
|
---|
282 | <xsl:value-of select="$result"/>
|
---|
283 | </xsl:template>
|
---|
284 |
|
---|
285 | </xsl:stylesheet>
|
---|