epub-translator 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. epub_translator/__init__.py +1 -2
  2. epub_translator/data/translate.jinja +3 -0
  3. epub_translator/epub/__init__.py +1 -1
  4. epub_translator/llm/context.py +10 -1
  5. epub_translator/llm/core.py +30 -3
  6. epub_translator/segment/__init__.py +1 -0
  7. epub_translator/segment/inline_segment.py +11 -1
  8. epub_translator/segment/text_segment.py +5 -10
  9. epub_translator/segment/utils.py +0 -16
  10. epub_translator/translation/__init__.py +2 -0
  11. epub_translator/{epub_transcode.py → translation/epub_transcode.py} +2 -2
  12. epub_translator/{punctuation.py → translation/punctuation.py} +1 -1
  13. epub_translator/{translator.py → translation/translator.py} +8 -6
  14. epub_translator/{xml_interrupter.py → translation/xml_interrupter.py} +52 -28
  15. epub_translator/xml/__init__.py +1 -1
  16. epub_translator/xml/inline.py +48 -2
  17. epub_translator/xml_translator/concurrency.py +52 -0
  18. epub_translator/xml_translator/score.py +164 -0
  19. epub_translator/xml_translator/stream_mapper.py +145 -114
  20. epub_translator/xml_translator/submitter.py +5 -5
  21. epub_translator/xml_translator/translator.py +12 -18
  22. {epub_translator-0.1.5.dist-info → epub_translator-0.1.7.dist-info}/METADATA +37 -9
  23. epub_translator-0.1.7.dist-info/RECORD +63 -0
  24. epub_translator/data/mmltex/README.md +0 -67
  25. epub_translator/data/mmltex/cmarkup.xsl +0 -1106
  26. epub_translator/data/mmltex/entities.xsl +0 -459
  27. epub_translator/data/mmltex/glayout.xsl +0 -222
  28. epub_translator/data/mmltex/mmltex.xsl +0 -36
  29. epub_translator/data/mmltex/scripts.xsl +0 -375
  30. epub_translator/data/mmltex/tables.xsl +0 -130
  31. epub_translator/data/mmltex/tokens.xsl +0 -328
  32. epub_translator-0.1.5.dist-info/RECORD +0 -68
  33. /epub_translator/{language.py → translation/language.py} +0 -0
  34. /epub_translator/xml/{firendly → friendly}/__init__.py +0 -0
  35. /epub_translator/xml/{firendly → friendly}/decoder.py +0 -0
  36. /epub_translator/xml/{firendly → friendly}/encoder.py +0 -0
  37. /epub_translator/xml/{firendly → friendly}/parser.py +0 -0
  38. /epub_translator/xml/{firendly → friendly}/tag.py +0 -0
  39. /epub_translator/xml/{firendly → friendly}/transform.py +0 -0
  40. {epub_translator-0.1.5.dist-info → epub_translator-0.1.7.dist-info}/LICENSE +0 -0
  41. {epub_translator-0.1.5.dist-info → epub_translator-0.1.7.dist-info}/WHEEL +0 -0
