1 <?xml version='1.0' encoding="UTF-8"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:m="http://www.w3.org/1998/Math/MathML"
6 <!-- ====================================================================== -->
7 <!-- $Id: scripts.xsl,v 1.1.1.1 2002/10/26 14:20:06 shade33 Exp $
8 This file is part of the XSLT MathML Library distribution.
9 See ./README or http://www.raleigh.ru/MathML/mmltex for
10 copyright and other information -->
11 <!-- ====================================================================== -->
13 <xsl:template match="m:munderover">
14 <xsl:variable name="base">
15 <xsl:call-template name="startspace">
16 <xsl:with-param name="symbol" select="./*[1]"/>
19 <xsl:variable name="under">
20 <xsl:call-template name="startspace">
21 <xsl:with-param name="symbol" select="./*[2]"/>
24 <xsl:variable name="over">
25 <xsl:call-template name="startspace">
26 <xsl:with-param name="symbol" select="./*[3]"/>
31 <xsl:when test="$over='¯'"> <!-- OverBar - over bar -->
32 <xsl:text>\overline{</xsl:text>
33 <xsl:call-template name="munder">
34 <xsl:with-param name="base" select="$base"/>
35 <xsl:with-param name="under" select="$under"/>
37 <xsl:text>}</xsl:text>
39 <xsl:when test="$over='︷'"> <!-- OverBrace - over brace -->
40 <xsl:text>\overbrace{</xsl:text>
41 <xsl:call-template name="munder">
42 <xsl:with-param name="base" select="$base"/>
43 <xsl:with-param name="under" select="$under"/>
45 <xsl:text>}</xsl:text>
47 <xsl:when test="$under='̲'"> <!-- UnderBar - combining low line -->
48 <xsl:text>\underline{</xsl:text>
49 <xsl:call-template name="mover">
50 <xsl:with-param name="base" select="$base"/>
51 <xsl:with-param name="over" select="$over"/>
52 <xsl:with-param name="pos_over" select="3"/>
54 <xsl:text>}</xsl:text>
56 <xsl:when test="$under='︸'"> <!-- UnderBrace - under brace -->
57 <xsl:text>\underbrace{</xsl:text>
58 <xsl:call-template name="mover">
59 <xsl:with-param name="base" select="$base"/>
60 <xsl:with-param name="over" select="$over"/>
61 <xsl:with-param name="pos_over" select="3"/>
63 <xsl:text>}</xsl:text>
65 <xsl:when test="translate($base,'∏∐⋂⋃⊔',
66 '∑∑∑∑∑')='∑'">
67 <!-- if $base is operator, such as
68 ∑ /sum L: summation operator
69 ∏ /prod L: product operator
70 ∐ /coprod L: coproduct operator
75 <xsl:apply-templates select="./*[1]"/>
76 <xsl:text>_{</xsl:text>
77 <xsl:apply-templates select="./*[2]"/>
78 <xsl:text>}^{</xsl:text>
79 <xsl:apply-templates select="./*[3]"/>
80 <xsl:text>}</xsl:text>
83 <xsl:text>\underset{</xsl:text>
84 <xsl:apply-templates select="./*[2]"/>
85 <xsl:text>}{\overset{</xsl:text>
86 <xsl:apply-templates select="./*[3]"/>
87 <xsl:text>}{</xsl:text>
88 <xsl:apply-templates select="./*[1]"/>
89 <xsl:text>}}</xsl:text>
94 <xsl:template match="m:mover">
95 <xsl:call-template name="mover">
96 <xsl:with-param name="base">
97 <xsl:call-template name="startspace">
98 <xsl:with-param name="symbol" select="./*[1]"/>
101 <xsl:with-param name="over">
102 <xsl:call-template name="startspace">
103 <xsl:with-param name="symbol" select="./*[2]"/>
109 <xsl:template match="m:munder">
110 <xsl:call-template name="munder">
111 <xsl:with-param name="base">
112 <xsl:call-template name="startspace">
113 <xsl:with-param name="symbol" select="./*[1]"/>
116 <xsl:with-param name="under">
117 <xsl:call-template name="startspace">
118 <xsl:with-param name="symbol" select="./*[2]"/>
124 <xsl:template name="mover">
125 <xsl:param name="base"/>
126 <xsl:param name="over"/>
127 <xsl:param name="pos_over" select="2"/>
129 <xsl:when test="$over='¯'"> <!-- OverBar - over bar -->
130 <xsl:text>\overline{</xsl:text>
131 <xsl:apply-templates select="./*[1]"/>
132 <xsl:text>}</xsl:text>
134 <xsl:when test="$over='︷'"> <!-- OverBrace - over brace -->
135 <xsl:text>\overbrace{</xsl:text>
136 <xsl:apply-templates select="./*[1]"/>
137 <xsl:text>}</xsl:text>
139 <xsl:when test="translate($base,'∏∐⋂⋃⊔',
140 '∑∑∑∑∑')='∑'">
141 <!-- if $base is operator, such as
142 ∑ /sum L: summation operator
143 ∏ /prod L: product operator
144 ∐ /coprod L: coproduct operator
149 <xsl:apply-templates select="./*[1]"/>
150 <xsl:text>^{</xsl:text>
151 <xsl:apply-templates select="./*[$pos_over]"/>
152 <xsl:text>}</xsl:text>
155 <xsl:text>\stackrel{</xsl:text>
156 <xsl:apply-templates select="./*[$pos_over]"/>
157 <xsl:text>}{</xsl:text>
158 <xsl:apply-templates select="./*[1]"/>
159 <xsl:text>}</xsl:text>
161 <xsl:text>\overset{</xsl:text>
162 <xsl:apply-templates select="./*[$pos_over]"/>
163 <xsl:text>}{</xsl:text>
164 <xsl:apply-templates select="./*[1]"/>
165 <xsl:text>}</xsl:text>-->
170 <xsl:template name="munder">
171 <xsl:param name="base"/>
172 <xsl:param name="under"/>
174 <xsl:when test="$under='̲'"> <!-- UnderBar - combining low line -->
175 <xsl:text>\underline{</xsl:text>
176 <xsl:apply-templates select="./*[1]"/>
177 <xsl:text>}</xsl:text>
179 <xsl:when test="$under='︸'"> <!-- UnderBrace - under brace -->
180 <xsl:text>\underbrace{</xsl:text>
181 <xsl:apply-templates select="./*[1]"/>
182 <xsl:text>}</xsl:text>
184 <xsl:when test="translate($base,'∏∐⋂⋃⊔',
185 '∑∑∑∑∑')='∑'">
186 <!-- if $base is operator, such as
187 ∑ /sum L: summation operator
188 ∏ /prod L: product operator
189 ∐ /coprod L: coproduct operator
194 <xsl:apply-templates select="./*[1]"/>
195 <xsl:text>_{</xsl:text>
196 <xsl:apply-templates select="./*[2]"/>
197 <xsl:text>}</xsl:text>
200 <xsl:text>\underset{</xsl:text> <!-- Required AmsMath package -->
201 <xsl:apply-templates select="./*[2]"/>
202 <xsl:text>}{</xsl:text>
203 <xsl:apply-templates select="./*[1]"/>
204 <xsl:text>}</xsl:text>
209 <xsl:template match="m:msubsup">
210 <xsl:text>{</xsl:text>
211 <xsl:apply-templates select="./*[1]"/>
212 <xsl:text>}_{</xsl:text>
213 <xsl:apply-templates select="./*[2]"/>
214 <xsl:text>}^{</xsl:text>
215 <xsl:apply-templates select="./*[3]"/>
216 <xsl:text>}</xsl:text>
219 <xsl:template match="m:msup">
220 <xsl:text>{</xsl:text>
221 <xsl:apply-templates select="./*[1]"/>
222 <xsl:text>}^{</xsl:text>
223 <xsl:apply-templates select="./*[2]"/>
224 <xsl:text>}</xsl:text>
227 <xsl:template match="m:msub">
228 <xsl:text>{</xsl:text>
229 <xsl:apply-templates select="./*[1]"/>
230 <xsl:text>}_{</xsl:text>
231 <xsl:apply-templates select="./*[2]"/>
232 <xsl:text>}</xsl:text>
235 <xsl:template match="m:mmultiscripts" mode="mprescripts">
236 <xsl:for-each select="m:mprescripts/following-sibling::*">
237 <xsl:if test="position() mod 2 and local-name(.)!='none'">
238 <xsl:text>{}_{</xsl:text>
239 <xsl:apply-templates select="."/>
240 <xsl:text>}</xsl:text>
242 <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
243 <xsl:text>{}^{</xsl:text>
244 <xsl:apply-templates select="."/>
245 <xsl:text>}</xsl:text>
248 <xsl:apply-templates select="./*[1]"/>
249 <xsl:for-each select="m:mprescripts/preceding-sibling::*[position()!=last()]">
250 <xsl:if test="position()>2 and local-name(.)!='none'">
251 <xsl:text>{}</xsl:text>
253 <xsl:if test="position() mod 2 and local-name(.)!='none'">
254 <xsl:text>_{</xsl:text>
255 <xsl:apply-templates select="."/>
256 <xsl:text>}</xsl:text>
258 <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
259 <xsl:text>^{</xsl:text>
260 <xsl:apply-templates select="."/>
261 <xsl:text>}</xsl:text>
266 <xsl:template match="m:mmultiscripts">
268 <xsl:when test="m:mprescripts">
269 <xsl:apply-templates select="." mode="mprescripts"/>
272 <xsl:apply-templates select="./*[1]"/>
273 <xsl:for-each select="*[position()>1]">
274 <xsl:if test="position()>2 and local-name(.)!='none'">
275 <xsl:text>{}</xsl:text>
277 <xsl:if test="position() mod 2 and local-name(.)!='none'">
278 <xsl:text>_{</xsl:text>
279 <xsl:apply-templates select="."/>
280 <xsl:text>}</xsl:text>
282 <xsl:if test="not(position() mod 2) and local-name(.)!='none'">
283 <xsl:text>^{</xsl:text>
284 <xsl:apply-templates select="."/>
285 <xsl:text>}</xsl:text>