source: trunk/Distribution/XSL/xhtml/math.xsl@ 3

Last change on this file since 3 was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

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