@@ -1,1106 +0,0 @@
1
- <?xml version='1.0' encoding="UTF-8"?>
2
- <xsl:stylesheet
3
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
- xmlns:m="http://www.w3.org/1998/Math/MathML"
5
- version='1.0'>
6
-
7
- <!-- ====================================================================== -->
8
- <!-- $Id: cmarkup.xsl,v 1.8 2003/06/10 12:24:04 shade33 Exp $
9
- This file is part of the XSLT MathML Library distribution.
10
- See ./README or http://www.raleigh.ru/MathML/mmltex for
11
- copyright and other information -->
12
- <!-- ====================================================================== -->
13
-
14
- <!-- 4.4.1.1 cn -->
15
- <xsl:template match="m:cn"><xsl:apply-templates/></xsl:template>
16
-
17
- <xsl:template match="m:cn[@type='complex-cartesian']">
18
- <xsl:apply-templates select="text()[1]"/>
19
- <xsl:text>+</xsl:text>
20
- <xsl:apply-templates select="text()[2]"/>
21
- <xsl:text>i</xsl:text>
22
- </xsl:template>
23
-
24
- <xsl:template match="m:cn[@type='rational']">
25
- <xsl:apply-templates select="text()[1]"/>
26
- <xsl:text>/</xsl:text>
27
- <xsl:apply-templates select="text()[2]"/>
28
- </xsl:template>
29
-
30
- <xsl:template match="m:cn[@type='integer' and @base!=10]">
31
- <xsl:apply-templates/>
32
- <xsl:text>_{</xsl:text><xsl:value-of select="@base"/><xsl:text>}</xsl:text>
33
- </xsl:template>
34
-
35
- <xsl:template match="m:cn[@type='complex-polar']">
36
- <xsl:apply-templates select="text()[1]"/>
37
- <xsl:text>e^{i </xsl:text>
38
- <xsl:apply-templates select="text()[2]"/>
39
- <xsl:text>}</xsl:text>
40
- </xsl:template>
41
-
42
- <xsl:template match="m:cn[@type='e-notation']">
43
- <xsl:apply-templates select="text()[1]"/>
44
- <xsl:text>E</xsl:text>
45
- <xsl:apply-templates select="text()[2]"/>
46
- </xsl:template>
47
-
48
- <!-- 4.4.1.1 ci 4.4.1.2 csymbol -->
49
- <xsl:template match="m:ci | m:csymbol">
50
- <xsl:choose>
51
- <xsl:when test="string-length(normalize-space(text()))>1">
52
- <xsl:text>\mathrm{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text>
53
- </xsl:when>
54
- <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
55
- </xsl:choose>
56
- </xsl:template>
57
-
58
- <!-- 4.4.2.1 apply 4.4.2.2 reln -->
59
- <xsl:template match="m:apply | m:reln">
60
- <xsl:apply-templates select="*[1]">
61
- <!-- <? -->
62
- <xsl:with-param name="p" select="10"/>
63
- </xsl:apply-templates>
64
- <!-- ?> -->
65
- <xsl:text>(</xsl:text>
66
- <xsl:for-each select="*[position()>1]">
67
- <xsl:apply-templates select="."/>
68
- <xsl:if test="not(position()=last())"><xsl:text>, </xsl:text></xsl:if>
69
- </xsl:for-each>
70
- <xsl:text>)</xsl:text>
71
- </xsl:template>
72
-
73
- <!-- 4.4.2.3 fn -->
74
- <xsl:template match="m:fn[m:apply[1]]"> <!-- for m:fn using default rule -->
75
- <xsl:text>(</xsl:text><xsl:apply-templates/><xsl:text>)</xsl:text>
76
- </xsl:template>
77
-
78
- <!-- 4.4.2.4 interval -->
79
- <xsl:template match="m:interval[*[2]]">
80
- <xsl:choose>
81
- <xsl:when test="@closure='open' or @closure='open-closed'">
82
- <xsl:text>\left(</xsl:text>
83
- </xsl:when>
84
- <xsl:otherwise><xsl:text>\left[</xsl:text></xsl:otherwise>
85
- </xsl:choose>
86
- <xsl:apply-templates select="*[1]"/>
87
- <xsl:text> , </xsl:text>
88
- <xsl:apply-templates select="*[2]"/>
89
- <xsl:choose>
90
- <xsl:when test="@closure='open' or @closure='closed-open'">
91
- <xsl:text>\right)</xsl:text>
92
- </xsl:when>
93
- <xsl:otherwise><xsl:text>\right]</xsl:text></xsl:otherwise>
94
- </xsl:choose>
95
- </xsl:template>
96
-
97
- <xsl:template match="m:interval">
98
- <xsl:text>\left\{</xsl:text><xsl:apply-templates/><xsl:text>\right\}</xsl:text>
99
- </xsl:template>
100
-
101
- <!-- 4.4.2.5 inverse -->
102
- <xsl:template match="m:apply[*[1][self::m:inverse]]">
103
- <xsl:apply-templates select="*[2]"/><xsl:text>^{(-1)}</xsl:text>
104
- </xsl:template>
105
-
106
- <!-- 4.4.2.6 sep 4.4.2.7 condition -->
107
- <xsl:template match="m:sep | m:condition"><xsl:apply-templates/></xsl:template>
108
-
109
- <!-- 4.4.2.9 lambda -->
110
- <xsl:template match="m:lambda">
111
- <xsl:apply-templates select="m:bvar/*"/>
112
- <xsl:text>\mapsto </xsl:text>
113
- <xsl:apply-templates select="*[last()]"/>
114
- <!-- Other variant
115
- <xsl:text>\mathrm{lambda}\: </xsl:text>
116
- <xsl:apply-templates select="m:bvar/*"/>
117
- <xsl:text>.\: </xsl:text>
118
- <xsl:apply-templates select="*[last()]"/> -->
119
- </xsl:template>
120
-
121
- <!-- 4.4.2.10 compose -->
122
- <xsl:template match="m:apply[*[1][self::m:compose]]">
123
- <xsl:param name="p" select="0"/>
124
- <xsl:call-template name="infix">
125
- <xsl:with-param name="this-p" select="1"/>
126
- <xsl:with-param name="p" select="$p"/>
127
- <xsl:with-param name="mo">\circ </xsl:with-param>
128
- </xsl:call-template>
129
- </xsl:template>
130
-
131
- <!-- 4.4.2.11 ident -->
132
- <xsl:template match="m:ident"><xsl:text>\mathrm{id}</xsl:text></xsl:template>
133
-
134
- <!-- 4.4.2.12 domain 4.4.2.13 codomain 4.4.2.14 image 4.4.3.21 arg 4.4.3.24 lcm
135
- 4.4.5.9 grad 4.4.5.10 curl 4.4.9.4 median 4.4.9.5 mode-->
136
- <xsl:template match="m:domain | m:codomain | m:image | m:arg | m:lcm | m:grad |
137
- m:curl | m:median | m:mode">
138
- <xsl:text>\mathop{\mathrm{</xsl:text>
139
- <xsl:value-of select="local-name()"/>
140
- <xsl:text>}}</xsl:text>
141
- </xsl:template>
142
-
143
- <!-- 4.4.2.15 domainofapplication -->
144
- <xsl:template match="m:domainofapplication"/>
145
-
146
- <!-- 4.4.2.16 piecewise -->
147
- <xsl:template match="m:piecewise">
148
- <xsl:text>\begin{cases}</xsl:text>
149
- <xsl:apply-templates select="m:piece"/>
150
- <xsl:apply-templates select="m:otherwise"/>
151
- <xsl:text>\end{cases}</xsl:text>
152
- </xsl:template>
153
-
154
- <xsl:template match="m:piece">
155
- <xsl:apply-templates select="*[1]"/>
156
- <xsl:text> &amp; \text{if $</xsl:text>
157
- <xsl:apply-templates select="*[2]"/>
158
- <xsl:text>$}</xsl:text>
159
- <xsl:if test="not(position()=last()) or ../m:otherwise"><xsl:text>\\ </xsl:text></xsl:if>
160
- </xsl:template>
161
-
162
- <xsl:template match="m:otherwise">
163
- <xsl:apply-templates select="*[1]"/>
164
- <xsl:text> &amp; \text{otherwise}</xsl:text>
165
- </xsl:template>
166
-
167
- <!-- 4.4.3.1 quotient -->
168
- <xsl:template match="m:apply[*[1][self::m:quotient]]">
169
- <xsl:text>\left\lfloor\frac{</xsl:text>
170
- <xsl:apply-templates select="*[2]"/>
171
- <xsl:text>}{</xsl:text>
172
- <xsl:apply-templates select="*[3]"/>
173
- <xsl:text>}\right\rfloor </xsl:text>
174
- </xsl:template>
175
-
176
- <!-- 4.4.3.2 factorial -->
177
- <xsl:template match="m:apply[*[1][self::m:factorial]]">
178
- <xsl:apply-templates select="*[2]">
179
- <xsl:with-param name="p" select="7"/>
180
- </xsl:apply-templates>
181
- <xsl:text>!</xsl:text>
182
- </xsl:template>
183
-
184
- <!-- 4.4.3.3 divide -->
185
- <xsl:template match="m:apply[*[1][self::m:divide]]">
186
- <xsl:param name="p" select="0"/>
187
- <xsl:param name="this-p" select="3"/>
188
- <xsl:if test="$this-p &lt; $p"><xsl:text>\left(</xsl:text></xsl:if>
189
- <xsl:text>\frac{</xsl:text>
190
- <xsl:apply-templates select="*[2]"/>
191
- <!-- <xsl:with-param name="p" select="$this-p"/>
192
- </xsl:apply-templates>-->
193
- <xsl:text>}{</xsl:text>
194
- <xsl:apply-templates select="*[3]"/>
195
- <!-- <xsl:with-param name="p" select="$this-p"/>
196
- </xsl:apply-templates>-->
197
- <xsl:text>}</xsl:text>
198
- <xsl:if test="$this-p &lt; $p"><xsl:text>\right)</xsl:text></xsl:if>
199
- </xsl:template>
200
-
201
- <!-- 4.4.3.4 max min -->
202
- <xsl:template match="m:apply[*[1][self::m:max or self::m:min]]">
203
- <xsl:text>\</xsl:text>
204
- <xsl:value-of select="local-name(*[1])"/>
205
- <xsl:text>\{</xsl:text>
206
- <xsl:choose>
207
- <xsl:when test="m:condition">
208
- <xsl:apply-templates select="*[last()]"/>
209
- <xsl:text>\mid </xsl:text>
210
- <xsl:apply-templates select="m:condition/node()"/>
211
- </xsl:when>
212
- <xsl:otherwise>
213
- <xsl:for-each select="*[position() &gt; 1]">
214
- <xsl:apply-templates select="."/>
215
- <xsl:if test="position() !=last()"><xsl:text> , </xsl:text></xsl:if>
216
- </xsl:for-each>
217
- </xsl:otherwise>
218
- </xsl:choose>
219
- <xsl:text>\}</xsl:text>
220
- </xsl:template>
221
-
222
- <!-- 4.4.3.5 minus-->
223
- <xsl:template match="m:apply[*[1][self::m:minus] and count(*)=2]">
224
- <xsl:text>-</xsl:text>
225
- <xsl:apply-templates select="*[2]">
226
- <xsl:with-param name="p" select="5"/>
227
- </xsl:apply-templates>
228
- </xsl:template>
229
-
230
- <xsl:template match="m:apply[*[1][self::m:minus] and count(*)&gt;2]">
231
- <xsl:param name="p" select="0"/>
232
- <xsl:call-template name="binary">
233
- <xsl:with-param name="mo">-</xsl:with-param>
234
- <xsl:with-param name="p" select="$p"/>
235
- <xsl:with-param name="this-p" select="2"/>
236
- </xsl:call-template>
237
- </xsl:template>
238
-
239
- <!-- 4.4.3.6 plus-->
240
- <xsl:template match="m:apply[*[1][self::m:plus]]">
241
- <xsl:param name="p" select="0"/>
242
- <xsl:if test="$p &gt; 2">
243
- <xsl:text>(</xsl:text>
244
- </xsl:if>
245
- <xsl:for-each select="*[position()&gt;1]">
246
- <xsl:if test="position() &gt; 1">
247
- <xsl:choose>
248
- <xsl:when test="self::m:apply[*[1][self::m:times] and
249
- *[2][self::m:apply/*[1][self::m:minus] or self::m:cn[not(m:sep) and
250
- (number(.) &lt; 0)]]]">-</xsl:when>
251
- <xsl:otherwise>+</xsl:otherwise>
252
- </xsl:choose>
253
- </xsl:if>
254
- <xsl:choose>
255
- <xsl:when test="self::m:apply[*[1][self::m:times] and
256
- *[2][self::m:cn[not(m:sep) and (number(.) &lt;0)]]]">
257
- <xsl:value-of select="-(*[2])"/>
258
- <xsl:apply-templates select=".">
259
- <xsl:with-param name="first" select="2"/>
260
- <xsl:with-param name="p" select="2"/>
261
- </xsl:apply-templates>
262
- </xsl:when>
263
- <xsl:when test="self::m:apply[*[1][self::m:times] and
264
- *[2][self::m:apply/*[1][self::m:minus]]]">
265
- <xsl:apply-templates select="./*[2]/*[2]"/>
266
- <xsl:apply-templates select=".">
267
- <xsl:with-param name="first" select="2"/>
268
- <xsl:with-param name="p" select="2"/>
269
- </xsl:apply-templates>
270
- </xsl:when>
271
- <xsl:otherwise>
272
- <xsl:apply-templates select=".">
273
- <xsl:with-param name="p" select="2"/>
274
- </xsl:apply-templates>
275
- </xsl:otherwise>
276
- </xsl:choose>
277
- </xsl:for-each>
278
- <xsl:if test="$p &gt; 2">
279
- <xsl:text>)</xsl:text>
280
- </xsl:if>
281
- </xsl:template>
282
-
283
- <!-- 4.4.3.7 power -->
284
- <xsl:template match="m:apply[*[1][self::m:power]]">
285
- <xsl:apply-templates select="*[2]">
286
- <xsl:with-param name="p" select="5"/>
287
- </xsl:apply-templates>
288
- <xsl:text>^{</xsl:text>
289
- <xsl:apply-templates select="*[3]">
290
- <xsl:with-param name="p" select="5"/>
291
- </xsl:apply-templates>
292
- <xsl:text>}</xsl:text>
293
- </xsl:template>
294
-
295
- <!-- 4.4.3.8 remainder -->
296
- <xsl:template match="m:apply[*[1][self::m:rem]]">
297
- <xsl:param name="p" select="0"/>
298
- <xsl:call-template name="binary">
299
- <xsl:with-param name="mo">\mod </xsl:with-param>
300
- <xsl:with-param name="p" select="$p"/>
301
- <xsl:with-param name="this-p" select="3"/>
302
- </xsl:call-template>
303
- </xsl:template>
304
-
305
- <!-- 4.4.3.9 times-->
306
- <xsl:template match="m:apply[*[1][self::m:times]]" name="times">
307
- <xsl:param name="p" select="0"/>
308
- <xsl:param name="first" select="1"/>
309
- <xsl:if test="$p &gt; 3"><xsl:text>(</xsl:text></xsl:if>
310
- <xsl:for-each select="*[position()&gt;1]">
311
- <xsl:if test="position() &gt; 1">
312
- <xsl:choose>
313
- <xsl:when test="self::m:cn">\times <!-- times --></xsl:when>
314
- <xsl:otherwise><!--invisible times--></xsl:otherwise>
315
- </xsl:choose>
316
- </xsl:if>
317
- <xsl:if test="position()&gt;= $first">
318
- <xsl:apply-templates select=".">
319
- <xsl:with-param name="p" select="3"/>
320
- </xsl:apply-templates>
321
- </xsl:if>
322
- </xsl:for-each>
323
- <xsl:if test="$p &gt; 3"><xsl:text>)</xsl:text></xsl:if>
324
- </xsl:template>
325
-
326
- <!-- 4.4.3.10 root -->
327
- <xsl:template match="m:apply[*[1][self::m:root]]">
328
- <xsl:text>\sqrt</xsl:text>
329
- <xsl:if test="m:degree!=2">
330
- <xsl:text>[</xsl:text>
331
- <xsl:apply-templates select="m:degree/*"/>
332
- <xsl:text>]</xsl:text>
333
- </xsl:if>
334
- <xsl:text>{</xsl:text>
335
- <xsl:apply-templates select="*[position()&gt;1 and not(self::m:degree)]"/>
336
- <xsl:text>}</xsl:text>
337
- </xsl:template>
338
-
339
- <!-- 4.4.3.11 gcd -->
340
- <xsl:template match="m:gcd"><xsl:text>\gcd </xsl:text></xsl:template>
341
-
342
- <!-- 4.4.3.12 and -->
343
- <xsl:template match="m:apply[*[1][self::m:and]]">
344
- <xsl:param name="p" select="0"/>
345
- <xsl:call-template name="infix">
346
- <xsl:with-param name="this-p" select="2"/>
347
- <xsl:with-param name="p" select="$p"/>
348
- <xsl:with-param name="mo">\land <!-- and --></xsl:with-param>
349
- </xsl:call-template>
350
- </xsl:template>
351
-
352
- <!-- 4.4.3.13 or -->
353
- <xsl:template match="m:apply[*[1][self::m:or]]">
354
- <xsl:param name="p" select="0"/>
355
- <xsl:call-template name="infix">
356
- <xsl:with-param name="this-p" select="3"/>
357
- <xsl:with-param name="p" select="$p"/>
358
- <xsl:with-param name="mo">\lor </xsl:with-param>
359
- </xsl:call-template>
360
- </xsl:template>
361
-
362
- <!-- 4.4.3.14 xor -->
363
- <xsl:template match="m:apply[*[1][self::m:xor]]">
364
- <xsl:param name="p" select="0"/>
365
- <xsl:call-template name="infix">
366
- <xsl:with-param name="this-p" select="3"/>
367
- <xsl:with-param name="p" select="$p"/>
368
- <xsl:with-param name="mo">\mathop{\mathrm{xor}}</xsl:with-param>
369
- </xsl:call-template>
370
- </xsl:template>
371
-
372
- <!-- 4.4.3.15 not -->
373
- <xsl:template match="m:apply[*[1][self::m:not]]">
374
- <xsl:text>\neg </xsl:text>
375
- <xsl:apply-templates select="*[2]">
376
- <xsl:with-param name="p" select="7"/>
377
- </xsl:apply-templates>
378
- </xsl:template>
379
-
380
- <!-- 4.4.3.16 implies -->
381
- <xsl:template match="m:apply[*[1][self::m:implies]] | m:reln[*[1][self::m:implies]]">
382
- <xsl:param name="p" select="0"/>
383
- <xsl:call-template name="binary">
384
- <xsl:with-param name="mo">\implies </xsl:with-param>
385
- <xsl:with-param name="p" select="$p"/>
386
- <xsl:with-param name="this-p" select="3"/>
387
- </xsl:call-template>
388
- </xsl:template>
389
-
390
- <!-- 4.4.3.17 forall 4.4.3.18 exists -->
391
- <xsl:template match="m:apply[*[1][self::m:forall or self::m:exists]]">
392
- <xsl:text>\</xsl:text>
393
- <xsl:value-of select="local-name(*[1])"/>
394
- <xsl:text> </xsl:text>
395
- <xsl:apply-templates select="m:bvar"/>
396
- <xsl:if test="m:condition">
397
- <xsl:text>, </xsl:text><xsl:apply-templates select="m:condition"/>
398
- </xsl:if>
399
- <xsl:if test="*[last()][local-name()!='condition'][local-name()!='bvar']">
400
- <xsl:text>\colon </xsl:text>
401
- <xsl:apply-templates select="*[last()]"/>
402
- </xsl:if>
403
- </xsl:template>
404
-
405
- <!-- 4.4.3.19 abs -->
406
- <xsl:template match="m:apply[*[1][self::m:abs]]">
407
- <xsl:text>\left|</xsl:text>
408
- <xsl:apply-templates select="*[2]"/>
409
- <xsl:text>\right|</xsl:text>
410
- </xsl:template>
411
-
412
- <!-- 4.4.3.20 conjugate -->
413
- <xsl:template match="m:apply[*[1][self::m:conjugate]]">
414
- <xsl:text>\overline{</xsl:text><xsl:apply-templates select="*[2]"/><xsl:text>}</xsl:text>
415
- </xsl:template>
416
-
417
- <!-- 4.4.3.22 real -->
418
- <xsl:template match="m:real"><xsl:text>\Re </xsl:text></xsl:template>
419
-
420
- <!-- 4.4.3.23 imaginary -->
421
- <xsl:template match="m:imaginary"><xsl:text>\Im </xsl:text></xsl:template>
422
-
423
- <!-- 4.4.3.25 floor -->
424
- <xsl:template match="m:apply[*[1][self::m:floor]]">
425
- <xsl:text>\lfloor </xsl:text>
426
- <xsl:apply-templates select="*[2]"/>
427
- <xsl:text>\rfloor </xsl:text>
428
- </xsl:template>
429
-
430
- <!-- 4.4.3.25 ceiling -->
431
- <xsl:template match="m:apply[*[1][self::m:ceiling]]">
432
- <xsl:text>\lceil </xsl:text>
433
- <xsl:apply-templates select="*[2]"/>
434
- <xsl:text>\rceil </xsl:text>
435
- </xsl:template>
436
-
437
- <!-- 4.4.4.1 eq -->
438
- <xsl:template match="m:apply[*[1][self::m:eq]] | m:reln[*[1][self::m:eq]]">
439
- <xsl:param name="p" select="0"/>
440
- <xsl:call-template name="infix">
441
- <xsl:with-param name="this-p" select="1"/>
442
- <xsl:with-param name="p" select="$p"/>
443
- <xsl:with-param name="mo">=</xsl:with-param>
444
- </xsl:call-template>
445
- </xsl:template>
446
-
447
- <!-- 4.4.4.2 neq -->
448
- <xsl:template match="m:apply[*[1][self::m:neq]] | m:reln[*[1][self::m:neq]]">
449
- <xsl:param name="p" select="0"/>
450
- <xsl:call-template name="infix">
451
- <xsl:with-param name="this-p" select="1"/>
452
- <xsl:with-param name="p" select="$p"/>
453
- <xsl:with-param name="mo">\neq </xsl:with-param>
454
- </xsl:call-template>
455
- </xsl:template>
456
-
457
- <!-- 4.4.4.3 gt -->
458
- <xsl:template match="m:apply[*[1][self::m:gt]] | m:reln[*[1][self::m:gt]]">
459
- <xsl:param name="p" select="0"/>
460
- <xsl:call-template name="infix">
461
- <xsl:with-param name="this-p" select="1"/>
462
- <xsl:with-param name="p" select="$p"/>
463
- <xsl:with-param name="mo">&gt; </xsl:with-param>
464
- </xsl:call-template>
465
- </xsl:template>
466
-
467
- <!-- 4.4.4.4 lt -->
468
- <xsl:template match="m:apply[*[1][self::m:lt]] | m:reln[*[1][self::m:lt]]">
469
- <xsl:param name="p" select="0"/>
470
- <xsl:call-template name="infix">
471
- <xsl:with-param name="this-p" select="1"/>
472
- <xsl:with-param name="p" select="$p"/>
473
- <xsl:with-param name="mo">&lt; </xsl:with-param>
474
- </xsl:call-template>
475
- </xsl:template>
476
-
477
- <!-- 4.4.4.5 geq -->
478
- <xsl:template match="m:apply[*[1][self::m:geq]] | m:reln[*[1][self::m:geq]]">
479
- <xsl:param name="p" select="0"/>
480
- <xsl:call-template name="infix">
481
- <xsl:with-param name="this-p" select="1"/>
482
- <xsl:with-param name="p" select="$p"/>
483
- <xsl:with-param name="mo">\ge </xsl:with-param>
484
- </xsl:call-template>
485
- </xsl:template>
486
-
487
- <!-- 4.4.4.6 leq -->
488
- <xsl:template match="m:apply[*[1][self::m:leq]] | m:reln[*[1][self::m:leq]]">
489
- <xsl:param name="p" select="0"/>
490
- <xsl:call-template name="infix">
491
- <xsl:with-param name="this-p" select="1"/>
492
- <xsl:with-param name="p" select="$p"/>
493
- <xsl:with-param name="mo">\le </xsl:with-param>
494
- </xsl:call-template>
495
- </xsl:template>
496
-
497
- <!-- 4.4.4.7 equivalent -->
498
- <xsl:template match="m:apply[*[1][self::m:equivalent]] | m:reln[*[1][self::m:equivalent]]">
499
- <xsl:param name="p" select="0"/>
500
- <xsl:call-template name="infix">
501
- <xsl:with-param name="this-p" select="1"/>
502
- <xsl:with-param name="p" select="$p"/>
503
- <xsl:with-param name="mo">\equiv </xsl:with-param>
504
- </xsl:call-template>
505
- </xsl:template>
506
-
507
- <!-- 4.4.4.8 approx -->
508
- <xsl:template match="m:apply[*[1][self::m:approx]] | m:reln[*[1][self::m:approx]]">
509
- <xsl:param name="p" select="0"/>
510
- <xsl:call-template name="infix">
511
- <xsl:with-param name="this-p" select="1"/>
512
- <xsl:with-param name="p" select="$p"/>
513
- <xsl:with-param name="mo">\approx </xsl:with-param>
514
- </xsl:call-template>
515
- </xsl:template>
516
-
517
- <!-- 4.4.4.9 factorof -->
518
- <xsl:template match="m:apply[*[1][self::m:factorof]] | m:reln[*[1][self::m:factorof]]">
519
- <xsl:param name="p" select="0"/>
520
- <xsl:call-template name="binary">
521
- <xsl:with-param name="mo"> | </xsl:with-param>
522
- <xsl:with-param name="p" select="$p"/>
523
- <xsl:with-param name="this-p" select="3"/>
524
- </xsl:call-template>
525
- </xsl:template>
526
-
527
- <!-- 4.4.5.1 int -->
528
- <xsl:template match="m:apply[*[1][self::m:int]]">
529
- <xsl:text>\int</xsl:text>
530
- <xsl:if test="m:lowlimit/*|m:interval/*[1]|m:condition/*">
531
- <xsl:text>_{</xsl:text>
532
- <xsl:apply-templates select="m:lowlimit/*|m:interval/*[1]|m:condition/*"/>
533
- <xsl:text>}</xsl:text>
534
- </xsl:if>
535
- <xsl:if test="m:uplimit/*|m:interval/*[2]">
536
- <xsl:text>^{</xsl:text>
537
- <xsl:apply-templates select="m:uplimit/*|m:interval/*[2]"/>
538
- <xsl:text>}</xsl:text>
539
- </xsl:if>
540
- <xsl:text> </xsl:text>
541
- <xsl:apply-templates select="*[last()]"/>
542
- <xsl:text>\,d </xsl:text>
543
- <xsl:apply-templates select="m:bvar"/>
544
- </xsl:template>
545
-
546
- <!-- 4.4.5.2 diff -->
547
- <xsl:template match="m:apply[*[1][self::m:diff] and m:ci and count(*)=2]" priority="2">
548
- <xsl:apply-templates select="*[2]"/>
549
- <xsl:text>^\prime </xsl:text>
550
- </xsl:template>
551
-
552
- <xsl:template match="m:apply[*[1][self::m:diff]]" priority="1">
553
- <xsl:text>\frac{</xsl:text>
554
- <xsl:choose>
555
- <xsl:when test="m:bvar/m:degree">
556
- <xsl:text>d^{</xsl:text>
557
- <xsl:apply-templates select="m:bvar/m:degree/node()"/>
558
- <xsl:text>}</xsl:text>
559
- <xsl:apply-templates select="*[last()]"/>
560
- <xsl:text>}{d</xsl:text>
561
- <xsl:apply-templates select="m:bvar/node()"/>
562
- <xsl:text>^{</xsl:text>
563
- <xsl:apply-templates select="m:bvar/m:degree/node()"/>
564
- <xsl:text>}</xsl:text>
565
- </xsl:when>
566
- <xsl:otherwise>
567
- <xsl:text>d </xsl:text>
568
- <xsl:apply-templates select="*[last()]"/>
569
- <xsl:text>}{d </xsl:text>
570
- <xsl:apply-templates select="m:bvar"/>
571
- </xsl:otherwise>
572
- </xsl:choose>
573
- <xsl:text>}</xsl:text>
574
- </xsl:template>
575
-
576
- <!-- 4.4.5.3 partialdiff -->
577
- <xsl:template match="m:apply[*[1][self::m:partialdiff] and m:list and m:ci and count(*)=3]" priority="2">
578
- <xsl:text>D_{</xsl:text>
579
- <xsl:for-each select="m:list[1]/*">
580
- <xsl:apply-templates select="."/>
581
- <xsl:if test="position()&lt;last()"><xsl:text>, </xsl:text></xsl:if>
582
- </xsl:for-each>
583
- <xsl:text>}</xsl:text>
584
- <xsl:apply-templates select="*[3]"/>
585
- </xsl:template>
586
-
587
- <xsl:template match="m:apply[*[1][self::m:partialdiff]]" priority="1">
588
- <xsl:text>\frac{\partial^{</xsl:text>
589
- <xsl:choose>
590
- <xsl:when test="m:degree">
591
- <xsl:apply-templates select="m:degree/node()"/>
592
- </xsl:when>
593
- <xsl:when test="m:bvar/m:degree[string(number(.))='NaN']">
594
- <xsl:for-each select="m:bvar/m:degree">
595
- <xsl:apply-templates select="node()"/>
596
- <xsl:if test="position()&lt;last()"><xsl:text>+</xsl:text></xsl:if>
597
- </xsl:for-each>
598
- <xsl:if test="count(m:bvar[not(m:degree)])&gt;0">
599
- <xsl:text>+</xsl:text>
600
- <xsl:value-of select="count(m:bvar[not(m:degree)])"/>
601
- </xsl:if>
602
- </xsl:when>
603
- <xsl:otherwise>
604
- <xsl:value-of select="sum(m:bvar/m:degree)+count(m:bvar[not(m:degree)])"/>
605
- </xsl:otherwise>
606
- </xsl:choose>
607
- <xsl:text>}</xsl:text>
608
- <xsl:apply-templates select="*[last()]"/>
609
- <xsl:text>}{</xsl:text>
610
- <xsl:for-each select="m:bvar">
611
- <xsl:text>\partial </xsl:text>
612
- <xsl:apply-templates select="node()"/>
613
- <xsl:if test="m:degree">
614
- <xsl:text>^{</xsl:text>
615
- <xsl:apply-templates select="m:degree/node()"/>
616
- <xsl:text>}</xsl:text>
617
- </xsl:if>
618
- </xsl:for-each>
619
- <xsl:text>}</xsl:text>
620
- </xsl:template>
621
-
622
- <!-- 4.4.2.8 declare 4.4.5.4 lowlimit 4.4.5.5 uplimit 4.4.5.7 degree 4.4.9.5 momentabout -->
623
- <xsl:template match="m:declare | m:lowlimit | m:uplimit | m:degree | m:momentabout"/>
624
-
625
- <!-- 4.4.5.6 bvar-->
626
- <xsl:template match="m:bvar">
627
- <xsl:apply-templates/>
628
- <xsl:if test="following-sibling::m:bvar"><xsl:text>, </xsl:text></xsl:if>
629
- </xsl:template>
630
-
631
- <!-- 4.4.5.8 divergence-->
632
- <xsl:template match="m:divergence"><xsl:text>\mathop{\mathrm{div}}</xsl:text></xsl:template>
633
-
634
- <!-- 4.4.5.11 laplacian-->
635
- <xsl:template match="m:laplacian"><xsl:text>\nabla^2 </xsl:text></xsl:template>
636
-
637
- <!-- 4.4.6.1 set -->
638
- <xsl:template match="m:set">
639
- <xsl:text>\{</xsl:text><xsl:call-template name="set"/><xsl:text>\}</xsl:text>
640
- </xsl:template>
641
-
642
- <!-- 4.4.6.2 list -->
643
- <xsl:template match="m:list">
644
- <xsl:text>\left[</xsl:text><xsl:call-template name="set"/><xsl:text>\right]</xsl:text>
645
- </xsl:template>
646
-
647
- <xsl:template name="set">
648
- <xsl:choose>
649
- <xsl:when test="m:condition">
650
- <xsl:apply-templates select="m:bvar/*[not(self::bvar or self::condition)]"/>
651
- <xsl:text>\colon </xsl:text>
652
- <xsl:apply-templates select="m:condition/node()"/>
653
- </xsl:when>
654
- <xsl:otherwise>
655
- <xsl:for-each select="*">
656
- <xsl:apply-templates select="."/>
657
- <xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
658
- </xsl:for-each>
659
- </xsl:otherwise>
660
- </xsl:choose>
661
- </xsl:template>
662
-
663
- <!-- 4.4.6.3 union -->
664
- <xsl:template match="m:apply[*[1][self::m:union]]">
665
- <xsl:param name="p" select="0"/>
666
- <xsl:call-template name="infix">
667
- <xsl:with-param name="this-p" select="2"/>
668
- <xsl:with-param name="p" select="$p"/>
669
- <xsl:with-param name="mo">\cup </xsl:with-param>
670
- </xsl:call-template>
671
- </xsl:template>
672
-
673
- <!-- 4.4.6.4 intersect -->
674
- <xsl:template match="m:apply[*[1][self::m:intersect]]">
675
- <xsl:param name="p" select="0"/>
676
- <xsl:call-template name="infix">
677
- <xsl:with-param name="this-p" select="3"/>
678
- <xsl:with-param name="p" select="$p"/>
679
- <xsl:with-param name="mo">\cap </xsl:with-param>
680
- </xsl:call-template>
681
- </xsl:template>
682
-
683
- <!-- 4.4.6.5 in -->
684
- <xsl:template match="m:apply[*[1][self::m:in]] | m:reln[*[1][self::m:in]]">
685
- <xsl:param name="p" select="0"/>
686
- <xsl:call-template name="binary">
687
- <xsl:with-param name="mo">\in </xsl:with-param>
688
- <xsl:with-param name="p" select="$p"/>
689
- <xsl:with-param name="this-p" select="3"/>
690
- </xsl:call-template>
691
- </xsl:template>
692
-
693
- <!-- 4.4.6.6 notin -->
694
- <xsl:template match="m:apply[*[1][self::m:notin]] | m:reln[*[1][self::m:notin]]">
695
- <xsl:param name="p" select="0"/>
696
- <xsl:call-template name="binary">
697
- <xsl:with-param name="mo">\notin </xsl:with-param>
698
- <xsl:with-param name="p" select="$p"/>
699
- <xsl:with-param name="this-p" select="3"/>
700
- </xsl:call-template>
701
- </xsl:template>
702
-
703
- <!-- 4.4.6.7 subset -->
704
- <xsl:template match="m:apply[*[1][self::m:subset]] | m:reln[*[1][self::m:subset]]">
705
- <xsl:param name="p" select="0"/>
706
- <xsl:call-template name="infix">
707
- <xsl:with-param name="this-p" select="2"/>
708
- <xsl:with-param name="p" select="$p"/>
709
- <xsl:with-param name="mo">\subseteq </xsl:with-param>
710
- </xsl:call-template>
711
- </xsl:template>
712
-
713
- <!-- 4.4.6.8 prsubset -->
714
- <xsl:template match="m:apply[*[1][self::m:prsubset]] | m:reln[*[1][self::m:prsubset]]">
715
- <xsl:param name="p" select="0"/>
716
- <xsl:call-template name="infix">
717
- <xsl:with-param name="this-p" select="2"/>
718
- <xsl:with-param name="p" select="$p"/>
719
- <xsl:with-param name="mo">\subset </xsl:with-param>
720
- </xsl:call-template>
721
- </xsl:template>
722
-
723
- <!-- 4.4.6.9 notsubset -->
724
- <xsl:template match="m:apply[*[1][self::m:notsubset]] | m:reln[*[1][self::m:notsubset]]">
725
- <xsl:param name="p" select="0"/>
726
- <xsl:call-template name="binary">
727
- <xsl:with-param name="this-p" select="2"/>
728
- <xsl:with-param name="p" select="$p"/>
729
- <xsl:with-param name="mo">\nsubseteq </xsl:with-param>
730
- </xsl:call-template>
731
- </xsl:template>
732
-
733
- <!-- 4.4.6.10 notprsubset -->
734
- <xsl:template match="m:apply[*[1][self::m:notprsubset]] | m:reln[*[1][self::m:notprsubset]]">
735
- <xsl:param name="p" select="0"/>
736
- <xsl:call-template name="binary">
737
- <xsl:with-param name="this-p" select="2"/>
738
- <xsl:with-param name="p" select="$p"/>
739
- <xsl:with-param name="mo">\not\subset </xsl:with-param>
740
- </xsl:call-template>
741
- </xsl:template>
742
-
743
- <!-- 4.4.6.11 setdiff -->
744
- <xsl:template match="m:apply[*[1][self::m:setdiff]]">
745
- <xsl:param name="p" select="0"/>
746
- <xsl:call-template name="binary">
747
- <xsl:with-param name="this-p" select="2"/>
748
- <xsl:with-param name="p" select="$p"/>
749
- <xsl:with-param name="mo">\setminus </xsl:with-param>
750
- </xsl:call-template>
751
- </xsl:template>
752
-
753
- <!-- 4.4.6.12 card -->
754
- <xsl:template match="m:apply[*[1][self::m:card]]">
755
- <xsl:text>|</xsl:text>
756
- <xsl:apply-templates select="*[2]"/>
757
- <xsl:text>|</xsl:text>
758
- </xsl:template>
759
-
760
- <!-- 4.4.6.13 cartesianproduct 4.4.10.6 vectorproduct -->
761
- <xsl:template match="m:apply[*[1][self::m:cartesianproduct or self::m:vectorproduct]]">
762
- <xsl:param name="p" select="0"/>
763
- <xsl:call-template name="infix">
764
- <xsl:with-param name="this-p" select="2"/>
765
- <xsl:with-param name="p" select="$p"/>
766
- <xsl:with-param name="mo">\times </xsl:with-param>
767
- </xsl:call-template>
768
- </xsl:template>
769
-
770
- <xsl:template
771
- match="m:apply[*[1][self::m:cartesianproduct][count(following-sibling::m:reals)=count(following-sibling::*)]]"
772
- priority="2">
773
- <xsl:apply-templates select="*[2]">
774
- <xsl:with-param name="p" select="5"/>
775
- </xsl:apply-templates>
776
- <xsl:text>^{</xsl:text>
777
- <xsl:value-of select="count(*)-1"/>
778
- <xsl:text>}</xsl:text>
779
- </xsl:template>
780
-
781
- <!-- 4.4.7.1 sum -->
782
- <xsl:template match="m:apply[*[1][self::m:sum]]">
783
- <xsl:text>\sum</xsl:text><xsl:call-template name="series"/>
784
- </xsl:template>
785
-
786
- <!-- 4.4.7.2 product -->
787
- <xsl:template match="m:apply[*[1][self::m:product]]">
788
- <xsl:text>\prod</xsl:text><xsl:call-template name="series"/>
789
- </xsl:template>
790
-
791
- <xsl:template name="series">
792
- <xsl:if test="m:lowlimit/*|m:interval/*[1]|m:condition/*">
793
- <xsl:text>_{</xsl:text>
794
- <xsl:if test="not(m:condition)">
795
- <xsl:apply-templates select="m:bvar"/>
796
- <xsl:text>=</xsl:text>
797
- </xsl:if>
798
- <xsl:apply-templates select="m:lowlimit/*|m:interval/*[1]|m:condition/*"/>
799
- <xsl:text>}</xsl:text>
800
- </xsl:if>
801
- <xsl:if test="m:uplimit/*|m:interval/*[2]">
802
- <xsl:text>^{</xsl:text>
803
- <xsl:apply-templates select="m:uplimit/*|m:interval/*[2]"/>
804
- <xsl:text>}</xsl:text>
805
- </xsl:if>
806
- <xsl:text> </xsl:text>
807
- <xsl:apply-templates select="*[last()]"/>
808
- </xsl:template>
809
-
810
- <!-- 4.4.7.3 limit -->
811
- <xsl:template match="m:apply[*[1][self::m:limit]]">
812
- <xsl:text>\lim_{</xsl:text>
813
- <xsl:apply-templates select="m:lowlimit|m:condition/*"/>
814
- <xsl:text>}</xsl:text>
815
- <xsl:apply-templates select="*[last()]"/>
816
- </xsl:template>
817
-
818
- <xsl:template match="m:apply[m:limit]/m:lowlimit" priority="3">
819
- <xsl:apply-templates select="../m:bvar/node()"/>
820
- <xsl:text>\to </xsl:text>
821
- <xsl:apply-templates/>
822
- </xsl:template>
823
-
824
- <!-- 4.4.7.4 tendsto -->
825
- <xsl:template match="m:apply[*[1][self::m:tendsto]] | m:reln[*[1][self::m:tendsto]]">
826
- <xsl:param name="p"/>
827
- <xsl:call-template name="binary">
828
- <xsl:with-param name="this-p" select="2"/>
829
- <xsl:with-param name="p" select="$p"/>
830
- <xsl:with-param name="mo">
831
- <xsl:choose>
832
- <xsl:when test="*[1][@type='above']">\searrow </xsl:when>
833
- <xsl:when test="*[1][@type='below']">\nearrow </xsl:when>
834
- <xsl:when test="*[1][@type='two-sided']">\rightarrow </xsl:when>
835
- <xsl:otherwise>\to </xsl:otherwise>
836
- </xsl:choose>
837
- </xsl:with-param>
838
- </xsl:call-template>
839
- </xsl:template>
840
-
841
- <!-- 4.4.8.1 common tringonometric functions 4.4.8.3 natural logarithm -->
842
- <xsl:template match="m:apply[*[1][
843
- self::m:sin or self::m:cos or self::m:tan or self::m:sec or
844
- self::m:csc or self::m:cot or self::m:sinh or self::m:cosh or
845
- self::m:tanh or self::m:coth or self::m:arcsin or self::m:arccos or
846
- self::m:arctan or self::m:ln]]">
847
- <xsl:text>\</xsl:text>
848
- <xsl:value-of select="local-name(*[1])"/>
849
- <xsl:text> </xsl:text>
850
- <xsl:apply-templates select="*[2]">
851
- <xsl:with-param name="p" select="7"/>
852
- </xsl:apply-templates>
853
- </xsl:template>
854
-
855
- <xsl:template match="m:sin | m:cos | m:tan | m:sec | m:csc |
856
- m:cot | m:sinh | m:cosh | m:tanh | m:coth |
857
- m:arcsin | m:arccos | m:arctan | m:ln">
858
- <xsl:text>\</xsl:text>
859
- <xsl:value-of select="local-name(.)"/>
860
- <xsl:text> </xsl:text>
861
- </xsl:template>
862
-
863
- <xsl:template match="m:apply[*[1][
864
- self::m:sech or self::m:csch or self::m:arccosh or
865
- self::m:arccot or self::m:arccoth or self::m:arccsc or
866
- self::m:arccsch or self::m:arcsec or self::m:arcsech or
867
- self::m:arcsinh or self::m:arctanh]]">
868
- <xsl:text>\mathrm{</xsl:text>
869
- <xsl:value-of select="local-name(*[1])"/>
870
- <xsl:text>\,}</xsl:text>
871
- <xsl:apply-templates select="*[2]">
872
- <xsl:with-param name="p" select="7"/>
873
- </xsl:apply-templates>
874
- </xsl:template>
875
-
876
- <xsl:template match="m:sech | m:csch | m:arccosh | m:arccot |
877
- m:arccoth | m:arccsc |m:arccsch |m:arcsec |
878
- m:arcsech | m:arcsinh | m:arctanh">
879
- <xsl:text>\mathrm{</xsl:text>
880
- <xsl:value-of select="local-name(.)"/>
881
- <xsl:text>}</xsl:text>
882
- </xsl:template>
883
-
884
- <!-- 4.4.8.2 exp -->
885
- <xsl:template match="m:apply[*[1][self::m:exp]]">
886
- <xsl:text>e^{</xsl:text><xsl:apply-templates select="*[2]"/><xsl:text>}</xsl:text>
887
- </xsl:template>
888
-
889
- <!-- 4.4.8.4 log -->
890
- <xsl:template match="m:apply[*[1][self::m:log]]">
891
- <xsl:text>\lg </xsl:text>
892
- <xsl:apply-templates select="*[last()]">
893
- <xsl:with-param name="p" select="7"/>
894
- </xsl:apply-templates>
895
- </xsl:template>
896
-
897
- <xsl:template match="m:apply[*[1][self::m:log] and m:logbase != 10]">
898
- <xsl:text>\log_{</xsl:text>
899
- <xsl:apply-templates select="m:logbase/node()"/>
900
- <xsl:text>}</xsl:text>
901
- <xsl:apply-templates select="*[last()]">
902
- <xsl:with-param name="p" select="7"/>
903
- </xsl:apply-templates>
904
- </xsl:template>
905
-
906
- <!-- 4.4.9.1 mean -->
907
- <xsl:template match="m:apply[*[1][self::m:mean]]">
908
- <xsl:text>\langle </xsl:text>
909
- <xsl:for-each select="*[position()&gt;1]">
910
- <xsl:apply-templates select="."/>
911
- <xsl:if test="position() !=last()"><xsl:text>, </xsl:text></xsl:if>
912
- </xsl:for-each>
913
- <xsl:text>\rangle </xsl:text>
914
- </xsl:template>
915
-
916
- <!-- 4.4.9.2 sdef -->
917
- <xsl:template match="m:sdev"><xsl:text>\sigma </xsl:text></xsl:template>
918
-
919
- <!-- 4.4.9.3 variance -->
920
- <xsl:template match="m:apply[*[1][self::m:variance]]">
921
- <xsl:text>\sigma(</xsl:text>
922
- <xsl:apply-templates select="*[2]"/>
923
- <xsl:text>)^2</xsl:text>
924
- </xsl:template>
925
-
926
- <!-- 4.4.9.5 moment -->
927
- <xsl:template match="m:apply[*[1][self::m:moment]]">
928
- <xsl:text>\langle </xsl:text>
929
- <xsl:apply-templates select="*[last()]"/>
930
- <xsl:text>^{</xsl:text>
931
- <xsl:apply-templates select="m:degree/node()"/>
932
- <xsl:text>}\rangle</xsl:text>
933
- <xsl:if test="m:momentabout">
934
- <xsl:text>_{</xsl:text>
935
- <xsl:apply-templates select="m:momentabout/node()"/>
936
- <xsl:text>}</xsl:text>
937
- </xsl:if>
938
- <xsl:text> </xsl:text>
939
- </xsl:template>
940
-
941
- <!-- 4.4.10.1 vector -->
942
- <xsl:template match="m:vector">
943
- <xsl:text>\left(\begin{array}{c}</xsl:text>
944
- <xsl:for-each select="*">
945
- <xsl:apply-templates select="."/>
946
- <xsl:if test="position()!=last()"><xsl:text>\\ </xsl:text></xsl:if>
947
- </xsl:for-each>
948
- <xsl:text>\end{array}\right)</xsl:text>
949
- </xsl:template>
950
-
951
- <!-- 4.4.10.2 matrix -->
952
- <xsl:template match="m:matrix">
953
- <xsl:text>\begin{pmatrix}</xsl:text>
954
- <xsl:apply-templates/>
955
- <xsl:text>\end{pmatrix}</xsl:text>
956
- </xsl:template>
957
-
958
- <!-- 4.4.10.3 matrixrow -->
959
- <xsl:template match="m:matrixrow">
960
- <xsl:for-each select="*">
961
- <xsl:apply-templates select="."/>
962
- <xsl:if test="position()!=last()"><xsl:text> &amp; </xsl:text></xsl:if>
963
- </xsl:for-each>
964
- <xsl:if test="position()!=last()"><xsl:text>\\ </xsl:text></xsl:if>
965
- </xsl:template>
966
-
967
- <!-- 4.4.10.4 determinant -->
968
- <xsl:template match="m:apply[*[1][self::m:determinant]]">
969
- <xsl:text>\det </xsl:text>
970
- <xsl:apply-templates select="*[2]">
971
- <xsl:with-param name="p" select="7"/>
972
- </xsl:apply-templates>
973
- </xsl:template>
974
-
975
- <xsl:template match="m:apply[*[1][self::m:determinant]][*[2][self::m:matrix]]" priority="2">
976
- <xsl:text>\begin{vmatrix}</xsl:text>
977
- <xsl:apply-templates select="m:matrix/*"/>
978
- <xsl:text>\end{vmatrix}</xsl:text>
979
- </xsl:template>
980
-
981
- <!-- 4.4.10.5 transpose -->
982
- <xsl:template match="m:apply[*[1][self::m:transpose]]">
983
- <xsl:apply-templates select="*[2]">
984
- <xsl:with-param name="p" select="7"/>
985
- </xsl:apply-templates>
986
- <xsl:text>^T</xsl:text>
987
- </xsl:template>
988
-
989
- <!-- 4.4.10.6 selector -->
990
- <xsl:template match="m:apply[*[1][self::m:selector]]">
991
- <xsl:apply-templates select="*[2]">
992
- <xsl:with-param name="p" select="7"/>
993
- </xsl:apply-templates>
994
- <xsl:text>_{</xsl:text>
995
- <xsl:for-each select="*[position()&gt;2]">
996
- <xsl:apply-templates select="."/>
997
- <xsl:if test="position() !=last()"><xsl:text>, </xsl:text></xsl:if>
998
- </xsl:for-each>
999
- <xsl:text>}</xsl:text>
1000
- </xsl:template>
1001
-
1002
- <!-- 4.4.10.8 scalarproduct -->
1003
- <xsl:template match="m:apply[*[1][self::m:scalarproduct]]">
1004
- <xsl:param name="p" select="0"/>
1005
- <xsl:call-template name="infix">
1006
- <xsl:with-param name="this-p" select="2"/>
1007
- <xsl:with-param name="p" select="$p"/>
1008
- <xsl:with-param name="mo">\cdot </xsl:with-param>
1009
- </xsl:call-template>
1010
- </xsl:template>
1011
-
1012
- <!-- 4.4.10.9 outerproduct -->
1013
- <xsl:template match="m:apply[*[1][self::m:outerproduct]]">
1014
- <xsl:param name="p" select="0"/>
1015
- <xsl:call-template name="infix">
1016
- <xsl:with-param name="this-p" select="2"/>
1017
- <xsl:with-param name="p" select="$p"/>
1018
- <xsl:with-param name="mo">\otimes </xsl:with-param>
1019
- </xsl:call-template>
1020
- </xsl:template>
1021
-
1022
- <!-- 4.4.11.2 semantics -->
1023
- <xsl:template match="m:semantics"><xsl:apply-templates select="*[1]"/></xsl:template>
1024
-
1025
- <xsl:template match="m:semantics[m:annotation/@encoding='TeX']">
1026
- <xsl:apply-templates select="m:annotation[@encoding='TeX']/node()"/>
1027
- </xsl:template>
1028
-
1029
- <!-- 4.4.12.1 integers -->
1030
- <xsl:template match="m:integers"><xsl:text>\mathbb{Z}</xsl:text></xsl:template>
1031
-
1032
- <!-- 4.4.12.2 reals -->
1033
- <xsl:template match="m:reals"><xsl:text>\mathbb{R}</xsl:text></xsl:template>
1034
-
1035
- <!-- 4.4.12.3 rationals -->
1036
- <xsl:template match="m:rationals"><xsl:text>\mathbb{Q}</xsl:text></xsl:template>
1037
-
1038
- <!-- 4.4.12.4 naturalnumbers -->
1039
- <xsl:template match="m:naturalnumbers"><xsl:text>\mathbb{N}</xsl:text></xsl:template>
1040
-
1041
- <!-- 4.4.12.5 complexes -->
1042
- <xsl:template match="m:complexes"><xsl:text>\mathbb{C}</xsl:text></xsl:template>
1043
-
1044
- <!-- 4.4.12.6 primes -->
1045
- <xsl:template match="m:primes"><xsl:text>\mathbb{P}</xsl:text></xsl:template>
1046
-
1047
- <!-- 4.4.12.7 exponentiale -->
1048
- <xsl:template match="m:exponentiale"><xsl:text>e</xsl:text></xsl:template>
1049
-
1050
- <!-- 4.4.12.8 imaginaryi -->
1051
- <xsl:template match="m:imaginaryi"><xsl:text>i</xsl:text></xsl:template>
1052
-
1053
- <!-- 4.4.12.9 notanumber -->
1054
- <xsl:template match="m:notanumber"><xsl:text>NaN</xsl:text></xsl:template>
1055
-
1056
- <!-- 4.4.12.10 true -->
1057
- <xsl:template match="m:true"><xsl:text>\mbox{true}</xsl:text></xsl:template>
1058
-
1059
- <!-- 4.4.12.11 false -->
1060
- <xsl:template match="m:false"><xsl:text>\mbox{false}</xsl:text></xsl:template>
1061
-
1062
- <!-- 4.4.12.12 emptyset -->
1063
- <xsl:template match="m:emptyset"><xsl:text>\emptyset </xsl:text></xsl:template>
1064
-
1065
- <!-- 4.4.12.13 pi -->
1066
- <xsl:template match="m:pi"><xsl:text>\pi </xsl:text></xsl:template>
1067
-
1068
- <!-- 4.4.12.14 eulergamma -->
1069
- <xsl:template match="m:eulergamma"><xsl:text>\gamma </xsl:text></xsl:template>
1070
-
1071
- <!-- 4.4.12.15 infinity -->
1072
- <xsl:template match="m:infinity"><xsl:text>\infty </xsl:text></xsl:template>
1073
-
1074
- <!-- ****************************** -->
1075
- <xsl:template name="infix" >
1076
- <xsl:param name="mo"/>
1077
- <xsl:param name="p" select="0"/>
1078
- <xsl:param name="this-p" select="0"/>
1079
- <xsl:if test="$this-p &lt; $p"><xsl:text>(</xsl:text></xsl:if>
1080
- <xsl:for-each select="*[position()&gt;1]">
1081
- <xsl:if test="position() &gt; 1">
1082
- <xsl:copy-of select="$mo"/>
1083
- </xsl:if>
1084
- <xsl:apply-templates select=".">
1085
- <xsl:with-param name="p" select="$this-p"/>
1086
- </xsl:apply-templates>
1087
- </xsl:for-each>
1088
- <xsl:if test="$this-p &lt; $p"><xsl:text>)</xsl:text></xsl:if>
1089
- </xsl:template>
1090
-
1091
- <xsl:template name="binary" >
1092
- <xsl:param name="mo"/>
1093
- <xsl:param name="p" select="0"/>
1094
- <xsl:param name="this-p" select="0"/>
1095
- <xsl:if test="$this-p &lt; $p"><xsl:text>(</xsl:text></xsl:if>
1096
- <xsl:apply-templates select="*[2]">
1097
- <xsl:with-param name="p" select="$this-p"/>
1098
- </xsl:apply-templates>
1099
- <xsl:value-of select="$mo"/>
1100
- <xsl:apply-templates select="*[3]">
1101
- <xsl:with-param name="p" select="$this-p"/>
1102
- </xsl:apply-templates>
1103
- <xsl:if test="$this-p &lt; $p"><xsl:text>)</xsl:text></xsl:if>
1104
- </xsl:template>
1105
-
1106
- </xsl:stylesheet>