Commit | Line | Data |
---|---|---|
7faf1d71 AW |
1 | <!-- saved from url=(0013)about:internet --> |
2 | <xsl:stylesheet | |
3 | version="1.0" | |
4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
5 | xmlns:mml="http://www.w3.org/1998/Math/MathML" | |
6 | > | |
7 | ||
8 | <!-- | |
9 | $Id: ctop.xsl,v 1.3 2002/09/20 08:41:39 davidc Exp $ | |
10 | ||
11 | Copyright David Carlisle 2001, 2002. | |
12 | ||
13 | Use and distribution of this code are permitted under the terms of the <a | |
14 | href="http://www.w3.org/Consortium/Legal/copyright-software-19980720" | |
15 | >W3C Software Notice and License</a>. | |
16 | --> | |
17 | ||
18 | <xsl:output method="xml" /> | |
19 | ||
20 | <xsl:template mode="c2p" match="*"> | |
21 | <xsl:copy> | |
22 | <xsl:copy-of select="@*"/> | |
23 | <xsl:apply-templates mode="c2p"/> | |
24 | </xsl:copy> | |
25 | </xsl:template> | |
26 | ||
27 | ||
28 | <!-- 4.4.1.1 cn --> | |
29 | ||
30 | <xsl:template mode="c2p" match="mml:cn"> | |
31 | <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn> | |
32 | </xsl:template> | |
33 | ||
34 | <xsl:template mode="c2p" match="mml:cn[@type='complex-cartesian']"> | |
35 | <mml:mrow> | |
36 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn> | |
37 | <mml:mo>+</mml:mo> | |
38 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn> | |
39 | <mml:mo><!--⁢--><!--invisible times--></mml:mo> | |
40 | <mml:mi>i<!-- imaginary i --></mml:mi> | |
41 | </mml:mrow> | |
42 | </xsl:template> | |
43 | ||
44 | <xsl:template mode="c2p" match="mml:cn[@type='rational']"> | |
45 | <mml:mrow> | |
46 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn> | |
47 | <mml:mo>/</mml:mo> | |
48 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn> | |
49 | </mml:mrow> | |
50 | </xsl:template> | |
51 | ||
52 | <xsl:template mode="c2p" match="mml:cn[@type='integer']"> | |
53 | <xsl:choose> | |
54 | <xsl:when test="not(@base) or @base=10"> | |
55 | <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn> | |
56 | </xsl:when> | |
57 | <xsl:otherwise> | |
58 | <mml:msub> | |
59 | <mml:mn><xsl:apply-templates mode="c2p"/></mml:mn> | |
60 | <mml:mn><xsl:value-of select="@base"/></mml:mn> | |
61 | </mml:msub> | |
62 | </xsl:otherwise> | |
63 | </xsl:choose> | |
64 | </xsl:template> | |
65 | ||
66 | <xsl:template mode="c2p" match="mml:cn[@type='complex-polar']"> | |
67 | <mml:mrow> | |
68 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/></mml:mn> | |
69 | <mml:mo><!--⁢--><!--invisible times--></mml:mo> | |
70 | <mml:msup> | |
71 | <mml:mi>e<!-- exponential e--></mml:mi> | |
72 | <mml:mrow> | |
73 | <mml:mi>i<!-- imaginary i--></mml:mi> | |
74 | <mml:mo><!--⁢--><!--invisible times--></mml:mo> | |
75 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn> | |
76 | </mml:mrow> | |
77 | </mml:msup> | |
78 | </mml:mrow> | |
79 | </xsl:template> | |
80 | ||
81 | <xsl:template mode="c2p" match="mml:cn[@type='e-notation']"> | |
82 | <mml:mn><xsl:apply-templates mode="c2p" select="text()[1]"/>E<xsl:apply-templates mode="c2p" select="text()[2]"/></mml:mn> | |
83 | </xsl:template> | |
84 | ||
85 | <!-- 4.4.1.1 ci --> | |
86 | ||
87 | <xsl:template mode="c2p" match="mml:ci/text()"> | |
88 | <mml:mi><xsl:value-of select="."/></mml:mi> | |
89 | </xsl:template> | |
90 | ||
91 | <xsl:template mode="c2p" match="mml:ci"> | |
92 | <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow> | |
93 | </xsl:template> | |
94 | ||
95 | <!-- 4.4.1.2 csymbol --> | |
96 | ||
97 | <xsl:template mode="c2p" match="mml:csymbol/text()"> | |
98 | <mml:mo><xsl:apply-templates mode="c2p"/></mml:mo> | |
99 | </xsl:template> | |
100 | ||
101 | <xsl:template mode="c2p" match="mml:csymbol"> | |
102 | <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow> | |
103 | </xsl:template> | |
104 | ||
105 | <!-- 4.4.2.1 apply 4.4.2.2 reln --> | |
106 | ||
107 | <xsl:template mode="c2p" match="mml:apply|mml:reln"> | |
108 | <mml:mrow> | |
109 | <xsl:apply-templates mode="c2p" select="*[1]"> | |
110 | <xsl:with-param name="p" select="10"/> | |
111 | </xsl:apply-templates> | |
112 | <mml:mo><!--⁢--><!--invisible times--></mml:mo> | |
113 | <mml:mfenced open="(" close=")" separators=","> | |
114 | <xsl:apply-templates mode="c2p" select="*[position()>1]"/> | |
115 | </mml:mfenced> | |
116 | </mml:mrow> | |
117 | </xsl:template> | |
118 | ||
119 | <!-- 4.4.2.3 fn --> | |
120 | <xsl:template mode="c2p" match="mml:fn"> | |
121 | <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow> | |
122 | </xsl:template> | |
123 | ||
124 | <!-- 4.4.2.4 interval --> | |
125 | <xsl:template mode="c2p" match="mml:interval[*[2]]"> | |
126 | <mml:mfenced open="[" close="]"><xsl:apply-templates mode="c2p"/></mml:mfenced> | |
127 | </xsl:template> | |
128 | <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='open']"> | |
129 | <mml:mfenced open="(" close=")"><xsl:apply-templates mode="c2p"/></mml:mfenced> | |
130 | </xsl:template> | |
131 | <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='open-closed']"> | |
132 | <mml:mfenced open="(" close="]"><xsl:apply-templates mode="c2p"/></mml:mfenced> | |
133 | </xsl:template> | |
134 | <xsl:template mode="c2p" match="mml:interval[*[2]][@closure='closed-open']"> | |
135 | <mml:mfenced open="[" close=")"><xsl:apply-templates mode="c2p"/></mml:mfenced> | |
136 | </xsl:template> | |
137 | ||
138 | <xsl:template mode="c2p" match="mml:interval"> | |
139 | <mml:mfenced open="{{" close="}}"><xsl:apply-templates mode="c2p"/></mml:mfenced> | |
140 | </xsl:template> | |
141 | ||
142 | <!-- 4.4.2.5 inverse --> | |
143 | ||
144 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:inverse]]"> | |
145 | <mml:msup> | |
146 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
147 | <mml:mrow><mml:mo>(</mml:mo><mml:mn>-1</mml:mn><mml:mo>)</mml:mo></mml:mrow> | |
148 | </mml:msup> | |
149 | </xsl:template> | |
150 | ||
151 | <!-- 4.4.2.6 sep --> | |
152 | ||
153 | <!-- 4.4.2.7 condition --> | |
154 | <xsl:template mode="c2p" match="mml:condition"> | |
155 | <mml:mrow><xsl:apply-templates mode="c2p"/></mml:mrow> | |
156 | </xsl:template> | |
157 | ||
158 | <!-- 4.4.2.8 declare --> | |
159 | <xsl:template mode="c2p" match="mml:declare"/> | |
160 | ||
161 | <!-- 4.4.2.9 lambda --> | |
162 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:lambda]]"> | |
163 | <mml:mrow> | |
164 | <mml:mi>λ<!--lambda--></mml:mi> | |
165 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar/*"/></mml:mrow> | |
166 | <mml:mo>.</mml:mo> | |
167 | <mml:mfenced> | |
168 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
169 | </mml:mfenced> | |
170 | </mml:mrow> | |
171 | </xsl:template> | |
172 | ||
173 | ||
174 | <!-- 4.4.2.10 compose --> | |
175 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:compose]]"> | |
176 | <xsl:param name="p" select="0"/> | |
177 | <xsl:call-template name="infix"> | |
178 | <xsl:with-param name="this-p" select="1"/> | |
179 | <xsl:with-param name="p" select="$p"/> | |
180 | <xsl:with-param name="mo"><mml:mo>∘<!-- o --></mml:mo></xsl:with-param> | |
181 | </xsl:call-template> | |
182 | </xsl:template> | |
183 | ||
184 | ||
185 | <!-- 4.4.2.11` ident --> | |
186 | <xsl:template mode="c2p" match="mml:ident"> | |
187 | <mml:mo>id</mml:mo> | |
188 | </xsl:template> | |
189 | ||
190 | <!-- 4.4.2.12` domain --> | |
191 | <xsl:template mode="c2p" match="mml:domain"> | |
192 | <mml:mo>domain</mml:mo> | |
193 | </xsl:template> | |
194 | ||
195 | <!-- 4.4.2.13` codomain --> | |
196 | <xsl:template mode="c2p" match="mml:codomain"> | |
197 | <mml:mo>codomain</mml:mo> | |
198 | </xsl:template> | |
199 | ||
200 | <!-- 4.4.2.14` image --> | |
201 | <xsl:template mode="c2p" match="mml:image"> | |
202 | <mml:mo>image</mml:mo> | |
203 | </xsl:template> | |
204 | ||
205 | <!-- 4.4.2.15` domainofapplication --> | |
206 | <xsl:template mode="c2p" match="mml:domainofapplication"> | |
207 | <mml:error/> | |
208 | </xsl:template> | |
209 | ||
210 | <!-- 4.4.2.16` piecewise --> | |
211 | <xsl:template mode="c2p" match="mml:piecewise"> | |
212 | <mml:mrow> | |
213 | <mml:mo>{</mml:mo> | |
214 | <mml:mtable> | |
215 | <xsl:for-each select="mml:piece|mml:otherwise"> | |
216 | <mml:mtr> | |
217 | <mml:mtd><xsl:apply-templates mode="c2p" select="*[1]"/></mml:mtd> | |
218 | <mml:mtd><mml:mtext>  if  </mml:mtext></mml:mtd> | |
219 | <mml:mtd><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mtd> | |
220 | </mml:mtr> | |
221 | </xsl:for-each> | |
222 | </mml:mtable> | |
223 | </mml:mrow> | |
224 | </xsl:template> | |
225 | ||
226 | ||
227 | <!-- 4.4.3.1 quotient --> | |
228 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:quotient]]"> | |
229 | <mml:mrow> | |
230 | <mml:mo>⌊<!-- lfloor--></mml:mo> | |
231 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
232 | <mml:mo>/</mml:mo> | |
233 | <xsl:apply-templates mode="c2p" select="*[3]"/> | |
234 | <mml:mo>⌋<!-- rfloor--></mml:mo> | |
235 | </mml:mrow> | |
236 | </xsl:template> | |
237 | ||
238 | ||
239 | ||
240 | <!-- 4.4.3.2 factorial --> | |
241 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:factorial]]"> | |
242 | <mml:mrow> | |
243 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
244 | <xsl:with-param name="p" select="7"/> | |
245 | </xsl:apply-templates> | |
246 | <mml:mo>!</mml:mo> | |
247 | </mml:mrow> | |
248 | </xsl:template> | |
249 | ||
250 | ||
251 | <!-- 4.4.3.3 divide --> | |
252 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:divide]]"> | |
253 | <xsl:param name="p" select="0"/> | |
254 | <xsl:call-template name="binary"> | |
255 | <xsl:with-param name="mo"><mml:mo>/</mml:mo></xsl:with-param> | |
256 | <xsl:with-param name="p" select="$p"/> | |
257 | <xsl:with-param name="this-p" select="3"/> | |
258 | </xsl:call-template> | |
259 | </xsl:template> | |
260 | ||
261 | ||
262 | <!-- 4.4.3.4 max min--> | |
263 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:max]]"> | |
264 | <mml:mrow> | |
265 | <mml:mo>max</mml:mo> | |
266 | <xsl:call-template name="set"/> | |
267 | </mml:mrow> | |
268 | </xsl:template> | |
269 | ||
270 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:min]]"> | |
271 | <mml:mrow> | |
272 | <mml:mo>max</mml:mo> | |
273 | <xsl:call-template name="set"/> | |
274 | </mml:mrow> | |
275 | </xsl:template> | |
276 | ||
277 | <!-- 4.4.3.5 minus--> | |
278 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:minus] and count(*)=2]"> | |
279 | <mml:mrow> | |
280 | <mml:mo>−<!--minus--></mml:mo> | |
281 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
282 | <xsl:with-param name="p" select="5"/> | |
283 | </xsl:apply-templates> | |
284 | </mml:mrow> | |
285 | </xsl:template> | |
286 | ||
287 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:minus] and count(*)>2]"> | |
288 | <xsl:param name="p" select="0"/> | |
289 | <xsl:call-template name="binary"> | |
290 | <xsl:with-param name="mo"><mml:mo>−<!--minus--></mml:mo></xsl:with-param> | |
291 | <xsl:with-param name="p" select="$p"/> | |
292 | <xsl:with-param name="this-p" select="2"/> | |
293 | </xsl:call-template> | |
294 | </xsl:template> | |
295 | ||
296 | <!-- 4.4.3.6 plus--> | |
297 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:plus]]"> | |
298 | <xsl:param name="p" select="0"/> | |
299 | <mml:mrow> | |
300 | <xsl:if test="$p > 2"><mml:mo>(</mml:mo></xsl:if> | |
301 | <xsl:for-each select="*[position()>1]"> | |
302 | <xsl:if test="position() > 1"> | |
303 | <mml:mo> | |
304 | <xsl:choose> | |
305 | <xsl:when test="self::mml:apply[*[1][self::mml:times] and | |
306 | *[2][self::mml:apply/*[1][self::mml:minus] or self::mml:cn[not(mml:sep) and | |
307 | (number(.) < 0)]]]">−<!--minus--></xsl:when> | |
308 | <xsl:otherwise>+</xsl:otherwise> | |
309 | </xsl:choose> | |
310 | </mml:mo> | |
311 | </xsl:if> | |
312 | <xsl:choose> | |
313 | <xsl:when test="self::mml:apply[*[1][self::mml:times] and | |
314 | *[2][self::mml:cn[not(mml:sep) and (number(.) <0)]]]"> | |
315 | <mml:mrow> | |
316 | <mml:mn><xsl:value-of select="-(*[2])"/></mml:mn> | |
317 | <mml:mo><!--⁢--><!--invisible times--></mml:mo> | |
318 | <xsl:apply-templates mode="c2p" select="."> | |
319 | <xsl:with-param name="first" select="2"/> | |
320 | <xsl:with-param name="p" select="2"/> | |
321 | </xsl:apply-templates> | |
322 | </mml:mrow> | |
323 | </xsl:when> | |
324 | <xsl:when test="self::mml:apply[*[1][self::mml:times] and | |
325 | *[2][self::mml:apply/*[1][self::mml:minus]]]"> | |
326 | <mml:mrow> | |
327 | <xsl:apply-templates mode="c2p" select="./*[2]/*[2]"/> | |
328 | <xsl:apply-templates mode="c2p" select="."> | |
329 | <xsl:with-param name="first" select="2"/> | |
330 | <xsl:with-param name="p" select="2"/> | |
331 | </xsl:apply-templates> | |
332 | </mml:mrow> | |
333 | </xsl:when> | |
334 | <xsl:otherwise> | |
335 | <xsl:apply-templates mode="c2p" select="."> | |
336 | <xsl:with-param name="p" select="2"/> | |
337 | </xsl:apply-templates> | |
338 | </xsl:otherwise> | |
339 | </xsl:choose> | |
340 | </xsl:for-each> | |
341 | <xsl:if test="$p > 2"><mml:mo>)</mml:mo></xsl:if> | |
342 | </mml:mrow> | |
343 | </xsl:template> | |
344 | ||
345 | ||
346 | <!-- 4.4.3.7 power --> | |
347 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:power]]"> | |
348 | <mml:msup> | |
349 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
350 | <xsl:with-param name="p" select="5"/> | |
351 | </xsl:apply-templates> | |
352 | <xsl:apply-templates mode="c2p" select="*[3]"> | |
353 | <xsl:with-param name="p" select="5"/> | |
354 | </xsl:apply-templates> | |
355 | </mml:msup> | |
356 | </xsl:template> | |
357 | ||
358 | <!-- 4.4.3.8 remainder --> | |
359 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:rem]]"> | |
360 | <xsl:param name="p" select="0"/> | |
361 | <xsl:call-template name="binary"> | |
362 | <xsl:with-param name="mo"><mml:mo>mod</mml:mo></xsl:with-param> | |
363 | <xsl:with-param name="p" select="$p"/> | |
364 | <xsl:with-param name="this-p" select="3"/> | |
365 | </xsl:call-template> | |
366 | </xsl:template> | |
367 | ||
368 | <!-- 4.4.3.9 times--> | |
369 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:times]]" name="times"> | |
370 | <xsl:param name="p" select="0"/> | |
371 | <xsl:param name="first" select="1"/> | |
372 | <mml:mrow> | |
373 | <xsl:if test="$p > 3"><mml:mo>(</mml:mo></xsl:if> | |
374 | <xsl:for-each select="*[position()>1]"> | |
375 | <xsl:if test="position() > 1"> | |
376 | <mml:mo> | |
377 | <xsl:choose> | |
378 | <xsl:when test="self::mml:cn">×<!-- times --></xsl:when> | |
379 | <xsl:otherwise><!--⁢--><!--invisible times--></xsl:otherwise> | |
380 | </xsl:choose> | |
381 | </mml:mo> | |
382 | </xsl:if> | |
383 | <xsl:if test="position()>= $first"> | |
384 | <xsl:apply-templates mode="c2p" select="."> | |
385 | <xsl:with-param name="p" select="3"/> | |
386 | </xsl:apply-templates> | |
387 | </xsl:if> | |
388 | </xsl:for-each> | |
389 | <xsl:if test="$p > 3"><mml:mo>)</mml:mo></xsl:if> | |
390 | </mml:mrow> | |
391 | </xsl:template> | |
392 | ||
393 | ||
394 | <!-- 4.4.3.10 root --> | |
395 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:root] and not(mml:degree) or mml:degree=2]" priority="4"> | |
396 | <mml:msqrt> | |
397 | <xsl:apply-templates mode="c2p" select="*[position()>1]"/> | |
398 | </mml:msqrt> | |
399 | </xsl:template> | |
400 | ||
401 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:root]]"> | |
402 | <mml:mroot> | |
403 | <xsl:apply-templates mode="c2p" select="*[position()>1 and not(self::mml:degree)]"/> | |
404 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/*"/></mml:mrow> | |
405 | </mml:mroot> | |
406 | </xsl:template> | |
407 | ||
408 | <!-- 4.4.3.11 gcd --> | |
409 | <xsl:template mode="c2p" match="mml:gcd"> | |
410 | <mml:mo>gcd</mml:mo> | |
411 | </xsl:template> | |
412 | ||
413 | <!-- 4.4.3.12 and --> | |
414 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:and]]"> | |
415 | <xsl:param name="p" select="0"/> | |
416 | <xsl:call-template name="infix"> | |
417 | <xsl:with-param name="this-p" select="2"/> | |
418 | <xsl:with-param name="p" select="$p"/> | |
419 | <xsl:with-param name="mo"><mml:mo>∧<!-- and --></mml:mo></xsl:with-param> | |
420 | </xsl:call-template> | |
421 | </xsl:template> | |
422 | ||
423 | ||
424 | <!-- 4.4.3.13 or --> | |
425 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:or]]"> | |
426 | <xsl:param name="p" select="0"/> | |
427 | <xsl:call-template name="infix"> | |
428 | <xsl:with-param name="this-p" select="3"/> | |
429 | <xsl:with-param name="p" select="$p"/> | |
430 | <xsl:with-param name="mo"><mml:mo>∨<!-- or --></mml:mo></xsl:with-param> | |
431 | </xsl:call-template> | |
432 | </xsl:template> | |
433 | ||
434 | <!-- 4.4.3.14 xor --> | |
435 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:xor]]"> | |
436 | <xsl:param name="p" select="0"/> | |
437 | <xsl:call-template name="infix"> | |
438 | <xsl:with-param name="this-p" select="3"/> | |
439 | <xsl:with-param name="p" select="$p"/> | |
440 | <xsl:with-param name="mo"><mml:mo>xor</mml:mo></xsl:with-param> | |
441 | </xsl:call-template> | |
442 | </xsl:template> | |
443 | ||
444 | ||
445 | <!-- 4.4.3.15 not --> | |
446 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:not]]"> | |
447 | <mml:mrow> | |
448 | <mml:mo>¬<!-- not --></mml:mo> | |
449 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
450 | <xsl:with-param name="p" select="7"/> | |
451 | </xsl:apply-templates> | |
452 | </mml:mrow> | |
453 | </xsl:template> | |
454 | ||
455 | ||
456 | ||
457 | ||
458 | <!-- 4.4.3.16 implies --> | |
459 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:implies]]"> | |
460 | <xsl:param name="p" select="0"/> | |
461 | <xsl:call-template name="binary"> | |
462 | <xsl:with-param name="mo"><mml:mo>⇒<!-- Rightarrow --></mml:mo></xsl:with-param> | |
463 | <xsl:with-param name="p" select="$p"/> | |
464 | <xsl:with-param name="this-p" select="3"/> | |
465 | </xsl:call-template> | |
466 | </xsl:template> | |
467 | ||
468 | ||
469 | <!-- 4.4.3.17 forall --> | |
470 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:forall]]"> | |
471 | <mml:mrow> | |
472 | <mml:mi>∀<!--forall--></mml:mi> | |
473 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar[not(current()/mml:condition)]/*|mml:condition/*"/></mml:mrow> | |
474 | <mml:mo>.</mml:mo> | |
475 | <mml:mfenced> | |
476 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
477 | </mml:mfenced> | |
478 | </mml:mrow> | |
479 | </xsl:template> | |
480 | ||
481 | ||
482 | ||
483 | <!-- 4.4.3.18 exists --> | |
484 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:exists]]"> | |
485 | <mml:mrow> | |
486 | <mml:mi>∃<!--exists--></mml:mi> | |
487 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar[not(current()/mml:condition)]/*|mml:condition/*"/></mml:mrow> | |
488 | <mml:mo>.</mml:mo> | |
489 | <mml:mfenced> | |
490 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
491 | </mml:mfenced> | |
492 | </mml:mrow> | |
493 | </xsl:template> | |
494 | ||
495 | ||
496 | <!-- 4.4.3.19 abs --> | |
497 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:abs]]"> | |
498 | <mml:mrow> | |
499 | <mml:mo>|</mml:mo> | |
500 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
501 | <mml:mo>|</mml:mo> | |
502 | </mml:mrow> | |
503 | </xsl:template> | |
504 | ||
505 | ||
506 | ||
507 | <!-- 4.4.3.20 conjugate --> | |
508 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:conjugate]]"> | |
509 | <mml:mover> | |
510 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
511 | <mml:mo>¯<!-- overline --></mml:mo> | |
512 | </mml:mover> | |
513 | </xsl:template> | |
514 | ||
515 | <!-- 4.4.3.21 arg --> | |
516 | <xsl:template mode="c2p" match="mml:arg"> | |
517 | <mml:mo>arg</mml:mo> | |
518 | </xsl:template> | |
519 | ||
520 | ||
521 | <!-- 4.4.3.22 real --> | |
522 | <xsl:template mode="c2p" match="mml:real"> | |
523 | <mml:mo>ℛ<!-- real --></mml:mo> | |
524 | </xsl:template> | |
525 | ||
526 | <!-- 4.4.3.23 imaginary --> | |
527 | <xsl:template mode="c2p" match="mml:imaginary"> | |
528 | <mml:mo>ℑ<!-- imaginary --></mml:mo> | |
529 | </xsl:template> | |
530 | ||
531 | <!-- 4.4.3.24 lcm --> | |
532 | <xsl:template mode="c2p" match="mml:lcm"> | |
533 | <mml:mo>lcm</mml:mo> | |
534 | </xsl:template> | |
535 | ||
536 | ||
537 | <!-- 4.4.3.25 floor --> | |
538 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:floor]]"> | |
539 | <mml:mrow> | |
540 | <mml:mo>⌊<!-- lfloor--></mml:mo> | |
541 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
542 | <mml:mo>⌋<!-- rfloor--></mml:mo> | |
543 | </mml:mrow> | |
544 | </xsl:template> | |
545 | ||
546 | ||
547 | <!-- 4.4.3.25 ceiling --> | |
548 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:ceiling]]"> | |
549 | <mml:mrow> | |
550 | <mml:mo>⌈<!-- lceil--></mml:mo> | |
551 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
552 | <mml:mo>⌉<!-- rceil--></mml:mo> | |
553 | </mml:mrow> | |
554 | </xsl:template> | |
555 | ||
556 | <!-- 4.4.4.1 eq --> | |
557 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:eq]]"> | |
558 | <xsl:param name="p" select="0"/> | |
559 | <xsl:call-template name="infix"> | |
560 | <xsl:with-param name="this-p" select="1"/> | |
561 | <xsl:with-param name="p" select="$p"/> | |
562 | <xsl:with-param name="mo"><mml:mo>=</mml:mo></xsl:with-param> | |
563 | </xsl:call-template> | |
564 | </xsl:template> | |
565 | ||
566 | <!-- 4.4.4.2 neq --> | |
567 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:neq]]"> | |
568 | <xsl:param name="p" select="0"/> | |
569 | <xsl:call-template name="infix"> | |
570 | <xsl:with-param name="this-p" select="1"/> | |
571 | <xsl:with-param name="p" select="$p"/> | |
572 | <xsl:with-param name="mo"><mml:mo>≠<!-- neq --></mml:mo></xsl:with-param> | |
573 | </xsl:call-template> | |
574 | </xsl:template> | |
575 | ||
576 | <!-- 4.4.4.3 eq --> | |
577 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:gt]]"> | |
578 | <xsl:param name="p" select="0"/> | |
579 | <xsl:call-template name="infix"> | |
580 | <xsl:with-param name="this-p" select="1"/> | |
581 | <xsl:with-param name="p" select="$p"/> | |
582 | <xsl:with-param name="mo"><mml:mo>></mml:mo></xsl:with-param> | |
583 | </xsl:call-template> | |
584 | </xsl:template> | |
585 | ||
586 | <!-- 4.4.4.4 lt --> | |
587 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:lt]]"> | |
588 | <xsl:param name="p" select="0"/> | |
589 | <xsl:call-template name="infix"> | |
590 | <xsl:with-param name="this-p" select="1"/> | |
591 | <xsl:with-param name="p" select="$p"/> | |
592 | <xsl:with-param name="mo"><mml:mo><</mml:mo></xsl:with-param> | |
593 | </xsl:call-template> | |
594 | </xsl:template> | |
595 | ||
596 | <!-- 4.4.4.5 geq --> | |
597 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:geq]]"> | |
598 | <xsl:param name="p" select="0"/> | |
599 | <xsl:call-template name="infix"> | |
600 | <xsl:with-param name="this-p" select="1"/> | |
601 | <xsl:with-param name="p" select="$p"/> | |
602 | <xsl:with-param name="mo"><mml:mo>≥</mml:mo></xsl:with-param> | |
603 | </xsl:call-template> | |
604 | </xsl:template> | |
605 | ||
606 | <!-- 4.4.4.6 geq --> | |
607 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:leq]]"> | |
608 | <xsl:param name="p" select="0"/> | |
609 | <xsl:call-template name="infix"> | |
610 | <xsl:with-param name="this-p" select="1"/> | |
611 | <xsl:with-param name="p" select="$p"/> | |
612 | <xsl:with-param name="mo"><mml:mo>≤</mml:mo></xsl:with-param> | |
613 | </xsl:call-template> | |
614 | </xsl:template> | |
615 | ||
616 | <!-- 4.4.4.7 equivalent --> | |
617 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:equivalent]]"> | |
618 | <xsl:param name="p" select="0"/> | |
619 | <xsl:call-template name="infix"> | |
620 | <xsl:with-param name="this-p" select="1"/> | |
621 | <xsl:with-param name="p" select="$p"/> | |
622 | <xsl:with-param name="mo"><mml:mo>≡</mml:mo></xsl:with-param> | |
623 | </xsl:call-template> | |
624 | </xsl:template> | |
625 | ||
626 | <!-- 4.4.4.8 approx --> | |
627 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:approx]]"> | |
628 | <xsl:param name="p" select="0"/> | |
629 | <xsl:call-template name="infix"> | |
630 | <xsl:with-param name="this-p" select="1"/> | |
631 | <xsl:with-param name="p" select="$p"/> | |
632 | <xsl:with-param name="mo"><mml:mo>≃</mml:mo></xsl:with-param> | |
633 | </xsl:call-template> | |
634 | </xsl:template> | |
635 | ||
636 | ||
637 | <!-- 4.4.4.9 factorof --> | |
638 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:factorof]]"> | |
639 | <xsl:param name="p" select="0"/> | |
640 | <xsl:call-template name="binary"> | |
641 | <xsl:with-param name="mo"><mml:mo>|</mml:mo></xsl:with-param> | |
642 | <xsl:with-param name="p" select="$p"/> | |
643 | <xsl:with-param name="this-p" select="3"/> | |
644 | </xsl:call-template> | |
645 | </xsl:template> | |
646 | ||
647 | <!-- 4.4.5.1 int --> | |
648 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:int]]"> | |
649 | <mml:mrow> | |
650 | <mml:msubsup> | |
651 | <mml:mi>∫<!--int--></mml:mi> | |
652 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow> | |
653 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow> | |
654 | </mml:msubsup> | |
655 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
656 | <mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar"/> | |
657 | </mml:mrow> | |
658 | </xsl:template> | |
659 | ||
660 | <!-- 4.4.5.2 diff --> | |
661 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:diff] and mml:ci and count(*)=2]" priority="2"> | |
662 | <mml:msup> | |
663 | <mml:mrow><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mrow> | |
664 | <mml:mo>′<!--prime--></mml:mo> | |
665 | </mml:msup> | |
666 | </xsl:template> | |
667 | ||
668 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:diff]]" priority="1"> | |
669 | <mml:mfrac> | |
670 | <xsl:choose> | |
671 | <xsl:when test="mml:bvar/mml:degree"> | |
672 | <mml:mrow><mml:msup><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar/mml:degree/node()"/></mml:msup> | |
673 | <xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow> | |
674 | <mml:mrow><mml:mo>d</mml:mo><mml:msup><xsl:apply-templates mode="c2p" | |
675 | select="mml:bvar/node()"/><xsl:apply-templates mode="c2p" | |
676 | select="mml:bvar/mml:degree/node()"/></mml:msup> | |
677 | </mml:mrow> | |
678 | </xsl:when> | |
679 | <xsl:otherwise> | |
680 | <mml:mrow><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow> | |
681 | <mml:mrow><mml:mo>d</mml:mo><xsl:apply-templates mode="c2p" select="mml:bvar"/></mml:mrow> | |
682 | </xsl:otherwise> | |
683 | </xsl:choose> | |
684 | </mml:mfrac> | |
685 | </xsl:template> | |
686 | ||
687 | ||
688 | <!-- 4.4.5.3 partialdiff --> | |
689 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:partialdiff] and mml:list and mml:ci and count(*)=3]" priority="2"> | |
690 | <mml:mrow> | |
691 | <mml:msub><mml:mo>D</mml:mo><mml:mrow> | |
692 | <xsl:for-each select="mml:list[1]/*"> | |
693 | <xsl:apply-templates mode="c2p" select="."/> | |
694 | <xsl:if test="position()<last()"><mml:mo>,</mml:mo></xsl:if> | |
695 | </xsl:for-each> | |
696 | </mml:mrow></mml:msub> | |
697 | <mml:mrow><xsl:apply-templates mode="c2p" select="*[3]"/></mml:mrow> | |
698 | </mml:mrow> | |
699 | </xsl:template> | |
700 | ||
701 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:partialdiff]]" priority="1"> | |
702 | <mml:mfrac> | |
703 | <mml:mrow><mml:msup><mml:mo>∂<!-- partial --></mml:mo> | |
704 | <mml:mrow> | |
705 | <xsl:choose> | |
706 | <xsl:when test="mml:degree"> | |
707 | <xsl:apply-templates mode="c2p" select="mml:degree/node()"/> | |
708 | </xsl:when> | |
709 | <xsl:when test="mml:bvar/mml:degree[string(number(.))='NaN']"> | |
710 | <xsl:for-each select="mml:bvar/mml:degree"> | |
711 | <xsl:apply-templates mode="c2p" select="node()"/> | |
712 | <xsl:if test="position()<last()"><mml:mo>+</mml:mo></xsl:if> | |
713 | </xsl:for-each> | |
714 | <xsl:if test="count(mml:bvar[not(mml:degree)])>0"> | |
715 | <mml:mo>+</mml:mo><mml:mn><xsl:value-of select="count(mml:bvar[not(mml:degree)])"/></mml:mn> | |
716 | </xsl:if> | |
717 | </xsl:when> | |
718 | <xsl:otherwise> | |
719 | <mml:mn><xsl:value-of select="sum(mml:bvar/mml:degree)+count(mml:bvar[not(mml:degree)])"/></mml:mn> | |
720 | </xsl:otherwise> | |
721 | </xsl:choose> | |
722 | </mml:mrow> | |
723 | </mml:msup> | |
724 | <xsl:apply-templates mode="c2p" select="*[last()]"/></mml:mrow> | |
725 | <mml:mrow> | |
726 | <xsl:for-each select="mml:bvar"> | |
727 | <mml:mrow> | |
728 | <mml:mo>∂<!-- partial --></mml:mo><mml:msup><xsl:apply-templates mode="c2p" select="node()"/> | |
729 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/node()"/></mml:mrow> | |
730 | </mml:msup> | |
731 | </mml:mrow> | |
732 | </xsl:for-each> | |
733 | </mml:mrow> | |
734 | </mml:mfrac> | |
735 | </xsl:template> | |
736 | ||
737 | <!-- 4.4.5.4 lowlimit--> | |
738 | <xsl:template mode="c2p" match="mml:lowlimit"/> | |
739 | ||
740 | <!-- 4.4.5.5 uplimit--> | |
741 | <xsl:template mode="c2p" match="mml:uplimit"/> | |
742 | ||
743 | <!-- 4.4.5.6 bvar--> | |
744 | <xsl:template mode="c2p" match="mml:bvar"> | |
745 | <mml:mi><xsl:apply-templates mode="c2p"/></mml:mi> | |
746 | <xsl:if test="following-sibling::mml:bvar"><mml:mo>,</mml:mo></xsl:if> | |
747 | </xsl:template> | |
748 | ||
749 | <!-- 4.4.5.7 degree--> | |
750 | <xsl:template mode="c2p" match="mml:degree"/> | |
751 | ||
752 | <!-- 4.4.5.8 divergence--> | |
753 | <xsl:template mode="c2p" match="mml:divergence"> | |
754 | <mml:mo>div</mml:mo> | |
755 | </xsl:template> | |
756 | ||
757 | <!-- 4.4.5.9 grad--> | |
758 | <xsl:template mode="c2p" match="mml:grad"> | |
759 | <mml:mo>grad</mml:mo> | |
760 | </xsl:template> | |
761 | ||
762 | <!-- 4.4.5.10 curl --> | |
763 | <xsl:template mode="c2p" match="mml:curl"> | |
764 | <mml:mo>curl</mml:mo> | |
765 | </xsl:template> | |
766 | ||
767 | ||
768 | <!-- 4.4.5.11 laplacian--> | |
769 | <xsl:template mode="c2p" match="mml:laplacian"> | |
770 | <mml:msup><mml:mo>∇<!-- nabla --></mml:mo><mml:mn>2</mml:mn></mml:msup> | |
771 | </xsl:template> | |
772 | ||
773 | <!-- 4.4.6.1 set --> | |
774 | ||
775 | <xsl:template mode="c2p" match="mml:set"> | |
776 | <xsl:call-template name="set"/> | |
777 | </xsl:template> | |
778 | ||
779 | <!-- 4.4.6.2 list --> | |
780 | ||
781 | <xsl:template mode="c2p" match="mml:list"> | |
782 | <xsl:call-template name="set"> | |
783 | <xsl:with-param name="o" select="'('"/> | |
784 | <xsl:with-param name="c" select="')'"/> | |
785 | </xsl:call-template> | |
786 | </xsl:template> | |
787 | ||
788 | <!-- 4.4.6.3 union --> | |
789 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:union]]"> | |
790 | <xsl:param name="p" select="0"/> | |
791 | <xsl:call-template name="infix"> | |
792 | <xsl:with-param name="this-p" select="2"/> | |
793 | <xsl:with-param name="p" select="$p"/> | |
794 | <xsl:with-param name="mo"><mml:mo>∪<!-- union --></mml:mo></xsl:with-param> | |
795 | </xsl:call-template> | |
796 | </xsl:template> | |
797 | ||
798 | <!-- 4.4.6.4 intersect --> | |
799 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:intersect]]"> | |
800 | <xsl:param name="p" select="0"/> | |
801 | <xsl:call-template name="infix"> | |
802 | <xsl:with-param name="this-p" select="3"/> | |
803 | <xsl:with-param name="p" select="$p"/> | |
804 | <xsl:with-param name="mo"><mml:mo>∩<!-- intersect --></mml:mo></xsl:with-param> | |
805 | </xsl:call-template> | |
806 | </xsl:template> | |
807 | ||
808 | <!-- 4.4.6.5 in --> | |
809 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:in]]"> | |
810 | <xsl:param name="p" select="0"/> | |
811 | <xsl:call-template name="binary"> | |
812 | <xsl:with-param name="mo"><mml:mo>∈<!-- in --></mml:mo></xsl:with-param> | |
813 | <xsl:with-param name="p" select="$p"/> | |
814 | <xsl:with-param name="this-p" select="3"/> | |
815 | </xsl:call-template> | |
816 | </xsl:template> | |
817 | ||
818 | <!-- 4.4.6.5 notin --> | |
819 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notin]]"> | |
820 | <xsl:param name="p" select="0"/> | |
821 | <xsl:call-template name="binary"> | |
822 | <xsl:with-param name="mo"><mml:mo>∉<!-- not in --></mml:mo></xsl:with-param> | |
823 | <xsl:with-param name="p" select="$p"/> | |
824 | <xsl:with-param name="this-p" select="3"/> | |
825 | </xsl:call-template> | |
826 | </xsl:template> | |
827 | ||
828 | <!-- 4.4.6.7 subset --> | |
829 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:subset]]"> | |
830 | <xsl:param name="p" select="0"/> | |
831 | <xsl:call-template name="infix"> | |
832 | <xsl:with-param name="this-p" select="2"/> | |
833 | <xsl:with-param name="p" select="$p"/> | |
834 | <xsl:with-param name="mo"><mml:mo>⊆<!-- subseteq --></mml:mo></xsl:with-param> | |
835 | </xsl:call-template> | |
836 | </xsl:template> | |
837 | ||
838 | <!-- 4.4.6.8 prsubset --> | |
839 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:prsubset]]"> | |
840 | <xsl:param name="p" select="0"/> | |
841 | <xsl:call-template name="infix"> | |
842 | <xsl:with-param name="this-p" select="2"/> | |
843 | <xsl:with-param name="p" select="$p"/> | |
844 | <xsl:with-param name="mo"><mml:mo>⊂<!-- prsubset --></mml:mo></xsl:with-param> | |
845 | </xsl:call-template> | |
846 | </xsl:template> | |
847 | ||
848 | <!-- 4.4.6.9 notsubset --> | |
849 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notsubset]]"> | |
850 | <xsl:param name="p" select="0"/> | |
851 | <xsl:call-template name="binary"> | |
852 | <xsl:with-param name="this-p" select="2"/> | |
853 | <xsl:with-param name="p" select="$p"/> | |
854 | <xsl:with-param name="mo"><mml:mo>⊈<!-- notsubseteq --></mml:mo></xsl:with-param> | |
855 | </xsl:call-template> | |
856 | </xsl:template> | |
857 | ||
858 | <!-- 4.4.6.10 notprsubset --> | |
859 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:notprsubset]]"> | |
860 | <xsl:param name="p" select="0"/> | |
861 | <xsl:call-template name="binary"> | |
862 | <xsl:with-param name="this-p" select="2"/> | |
863 | <xsl:with-param name="p" select="$p"/> | |
864 | <xsl:with-param name="mo"><mml:mo>⊄<!-- prsubset --></mml:mo></xsl:with-param> | |
865 | </xsl:call-template> | |
866 | </xsl:template> | |
867 | ||
868 | <!-- 4.4.6.11 setdiff --> | |
869 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:setdiff]]"> | |
870 | <xsl:param name="p" select="0"/> | |
871 | <xsl:call-template name="binary"> | |
872 | <xsl:with-param name="this-p" select="2"/> | |
873 | <xsl:with-param name="p" select="$p"/> | |
874 | <xsl:with-param name="mo"><mml:mo>∖<!-- setminus --></mml:mo></xsl:with-param> | |
875 | </xsl:call-template> | |
876 | </xsl:template> | |
877 | ||
878 | <!-- 4.4.6.12 card --> | |
879 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:card]]"> | |
880 | <mml:mrow> | |
881 | <mml:mo>|</mml:mo> | |
882 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
883 | <mml:mo>|</mml:mo> | |
884 | </mml:mrow> | |
885 | </xsl:template> | |
886 | ||
887 | <!-- 4.4.6.13 cartesianproduct --> | |
888 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:cartesianproduct or self::mml:vectorproduct]]"> | |
889 | <xsl:param name="p" select="0"/> | |
890 | <xsl:call-template name="infix"> | |
891 | <xsl:with-param name="this-p" select="2"/> | |
892 | <xsl:with-param name="p" select="$p"/> | |
893 | <xsl:with-param name="mo"><mml:mo>×<!-- times --></mml:mo></xsl:with-param> | |
894 | </xsl:call-template> | |
895 | </xsl:template> | |
896 | ||
897 | <xsl:template | |
898 | match="mml:apply[*[1][self::mml:cartesianproduct][count(following-sibling::mml:reals)=count(following-sibling::*)]]" | |
899 | priority="2"> | |
900 | <mml:msup> | |
901 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
902 | <xsl:with-param name="p" select="5"/> | |
903 | </xsl:apply-templates> | |
904 | <mml:mn><xsl:value-of select="count(*)-1"/></mml:mn> | |
905 | </mml:msup> | |
906 | </xsl:template> | |
907 | ||
908 | ||
909 | <!-- 4.4.7.1 sum --> | |
910 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:sum]]"> | |
911 | <mml:mrow> | |
912 | <mml:msubsup> | |
913 | <mml:mo>∑<!--sum--></mml:mo> | |
914 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow> | |
915 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow> | |
916 | </mml:msubsup> | |
917 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
918 | </mml:mrow> | |
919 | </xsl:template> | |
920 | ||
921 | <!-- 4.4.7.2 product --> | |
922 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:product]]"> | |
923 | <mml:mrow> | |
924 | <mml:msubsup> | |
925 | <mml:mo>∏<!--product--></mml:mo> | |
926 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit/*|mml:interval/*[1]|mml:condition/*"/></mml:mrow> | |
927 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:uplimit/*|mml:interval/*[2]"/></mml:mrow> | |
928 | </mml:msubsup> | |
929 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
930 | </mml:mrow> | |
931 | </xsl:template> | |
932 | ||
933 | <!-- 4.4.7.3 limit --> | |
934 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:limit]]"> | |
935 | <mml:mrow> | |
936 | <mml:munder> | |
937 | <mml:mi>limit</mml:mi> | |
938 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:lowlimit|mml:condition/*"/></mml:mrow> | |
939 | </mml:munder> | |
940 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
941 | </mml:mrow> | |
942 | </xsl:template> | |
943 | ||
944 | <xsl:template mode="c2p" match="mml:apply[mml:limit]/mml:lowlimit" priority="3"> | |
945 | <mml:mrow> | |
946 | <xsl:apply-templates mode="c2p" select="../mml:bvar/node()"/> | |
947 | <mml:mo>→<!--rightarrow--></mml:mo> | |
948 | <xsl:apply-templates mode="c2p"/> | |
949 | </mml:mrow> | |
950 | </xsl:template> | |
951 | ||
952 | ||
953 | <!-- 4.4.7.4 tendsto --> | |
954 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:tendsto]]"> | |
955 | <xsl:param name="p"/> | |
956 | <xsl:call-template name="binary"> | |
957 | <xsl:with-param name="this-p" select="2"/> | |
958 | <xsl:with-param name="p" select="$p"/> | |
959 | <xsl:with-param name="mo"><mml:mo> | |
960 | <xsl:choose> | |
961 | <xsl:when test="@type='above'">↘<!--searrow--></xsl:when> | |
962 | <xsl:when test="@type='below'">↗<!--nearrow--></xsl:when> | |
963 | <xsl:when test="@type='two-sided'">→<!--rightarrow--></xsl:when> | |
964 | <xsl:otherwise>→<!--rightarrow--></xsl:otherwise> | |
965 | </xsl:choose> | |
966 | </mml:mo></xsl:with-param> | |
967 | </xsl:call-template> | |
968 | </xsl:template> | |
969 | ||
970 | <!-- 4.4.8.1 trig --> | |
971 | <xsl:template mode="c2p" match="mml:apply[*[1][ | |
972 | self::mml:sin or self::mml:cos or self::mml:tan or self::mml:sec or | |
973 | self::mml:csc or self::mml:cot or self::mml:sinh or self::mml:cosh or | |
974 | self::mml:tanh or self::mml:sech or self::mml:csch or self::mml:coth or | |
975 | self::mml:arcsin or self::mml:arccos or self::mml:arctan or self::mml:arccosh | |
976 | or self::mml:arccot or self::mml:arccoth or self::mml:arccsc or | |
977 | self::mml:arccsch or self::mml:arcsec or self::mml:arcsech or | |
978 | self::mml:arcsinh or self::mml:arctanh or self::mml:ln]]"> | |
979 | <mml:mrow> | |
980 | <mml:mi><xsl:value-of select="local-name(*[1])"/></mml:mi> | |
981 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
982 | <xsl:with-param name="p" select="7"/> | |
983 | </xsl:apply-templates> | |
984 | </mml:mrow> | |
985 | </xsl:template> | |
986 | ||
987 | ||
988 | ||
989 | ||
990 | <!-- 4.4.8.2 exp --> | |
991 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:exp]]"> | |
992 | <mml:msup> | |
993 | <mml:mi>e<!-- exponential e--></mml:mi> | |
994 | <mml:mrow><xsl:apply-templates mode="c2p" select="*[2]"/></mml:mrow> | |
995 | </mml:msup> | |
996 | </xsl:template> | |
997 | ||
998 | <!-- 4.4.8.3 ln --> | |
999 | <!-- with trig --> | |
1000 | ||
1001 | <!-- 4.4.8.4 log --> | |
1002 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:log]]"> | |
1003 | <mml:mrow> | |
1004 | <xsl:choose> | |
1005 | <xsl:when test="not(mml:logbase) or mml:logbase=10"> | |
1006 | <mml:mi>log</mml:mi> | |
1007 | </xsl:when> | |
1008 | <xsl:otherwise> | |
1009 | <mml:msub> | |
1010 | <mml:mi>log</mml:mi> | |
1011 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:logbase/node()"/></mml:mrow> | |
1012 | </mml:msub> | |
1013 | </xsl:otherwise> | |
1014 | </xsl:choose> | |
1015 | <xsl:apply-templates mode="c2p" select="*[last()]"> | |
1016 | <xsl:with-param name="p" select="7"/> | |
1017 | </xsl:apply-templates> | |
1018 | </mml:mrow> | |
1019 | </xsl:template> | |
1020 | ||
1021 | ||
1022 | <!-- 4.4.9.1 mean --> | |
1023 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:mean]]"> | |
1024 | <mml:mrow> | |
1025 | <mml:mo>〈<!--langle--></mml:mo> | |
1026 | <xsl:for-each select="*[position()>1]"> | |
1027 | <xsl:apply-templates mode="c2p" select="."/> | |
1028 | <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if> | |
1029 | </xsl:for-each> | |
1030 | <mml:mo>〉<!--rangle--></mml:mo> | |
1031 | </mml:mrow> | |
1032 | </xsl:template> | |
1033 | ||
1034 | ||
1035 | <!-- 4.4.9.2 sdef --> | |
1036 | <xsl:template mode="c2p" match="mml:sdev"> | |
1037 | <mml:mo>σ<!--sigma--></mml:mo> | |
1038 | </xsl:template> | |
1039 | ||
1040 | <!-- 4.4.9.3 variance --> | |
1041 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:variance]]"> | |
1042 | <mml:msup> | |
1043 | <mml:mrow> | |
1044 | <mml:mo>σ<!--sigma--></mml:mo> | |
1045 | <mml:mo>(</mml:mo> | |
1046 | <xsl:apply-templates mode="c2p" select="*[2]"/> | |
1047 | <mml:mo>)</mml:mo> | |
1048 | </mml:mrow> | |
1049 | <mml:mn>2</mml:mn> | |
1050 | </mml:msup> | |
1051 | </xsl:template> | |
1052 | ||
1053 | ||
1054 | <!-- 4.4.9.4 median --> | |
1055 | <xsl:template mode="c2p" match="mml:median"> | |
1056 | <mml:mo>median</mml:mo> | |
1057 | </xsl:template> | |
1058 | ||
1059 | ||
1060 | <!-- 4.4.9.5 mode --> | |
1061 | <xsl:template mode="c2p" match="mml:mode"> | |
1062 | <mml:mo>mode</mml:mo> | |
1063 | </xsl:template> | |
1064 | ||
1065 | <!-- 4.4.9.5 moment --> | |
1066 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:moment]]"> | |
1067 | <mml:mrow> | |
1068 | <mml:mo>〈<!--langle--></mml:mo> | |
1069 | <mml:msup> | |
1070 | <xsl:apply-templates mode="c2p" select="*[last()]"/> | |
1071 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:degree/node()"/></mml:mrow> | |
1072 | </mml:msup> | |
1073 | <mml:mo>〉<!--rangle--></mml:mo> | |
1074 | </mml:mrow> | |
1075 | </xsl:template> | |
1076 | ||
1077 | <!-- 4.4.9.5 momentabout --> | |
1078 | <xsl:template mode="c2p" match="mml:momentabout"/> | |
1079 | ||
1080 | <!-- 4.4.10.1 vector --> | |
1081 | <xsl:template mode="c2p" match="mml:vector"> | |
1082 | <mml:mrow> | |
1083 | <mml:mo>(</mml:mo> | |
1084 | <mml:mtable> | |
1085 | <xsl:for-each select="*"> | |
1086 | <mml:mtr><mml:mtd><xsl:apply-templates mode="c2p" select="."/></mml:mtd></mml:mtr> | |
1087 | </xsl:for-each> | |
1088 | </mml:mtable> | |
1089 | <mml:mo>)</mml:mo> | |
1090 | </mml:mrow> | |
1091 | </xsl:template> | |
1092 | ||
1093 | <!-- 4.4.10.2 matrix --> | |
1094 | <xsl:template mode="c2p" match="mml:matrix"> | |
1095 | <mml:mrow> | |
1096 | <mml:mo>(</mml:mo> | |
1097 | <mml:mtable> | |
1098 | <xsl:apply-templates mode="c2p"/> | |
1099 | </mml:mtable> | |
1100 | <mml:mo>)</mml:mo> | |
1101 | </mml:mrow> | |
1102 | </xsl:template> | |
1103 | ||
1104 | <!-- 4.4.10.3 matrixrow --> | |
1105 | <xsl:template mode="c2p" match="mml:matrixrow"> | |
1106 | <mml:mtr> | |
1107 | <xsl:for-each select="*"> | |
1108 | <mml:mtd><xsl:apply-templates mode="c2p" select="."/></mml:mtd> | |
1109 | </xsl:for-each> | |
1110 | </mml:mtr> | |
1111 | </xsl:template> | |
1112 | ||
1113 | <!-- 4.4.10.4 determinant --> | |
1114 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:determinant]]"> | |
1115 | <mml:mrow> | |
1116 | <mml:mi>det</mml:mi> | |
1117 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
1118 | <xsl:with-param name="p" select="7"/> | |
1119 | </xsl:apply-templates> | |
1120 | </mml:mrow> | |
1121 | </xsl:template> | |
1122 | ||
1123 | <xsl:template | |
1124 | match="mml:apply[*[1][self::mml:determinant]][*[2][self::mml:matrix]]" priority="2"> | |
1125 | <mml:mrow> | |
1126 | <mml:mo>|</mml:mo> | |
1127 | <mml:mtable> | |
1128 | <xsl:apply-templates mode="c2p" select="mml:matrix/*"/> | |
1129 | </mml:mtable> | |
1130 | <mml:mo>|</mml:mo> | |
1131 | </mml:mrow> | |
1132 | </xsl:template> | |
1133 | ||
1134 | <!-- 4.4.10.5 transpose --> | |
1135 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:transpose]]"> | |
1136 | <mml:msup> | |
1137 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
1138 | <xsl:with-param name="p" select="7"/> | |
1139 | </xsl:apply-templates> | |
1140 | <mml:mi>T</mml:mi> | |
1141 | </mml:msup> | |
1142 | </xsl:template> | |
1143 | ||
1144 | <!-- 4.4.10.5 selector --> | |
1145 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:selector]]"> | |
1146 | <mml:msub> | |
1147 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
1148 | <xsl:with-param name="p" select="7"/> | |
1149 | </xsl:apply-templates> | |
1150 | <mml:mrow> | |
1151 | <xsl:for-each select="*[position()>2]"> | |
1152 | <xsl:apply-templates mode="c2p" select="."/> | |
1153 | <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if> | |
1154 | </xsl:for-each> | |
1155 | </mml:mrow> | |
1156 | </mml:msub> | |
1157 | </xsl:template> | |
1158 | ||
1159 | <!-- *** --> | |
1160 | <!-- 4.4.10.6 vectorproduct see cartesianproduct --> | |
1161 | ||
1162 | ||
1163 | <!-- 4.4.10.7 scalarproduct--> | |
1164 | <xsl:template mode="c2p" match="mml:apply[*[1][self::mml:scalarproduct or self::mml:outerproduct]]"> | |
1165 | <xsl:param name="p" select="0"/> | |
1166 | <xsl:call-template name="infix"> | |
1167 | <xsl:with-param name="this-p" select="2"/> | |
1168 | <xsl:with-param name="p" select="$p"/> | |
1169 | <xsl:with-param name="mo"><mml:mo>.</mml:mo></xsl:with-param> | |
1170 | </xsl:call-template> | |
1171 | </xsl:template> | |
1172 | ||
1173 | <!-- 4.4.10.8 outerproduct--> | |
1174 | ||
1175 | <!-- 4.4.11.2 semantics --> | |
1176 | <xsl:template mode="c2p" match="mml:semantics"> | |
1177 | <xsl:apply-templates mode="c2p" select="*[1]"/> | |
1178 | </xsl:template> | |
1179 | <xsl:template mode="c2p" match="mml:semantics[mml:annotation-xml/@encoding='MathML-Presentation']"> | |
1180 | <xsl:apply-templates mode="c2p" select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/> | |
1181 | </xsl:template> | |
1182 | ||
1183 | <!-- 4.4.12.1 integers --> | |
1184 | <xsl:template mode="c2p" match="mml:integers"> | |
1185 | <mml:mi mathvariant="double-struck">Z</mml:mi> | |
1186 | </xsl:template> | |
1187 | ||
1188 | <!-- 4.4.12.2 reals --> | |
1189 | <xsl:template mode="c2p" match="mml:reals"> | |
1190 | <mml:mi mathvariant="double-struck">R</mml:mi> | |
1191 | </xsl:template> | |
1192 | ||
1193 | <!-- 4.4.12.3 rationals --> | |
1194 | <xsl:template mode="c2p" match="mml:rationals"> | |
1195 | <mml:mi mathvariant="double-struck">Q</mml:mi> | |
1196 | </xsl:template> | |
1197 | ||
1198 | <!-- 4.4.12.4 naturalnumbers --> | |
1199 | <xsl:template mode="c2p" match="mml:naturalnumbers"> | |
1200 | <mml:mi mathvariant="double-struck">N</mml:mi> | |
1201 | </xsl:template> | |
1202 | ||
1203 | <!-- 4.4.12.5 complexes --> | |
1204 | <xsl:template mode="c2p" match="mml:complexes"> | |
1205 | <mml:mi mathvariant="double-struck">C</mml:mi> | |
1206 | </xsl:template> | |
1207 | ||
1208 | <!-- 4.4.12.6 primes --> | |
1209 | <xsl:template mode="c2p" match="mml:primes"> | |
1210 | <mml:mi mathvariant="double-struck">P</mml:mi> | |
1211 | </xsl:template> | |
1212 | ||
1213 | <!-- 4.4.12.7 exponentiale --> | |
1214 | <xsl:template mode="c2p" match="mml:exponentiale"> | |
1215 | <mml:mi>e<!-- exponential e--></mml:mi> | |
1216 | </xsl:template> | |
1217 | ||
1218 | <!-- 4.4.12.8 imaginaryi --> | |
1219 | <xsl:template mode="c2p" match="mml:imaginaryi"> | |
1220 | <mml:mi>i<!-- imaginary i--></mml:mi> | |
1221 | </xsl:template> | |
1222 | ||
1223 | <!-- 4.4.12.9 notanumber --> | |
1224 | <xsl:template mode="c2p" match="mml:notanumber"> | |
1225 | <mml:mi>NaN</mml:mi> | |
1226 | </xsl:template> | |
1227 | ||
1228 | <!-- 4.4.12.10 true --> | |
1229 | <xsl:template mode="c2p" match="mml:true"> | |
1230 | <mml:mi>true</mml:mi> | |
1231 | </xsl:template> | |
1232 | ||
1233 | <!-- 4.4.12.11 false --> | |
1234 | <xsl:template mode="c2p" match="mml:false"> | |
1235 | <mml:mi>false</mml:mi> | |
1236 | </xsl:template> | |
1237 | ||
1238 | <!-- 4.4.12.12 emptyset --> | |
1239 | <xsl:template mode="c2p" match="mml:emptyset"> | |
1240 | <mml:mi>∅<!-- emptyset --></mml:mi> | |
1241 | </xsl:template> | |
1242 | ||
1243 | ||
1244 | <!-- 4.4.12.13 pi --> | |
1245 | <xsl:template mode="c2p" match="mml:pi"> | |
1246 | <mml:mi>π<!-- pi --></mml:mi> | |
1247 | </xsl:template> | |
1248 | ||
1249 | <!-- 4.4.12.14 eulergamma --> | |
1250 | <xsl:template mode="c2p" match="mml:eulergamma"> | |
1251 | <mml:mi>γ<!-- gamma --></mml:mi> | |
1252 | </xsl:template> | |
1253 | ||
1254 | <!-- 4.4.12.15 infinity --> | |
1255 | <xsl:template mode="c2p" match="mml:infinity"> | |
1256 | <mml:mi>∞<!-- infinity --></mml:mi> | |
1257 | </xsl:template> | |
1258 | ||
1259 | ||
1260 | <!-- ****************************** --> | |
1261 | <xsl:template name="infix" > | |
1262 | <xsl:param name="mo"/> | |
1263 | <xsl:param name="p" select="0"/> | |
1264 | <xsl:param name="this-p" select="0"/> | |
1265 | <mml:mrow> | |
1266 | <xsl:if test="$this-p < $p"><mml:mo>(</mml:mo></xsl:if> | |
1267 | <xsl:for-each select="*[position()>1]"> | |
1268 | <xsl:if test="position() > 1"> | |
1269 | <xsl:copy-of select="$mo"/> | |
1270 | </xsl:if> | |
1271 | <xsl:apply-templates mode="c2p" select="."> | |
1272 | <xsl:with-param name="p" select="$this-p"/> | |
1273 | </xsl:apply-templates> | |
1274 | </xsl:for-each> | |
1275 | <xsl:if test="$this-p < $p"><mml:mo>)</mml:mo></xsl:if> | |
1276 | </mml:mrow> | |
1277 | </xsl:template> | |
1278 | ||
1279 | <xsl:template name="binary" > | |
1280 | <xsl:param name="mo"/> | |
1281 | <xsl:param name="p" select="0"/> | |
1282 | <xsl:param name="this-p" select="0"/> | |
1283 | <mml:mrow> | |
1284 | <xsl:if test="$this-p < $p"><mml:mo>(</mml:mo></xsl:if> | |
1285 | <xsl:apply-templates mode="c2p" select="*[2]"> | |
1286 | <xsl:with-param name="p" select="$this-p"/> | |
1287 | </xsl:apply-templates> | |
1288 | <xsl:copy-of select="$mo"/> | |
1289 | <xsl:apply-templates mode="c2p" select="*[3]"> | |
1290 | <xsl:with-param name="p" select="$this-p"/> | |
1291 | </xsl:apply-templates> | |
1292 | <xsl:if test="$this-p < $p"><mml:mo>)</mml:mo></xsl:if> | |
1293 | </mml:mrow> | |
1294 | </xsl:template> | |
1295 | ||
1296 | <xsl:template name="set" > | |
1297 | <xsl:param name="o" select="'{'"/> | |
1298 | <xsl:param name="c" select="'}'"/> | |
1299 | <mml:mrow> | |
1300 | <mml:mo><xsl:value-of select="$o"/></mml:mo> | |
1301 | <xsl:choose> | |
1302 | <xsl:when test="mml:condition"> | |
1303 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:bvar/*[not(self::bvar or self::condition)]"/></mml:mrow> | |
1304 | <mml:mo>|</mml:mo> | |
1305 | <mml:mrow><xsl:apply-templates mode="c2p" select="mml:condition/node()"/></mml:mrow> | |
1306 | </xsl:when> | |
1307 | <xsl:otherwise> | |
1308 | <xsl:for-each select="*"> | |
1309 | <xsl:apply-templates mode="c2p" select="."/> | |
1310 | <xsl:if test="position() !=last()"><mml:mo>,</mml:mo></xsl:if> | |
1311 | </xsl:for-each> | |
1312 | </xsl:otherwise> | |
1313 | </xsl:choose> | |
1314 | <mml:mo><xsl:value-of select="$c"/></mml:mo> | |
1315 | </mml:mrow> | |
1316 | </xsl:template> | |
1317 | ||
1318 | </xsl:stylesheet> | |
1319 |