html2doc 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3754 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Beta Version 070708 --><xsl:stylesheet xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
- xmlns:mml="http://www.w3.org/1998/Math/MathML"
5
- xmlns="http://www.w3.org/1998/Math/MathML"
6
- xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
7
- version="1.0"
8
- >
9
- <!--
10
- exclude-result-prefixes="mml m w">
11
- -->
12
- <xsl:output method="xml" encoding="UTF-8"/>
13
-
14
-
15
- <xsl:variable name="StrUCAlphabet">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
16
- <xsl:variable name="StrLCAlphabet">abcdefghijklmnopqrstuvwxyz</xsl:variable>
17
-
18
-
19
- <xsl:template match="/">
20
- <oMath>
21
- <xsl:apply-templates mode="mml" />
22
- </oMath>
23
- </xsl:template>
24
-
25
- <!-- %%Template: SReplace
26
-
27
- Replace all occurences of sOrig in sInput with sReplacement
28
- and return the resulting string. -->
29
- <xsl:template name="SReplace">
30
- <xsl:param name="sInput"/>
31
- <xsl:param name="sOrig"/>
32
- <xsl:param name="sReplacement"/>
33
-
34
- <xsl:choose>
35
- <xsl:when test="not(contains($sInput, $sOrig))">
36
- <xsl:value-of select="$sInput"/>
37
- </xsl:when>
38
- <xsl:otherwise>
39
- <xsl:variable name="sBefore" select="substring-before($sInput, $sOrig)"/>
40
- <xsl:variable name="sAfter" select="substring-after($sInput, $sOrig)"/>
41
- <xsl:variable name="sAfterProcessed">
42
- <xsl:call-template name="SReplace">
43
- <xsl:with-param name="sInput" select="$sAfter"/>
44
- <xsl:with-param name="sOrig" select="$sOrig"/>
45
- <xsl:with-param name="sReplacement" select="$sReplacement"/>
46
- </xsl:call-template>
47
- </xsl:variable>
48
-
49
- <xsl:value-of select="concat($sBefore, concat($sReplacement, $sAfterProcessed))"/>
50
- </xsl:otherwise>
51
- </xsl:choose>
52
- </xsl:template>
53
-
54
- <!-- %%Template: OutputText
55
-
56
- Post processing on the string given and otherwise do
57
- a xsl:value-of on it -->
58
- <xsl:template name="OutputText">
59
- <xsl:param name="sInput"/>
60
-
61
- <!-- Add local Variable as you add new post processing tasks -->
62
-
63
- <!-- 1. Remove any unwanted characters -->
64
- <xsl:variable name="sCharStrip">
65
- <xsl:value-of select="translate($sInput, '⁢​', '')"/>
66
- </xsl:variable>
67
-
68
- <!-- 2. Replace any characters as needed -->
69
- <!-- Replace &#x2A75; <-> == -->
70
- <xsl:variable name="sCharReplace">
71
- <xsl:call-template name="SReplace">
72
- <xsl:with-param name="sInput" select="$sCharStrip"/>
73
- <xsl:with-param name="sOrig" select="'⩵'"/>
74
- <xsl:with-param name="sReplacement" select="'=='"/>
75
- </xsl:call-template>
76
- </xsl:variable>
77
-
78
- <!-- Finally, return the last value -->
79
- <xsl:value-of select="$sCharReplace"/>
80
- </xsl:template>
81
-
82
-
83
- <!-- Template that determines whether or the given node
84
- ndCur is a token element that doesn't have an mglyph as
85
- a child.
86
- -->
87
- <xsl:template name="FNonGlyphToken">
88
- <xsl:param name="ndCur" select="."/>
89
- <xsl:choose>
90
- <xsl:when test="$ndCur/self::mml:mi[not(child::mml:mglyph)] | $ndCur/self::mml:mn[not(child::mml:mglyph)] | $ndCur/self::mml:mo[not(child::mml:mglyph)] | $ndCur/self::mml:ms[not(child::mml:mglyph)] | $ndCur/self::mml:mtext[not(child::mml:mglyph)]">1</xsl:when>
91
- <xsl:otherwise>0</xsl:otherwise>
92
- </xsl:choose>
93
- </xsl:template>
94
-
95
-
96
- <!-- Template used to determine if the current token element (ndCur) is the beginning of a run.
97
- A token element is the beginning of if:
98
-
99
- the count of preceding elements is 0
100
- or
101
- the directory preceding element is not a non-glyph token.
102
- -->
103
- <xsl:template name="FStartOfRun">
104
- <xsl:param name="ndCur" select="."/>
105
- <xsl:variable name="fPrecSibNonGlyphToken">
106
- <xsl:call-template name="FNonGlyphToken">
107
- <xsl:with-param name="ndCur" select="$ndCur/preceding-sibling::*[1]"/>
108
- </xsl:call-template>
109
- </xsl:variable>
110
- <xsl:choose>
111
- <xsl:when test="count($ndCur/preceding-sibling::*)=0 or $fPrecSibNonGlyphToken=0">1</xsl:when>
112
- <xsl:otherwise>0</xsl:otherwise>
113
- </xsl:choose>
114
- </xsl:template>
115
-
116
- <!-- Template that determines if ndCur is the argument of an nary expression.
117
-
118
- ndCur is the argument of an nary expression if:
119
-
120
- 1. The preceding sibling is one of the following: munder, mover, msub, msup, munder, msubsup, munderover
121
- and
122
- 2. The preceding sibling's child is an nary char as specified by the template "isNary"
123
- -->
124
- <xsl:template name="FIsNaryArgument">
125
- <xsl:param name="ndCur" select="."/>
126
-
127
- <xsl:variable name="fNary">
128
- <xsl:call-template name="isNary">
129
- <xsl:with-param name="ndCur" select="$ndCur/preceding-sibling::*[1]/child::*[1]"/>
130
- </xsl:call-template>
131
- </xsl:variable>
132
- <xsl:choose>
133
- <xsl:when test="preceding-sibling::*[1][self::mml:munder or self::mml:mover or self::mml:munderover or self::mml:msub or self::mml:msup or self::mml:msubsup] and $fNary='true'">1</xsl:when>
134
- <xsl:otherwise>0</xsl:otherwise>
135
- </xsl:choose>
136
- </xsl:template>
137
-
138
- <!-- %%Template: mml:mrow | mml:mstyle
139
-
140
- if this row is the next sibling of an n-ary (i.e. any of
141
- mover, munder, munderover, msupsub, msup, or msub with
142
- the base being an n-ary operator) then ignore this. Otherwise
143
- pass through -->
144
- <xsl:template mode="mml" match="mml:mrow|mml:mstyle">
145
- <xsl:variable name="fNaryArgument">
146
- <xsl:call-template name="FIsNaryArgument">
147
- <xsl:with-param name="ndCur" select="."/>
148
- </xsl:call-template>
149
- </xsl:variable>
150
- <xsl:if test="$fNaryArgument=0">
151
- <xsl:variable name="fLinearFrac">
152
- <xsl:call-template name="FLinearFrac">
153
- <xsl:with-param name="ndCur" select="."/>
154
- </xsl:call-template>
155
- </xsl:variable>
156
- <xsl:choose>
157
- <xsl:when test="$fLinearFrac=1">
158
- <xsl:call-template name="MakeLinearFraction">
159
- <xsl:with-param name="ndCur" select="."/>
160
- </xsl:call-template>
161
- </xsl:when>
162
- <xsl:otherwise>
163
- <xsl:variable name="fFunc">
164
- <xsl:call-template name="FIsFunc">
165
- <xsl:with-param name="ndCur" select="."/>
166
- </xsl:call-template>
167
- </xsl:variable>
168
- <xsl:choose>
169
- <xsl:when test="$fFunc=1">
170
- <xsl:call-template name="WriteFunc">
171
- <xsl:with-param name="ndCur" select="."/>
172
- </xsl:call-template>
173
- </xsl:when>
174
- <xsl:otherwise>
175
- <xsl:apply-templates mode="mml"/>
176
- </xsl:otherwise>
177
- </xsl:choose>
178
- </xsl:otherwise>
179
- </xsl:choose>
180
- </xsl:if>
181
- </xsl:template>
182
- <xsl:template mode="mml"
183
- match="mml:mi[not(child::mml:mglyph)] | mml:mn[not(child::mml:mglyph)] | mml:mo[not(child::mml:mglyph)] | mml:ms[not(child::mml:mglyph)] | mml:mtext[not(child::mml:mglyph)]">
184
-
185
- <!-- tokens with mglyphs as children are tranformed
186
- in a different manner than "normal" token elements.
187
- Where normal token elements are token elements that
188
- contain only text -->
189
- <xsl:variable name="fStartOfRun">
190
- <xsl:call-template name="FStartOfRun">
191
- <xsl:with-param name="ndCur" select="."/>
192
- </xsl:call-template>
193
- </xsl:variable>
194
-
195
- <!--In MathML, successive characters that are all part of one string are sometimes listed as separate
196
- tags based on their type (identifier (mi), name (mn), operator (mo), quoted (ms), literal text (mtext)),
197
- where said tags act to link one another into one logical run. In order to wrap the text of successive mi's,
198
- mn's, and mo's into one m:t, we need to denote where a run begins. The beginning of a run is the first mi, mn,
199
- or mo whose immediately preceding sibling either doesn't exist or is something other than a "normal" mi, mn, mo,
200
- ms, or mtext tag-->
201
-
202
- <!-- If this mi/mo/mn/ms . . . is part the numerator or denominator of a linear fraction, then don't collect. -->
203
- <xsl:variable name="fLinearFracParent">
204
- <xsl:call-template name="FLinearFrac">
205
- <xsl:with-param name="ndCur" select="parent::*"/>
206
- </xsl:call-template>
207
- </xsl:variable>
208
- <!-- If this mi/mo/mn/ms . . . is part of the name of a function, then don't collect. -->
209
- <xsl:variable name="fFunctionName">
210
- <xsl:call-template name="FIsFunc">
211
- <xsl:with-param name="ndCur" select="parent::*"/>
212
- </xsl:call-template>
213
- </xsl:variable>
214
- <xsl:variable name="fShouldCollect"
215
- select="($fLinearFracParent=0 and $fFunctionName=0) and (parent::mml:mrow or parent::mml:mstyle or parent::mml:msqrt or parent::mml:menclose or parent::mml:math or parent::mml:mphantom or parent::mml:mtd or parent::mml:maction)"/>
216
-
217
- <!--In MathML, the meaning of the different parts that make up mathematical structures, such as a fraction
218
- having a numerator and a denominator, is determined by the relative order of those different parts.
219
- For instance, In a fraction, the numerator is the first child and the denominator is the second child.
220
- To allow for more complex structures, MathML allows one to link a group of mi, mn, and mo's together
221
- using the mrow, or mstyle tags. The mi, mn, and mo's found within any of the above tags are considered
222
- one run. Therefore, if the parent of any mi, mn, or mo is found to be an mrow or mstyle, then the contiguous
223
- mi, mn, and mo's will be considered one run.-->
224
- <xsl:choose>
225
- <xsl:when test="$fShouldCollect">
226
- <xsl:choose>
227
- <xsl:when test="$fStartOfRun=1">
228
- <!--If this is the beginning of the run, pass all run attributes to CreateRunWithSameProp.-->
229
- <xsl:call-template name="CreateRunWithSameProp">
230
- <xsl:with-param name="mathbackground">
231
- <!-- Look for the unqualified mathml attribute mathbackground.
232
- Fall back to the qualified mathml attribute if necessary.
233
- This priority of unqualified over qualified will be
234
- followed throughout this xslt. -->
235
- <xsl:choose>
236
- <xsl:when test="@mathbackground">
237
- <xsl:value-of select="@mathbackground"/>
238
- </xsl:when>
239
- <xsl:otherwise>
240
- <xsl:value-of select="@mml:mathbackground"/>
241
- </xsl:otherwise>
242
- </xsl:choose>
243
- </xsl:with-param>
244
- <xsl:with-param name="mathcolor">
245
- <xsl:choose>
246
- <xsl:when test="@mathcolor">
247
- <xsl:value-of select="@mathcolor"/>
248
- </xsl:when>
249
- <xsl:otherwise>
250
- <xsl:value-of select="@mml:mathcolor"/>
251
- </xsl:otherwise>
252
- </xsl:choose>
253
- </xsl:with-param>
254
- <xsl:with-param name="mathvariant">
255
- <xsl:choose>
256
- <xsl:when test="@mathvariant">
257
- <xsl:value-of select="@mathvariant"/>
258
- </xsl:when>
259
- <xsl:otherwise>
260
- <xsl:value-of select="@mml:mathvariant"/>
261
- </xsl:otherwise>
262
- </xsl:choose>
263
- </xsl:with-param>
264
- <xsl:with-param name="color">
265
- <xsl:choose>
266
- <xsl:when test="@color">
267
- <xsl:value-of select="@color"/>
268
- </xsl:when>
269
- <xsl:otherwise>
270
- <xsl:value-of select="@mml:color"/>
271
- </xsl:otherwise>
272
- </xsl:choose>
273
- </xsl:with-param>
274
- <xsl:with-param name="font-family">
275
- <xsl:choose>
276
- <xsl:when test="@font-family">
277
- <xsl:value-of select="@font-family"/>
278
- </xsl:when>
279
- <xsl:otherwise>
280
- <xsl:value-of select="@mml:font-family"/>
281
- </xsl:otherwise>
282
- </xsl:choose>
283
- </xsl:with-param>
284
- <xsl:with-param name="fontsize">
285
- <xsl:choose>
286
- <xsl:when test="@fontsize">
287
- <xsl:value-of select="@fontsize"/>
288
- </xsl:when>
289
- <xsl:otherwise>
290
- <xsl:value-of select="@mml:fontsize"/>
291
- </xsl:otherwise>
292
- </xsl:choose>
293
- </xsl:with-param>
294
- <xsl:with-param name="fontstyle">
295
- <xsl:choose>
296
- <xsl:when test="@fontstyle">
297
- <xsl:value-of select="@fontstyle"/>
298
- </xsl:when>
299
- <xsl:otherwise>
300
- <xsl:value-of select="@mml:fontstyle"/>
301
- </xsl:otherwise>
302
- </xsl:choose>
303
- </xsl:with-param>
304
- <xsl:with-param name="fontweight">
305
- <xsl:choose>
306
- <xsl:when test="@fontweight">
307
- <xsl:value-of select="@fontweight"/>
308
- </xsl:when>
309
- <xsl:otherwise>
310
- <xsl:value-of select="@mml:fontweight"/>
311
- </xsl:otherwise>
312
- </xsl:choose>
313
- </xsl:with-param>
314
- <xsl:with-param name="mathsize">
315
- <xsl:choose>
316
- <xsl:when test="@mathsize">
317
- <xsl:value-of select="@mathsize"/>
318
- </xsl:when>
319
- <xsl:otherwise>
320
- <xsl:value-of select="@mml:mathsize"/>
321
- </xsl:otherwise>
322
- </xsl:choose>
323
- </xsl:with-param>
324
- <xsl:with-param name="ndTokenFirst" select="."/>
325
- </xsl:call-template>
326
- </xsl:when>
327
- </xsl:choose>
328
- </xsl:when>
329
- <xsl:otherwise>
330
- <!--Only one element will be part of run-->
331
- <r>
332
- <!--Create Run Properties based on current node's attributes-->
333
- <xsl:call-template name="CreateRunProp">
334
- <xsl:with-param name="mathvariant">
335
- <xsl:choose>
336
- <xsl:when test="@mathvariant">
337
- <xsl:value-of select="@mathvariant"/>
338
- </xsl:when>
339
- <xsl:otherwise>
340
- <xsl:value-of select="@mml:mathvariant"/>
341
- </xsl:otherwise>
342
- </xsl:choose>
343
- </xsl:with-param>
344
- <xsl:with-param name="fontstyle">
345
- <xsl:choose>
346
- <xsl:when test="@fontstyle">
347
- <xsl:value-of select="@fontstyle"/>
348
- </xsl:when>
349
- <xsl:otherwise>
350
- <xsl:value-of select="@mml:fontstyle"/>
351
- </xsl:otherwise>
352
- </xsl:choose>
353
- </xsl:with-param>
354
- <xsl:with-param name="fontweight">
355
- <xsl:choose>
356
- <xsl:when test="@fontweight">
357
- <xsl:value-of select="@fontweight"/>
358
- </xsl:when>
359
- <xsl:otherwise>
360
- <xsl:value-of select="@mml:fontweight"/>
361
- </xsl:otherwise>
362
- </xsl:choose>
363
- </xsl:with-param>
364
- <xsl:with-param name="mathcolor">
365
- <xsl:choose>
366
- <xsl:when test="@mathcolor">
367
- <xsl:value-of select="@mathcolor"/>
368
- </xsl:when>
369
- <xsl:otherwise>
370
- <xsl:value-of select="@mml:mathcolor"/>
371
- </xsl:otherwise>
372
- </xsl:choose>
373
- </xsl:with-param>
374
- <xsl:with-param name="mathsize">
375
- <xsl:choose>
376
- <xsl:when test="@mathsize">
377
- <xsl:value-of select="@mathsize"/>
378
- </xsl:when>
379
- <xsl:otherwise>
380
- <xsl:value-of select="@mml:mathsize"/>
381
- </xsl:otherwise>
382
- </xsl:choose>
383
- </xsl:with-param>
384
- <xsl:with-param name="color">
385
- <xsl:choose>
386
- <xsl:when test="@color">
387
- <xsl:value-of select="@color"/>
388
- </xsl:when>
389
- <xsl:otherwise>
390
- <xsl:value-of select="@mml:color"/>
391
- </xsl:otherwise>
392
- </xsl:choose>
393
- </xsl:with-param>
394
- <xsl:with-param name="fontsize">
395
- <xsl:choose>
396
- <xsl:when test="@fontsize">
397
- <xsl:value-of select="@fontsize"/>
398
- </xsl:when>
399
- <xsl:otherwise>
400
- <xsl:value-of select="@mml:fontsize"/>
401
- </xsl:otherwise>
402
- </xsl:choose>
403
- </xsl:with-param>
404
- <xsl:with-param name="ndCur" select="."/>
405
- <xsl:with-param name="fNor">
406
- <xsl:call-template name="FNor">
407
- <xsl:with-param name="ndCur" select="."/>
408
- </xsl:call-template>
409
- </xsl:with-param>
410
- <xsl:with-param name="fLit">
411
- <xsl:call-template name="FLit">
412
- <xsl:with-param name="ndCur" select="."/>
413
- </xsl:call-template>
414
- </xsl:with-param>
415
- </xsl:call-template>
416
- <t>
417
- <xsl:call-template name="OutputText">
418
- <xsl:with-param name="sInput" select="normalize-space(.)"/>
419
- </xsl:call-template>
420
- </t>
421
- </r>
422
- </xsl:otherwise>
423
- </xsl:choose>
424
- </xsl:template>
425
-
426
- <!-- %%Template: CreateRunWithSameProp
427
- -->
428
- <xsl:template name="CreateRunWithSameProp">
429
- <xsl:param name="mathbackground"/>
430
- <xsl:param name="mathcolor"/>
431
- <xsl:param name="mathvariant"/>
432
- <xsl:param name="color"/>
433
- <xsl:param name="font-family"/>
434
- <xsl:param name="fontsize"/>
435
- <xsl:param name="fontstyle"/>
436
- <xsl:param name="fontweight"/>
437
- <xsl:param name="mathsize"/>
438
- <xsl:param name="ndTokenFirst"/>
439
-
440
- <!--Given mathcolor, color, mstyle's (ancestor) color, and precedence of
441
- said attributes, determine the actual color of the current run-->
442
- <xsl:variable name="sColorPropCur">
443
- <xsl:choose>
444
- <xsl:when test="$mathcolor!=''">
445
- <xsl:value-of select="$mathcolor"/>
446
- </xsl:when>
447
- <xsl:when test="$color!=''">
448
- <xsl:value-of select="$color"/>
449
- </xsl:when>
450
- <xsl:when test="$ndTokenFirst/ancestor::mml:mstyle[@color][1]/@color!=''">
451
- <xsl:value-of select="$ndTokenFirst/ancestor::mml:mstyle[@color][1]/@color"/>
452
- </xsl:when>
453
- <xsl:when test="$ndTokenFirst/ancestor::mml:mstyle[@mml:color][1]/@mml:color!=''">
454
- <xsl:value-of select="$ndTokenFirst/ancestor::mml:mstyle[@color][1]/@mml:color"/>
455
- </xsl:when>
456
- <xsl:otherwise>
457
- <xsl:value-of select="''"/>
458
- </xsl:otherwise>
459
- </xsl:choose>
460
- </xsl:variable>
461
-
462
- <!--Given mathsize, and fontsize and precedence of said attributes,
463
- determine the actual font size of the current run-->
464
- <xsl:variable name="sSzCur">
465
- <xsl:choose>
466
- <xsl:when test="$mathsize!=''">
467
- <xsl:value-of select="$mathsize"/>
468
- </xsl:when>
469
- <xsl:when test="$fontsize!=''">
470
- <xsl:value-of select="$fontsize"/>
471
- </xsl:when>
472
- <xsl:otherwise>
473
- <xsl:value-of select="''"/>
474
- </xsl:otherwise>
475
- </xsl:choose>
476
- </xsl:variable>
477
-
478
- <!--Given mathvariant, fontstyle, and fontweight, and precedence of
479
- the attributes, determine the actual font of the current run-->
480
- <xsl:variable name="sFontCur">
481
- <xsl:call-template name="GetFontCur">
482
- <xsl:with-param name="mathvariant" select="$mathvariant"/>
483
- <xsl:with-param name="fontstyle" select="$fontstyle"/>
484
- <xsl:with-param name="fontweight" select="$fontweight"/>
485
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
486
- </xsl:call-template>
487
- </xsl:variable>
488
-
489
- <!-- The omml equivalent structure for mml:mtext is an omml run with the run property m:nor (normal) set.
490
- Therefore, we can only collect mtexts with other mtext elements. Suppose the $ndTokenFirst is an
491
- mml:mtext, then if any of its following siblings are to be grouped, they must also be mml:text elements.
492
- The inverse is also true, suppose the $ndTokenFirst isn't an mml:mtext, then if any of its following siblings
493
- are to be grouped with $ndTokenFirst, they can't be mml:mtext elements-->
494
- <xsl:variable name="fNdTokenFirstIsMText">
495
- <xsl:choose>
496
- <xsl:when test="$ndTokenFirst/self::mml:mtext">1</xsl:when>
497
- <xsl:otherwise>0</xsl:otherwise>
498
- </xsl:choose>
499
- </xsl:variable>
500
-
501
- <!--In order to determine the length of the run, we will find the number of nodes before the inital node in the run and
502
- the number of nodes before the first node that DOES NOT belong to the current run. The number of nodes that will
503
- be printed is One Less than the difference between the latter and the former-->
504
-
505
- <!--Find index of current node-->
506
- <xsl:variable name="nndBeforeFirst" select="count($ndTokenFirst/preceding-sibling::*)"/>
507
-
508
- <!--Find index of next change in run properties.
509
-
510
- The basic idea is that we want to find the position of the last node in the longest
511
- sequence of nodes, starting from ndTokenFirst, that can be grouped into a run. For
512
- example, nodes A and B can be grouped together into the same run iff they have the same
513
- props.
514
-
515
- To accomplish this grouping, we want to find the next sibling to ndTokenFirst that shouldn't be
516
- included in the run of text. We do this by counting the number of elements that precede the first
517
- such element that doesn't belong. The xpath that accomplishes this is below.
518
-
519
- Count the number of siblings the precede the first element after ndTokenFirst that shouldn't belong.
520
- count($ndTokenFirst/following-sibling::*[ . . . ][1]/preceding-sibling::*)
521
-
522
- Now, the hard part to this is what is represented by the '. . .' above. This conditional expression is
523
- defining what elements *don't* belong to the current run. The conditions are as follows:
524
-
525
- The element is not a token element (mi, mn, mo, ms, or mtext)
526
-
527
- or
528
-
529
- The token element contains a glyph child (this is handled separately).
530
-
531
- or
532
-
533
- The token is an mtext and the run didn't start with an mtext, or the token isn't an mtext and the run started
534
- with an mtext. We do this check because mtext transforms into an omml m:nor property, and thus, these mtext
535
- token elements need to be grouped separately from other token elements.
536
-
537
- // We do an or not( . . . ), because it was easier to define what token elements match than how they don't match.
538
- // Thus, this inner '. . .' defines how token attributes equate to one another. We add the 'not' outside of to accomplish
539
- // the goal of the outer '. . .', which is the find the next element that *doesn't* match.
540
- or not(
541
- The background colors match.
542
-
543
- and
544
-
545
- The current font (sFontCur) matches the mathvariant
546
-
547
- or
548
-
549
- sFontCur is normal and matches the current font characteristics
550
-
551
- or
552
-
553
- sFontCur is italic and matches the current font characteristics
554
-
555
- or
556
-
557
- . . .
558
-
559
- and
560
-
561
- The font family matches the current font family.
562
- ) // end of not().-->
563
- <xsl:variable name="nndBeforeLim"
564
- select="count($ndTokenFirst/following-sibling::* [(not(self::mml:mi) and not(self::mml:mn) and not(self::mml:mo) and not(self::mml:ms) and not(self::mml:mtext)) or (self::mml:mi[child::mml:mglyph] or self::mml:mn[child::mml:mglyph] or self::mml:mo[child::mml:mglyph] or self::mml:ms[child::mml:mglyph] or self::mml:mtext[child::mml:mglyph]) or (($fNdTokenFirstIsMText=1 and not(self::mml:mtext)) or ($fNdTokenFirstIsMText=0 and self::mml:mtext)) or not( ((($sFontCur=@mathvariant or $sFontCur=@mml:mathvariant) or ($sFontCur='normal' and ((@mathvariant='normal' or @mml:mathvariant='normal') or (((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='')) and ( ((@fontstyle='normal' or @mml:fontstyle='normal') and (not(@fontweight='bold') and not(@mml:fontweight='bold'))) or (self::mml:mi and string-length(normalize-space(.)) &gt; 1) ) ) ) ) or ($sFontCur='italic' and ((@mathvariant='italic' or @mml:mathvariant='italic') or (((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='')) and ( ((@fontstyle='italic' or @mml:fontstyle='italic') and (not(@fontweight='bold') and not(@mml:fontweight='bold'))) or (self::mml:mn or self::mml:mo or (self::mml:mi and string-length(normalize-space(.)) &lt;= 1)) ) ) ) ) or ($sFontCur='bold' and ((@mathvariant='bold' or @mml:mathvariant='bold') or (((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='')) and ( ((@fontweight='bold' or @mml:fontweight='bold') and ((@fontstyle='normal' or @mml:fontstyle='normal') or (self::mml:mi and string-length(normalize-space(.)) &lt;= 1)) ) ) ) ) ) or (($sFontCur='bi' or $sFontCur='bold-italic') and ( (@mathvariant='bold-italic' or @mml:mathvariant='bold-italic') or (((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='')) and ( ((@fontweight='bold' or @mml:fontweight='bold') and (@fontstyle='italic' or @mml:fontstyle='italic')) or ((@fontweight='bold' or @mml:fontweight='bold') and (self::mml:mn or self::mml:mo or (self::mml:mi and string-length(normalize-space(.)) &lt;= 1))) ) ) ) ) or (($sFontCur='' and ( ((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='') and (not(@fontstyle) or @fontstyle='') and (not(@mml:fontstyle) or @mml:fontstyle='') and (not(@fontweight)or @fontweight='') and (not(@mml:fontweight) or @mml:fontweight='') ) or (@mathvariant='italic' or @mml:mathvariant='italic') or ( ((not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='')) and ( (((@fontweight='normal' or @mml:fontweight='normal') and (@fontstyle='italic' or @mml:fontstyle='italic')) ) or ((not(@fontweight) or @fontweight='') and (not(@mml:fontweight) or @mml:fontweight='')) and (@fontstyle='italic' or @mml:fontstyle='italic') or ((not(@fontweight) or @fontweight='') and (not(@mml:fontweight) or @mml:fontweight='')) and (not(@fontstyle) or @fontstyle='') and (not(@mml:fontstyle) or @mml:fontstyle='')) ) ) )) or ($sFontCur='normal' and ((self::mml:mi and (not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant) and (not(@fontstyle) or @fontstyle='') and (not(@mml:fontstyle) or @mml:fontstyle='') and (not(@fontweight) or @fontweight='') and (not(@mml:fontweight) or @mml:fontweight='') and (string-length(normalize-space(.)) &gt; 1) ) or ((self::mml:ms or self::mml:mtext) and (not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant) and (not(@fontstyle) or @fontstyle) and (not(@fontstyle) or @fontstyle='') and (not(@fontweight) or @fontweight) and (not(@mml:fontweight) or @mml:fontweight='') ) ) ) ) and (($font-family = @font-family or $font-family = @mml:font-family) or (($font-family='' or not($font-family)) and (not(@font-family) or @font-family='') and (not(@mml:font-family) or @mml:font-family='') ) ) )) ][1]/preceding-sibling::*)"/>
565
-
566
- <xsl:variable name="cndRun" select="$nndBeforeLim - $nndBeforeFirst"/>
567
-
568
- <!--Contiguous groups of like-property mi, mn, and mo's are separated by non- mi, mn, mo tags, or mi,mn, or mo
569
- tags with different properties. nndBeforeLim is the number of nodes before the next tag which separates contiguous
570
- groups of like-property mi, mn, and mo's. Knowing this delimiting tag allows for the aggregation of the correct
571
- number of mi, mn, and mo tags.-->
572
- <r>
573
-
574
- <!--The beginning and ending of the current run has been established. Now we should open a run element-->
575
- <xsl:choose>
576
-
577
- <!--If cndRun > 0, then there is a following diffrent prop, or non- Token,
578
- although there may or may not have been a preceding different prop, or non-
579
- Token-->
580
- <xsl:when test="$cndRun &gt; 0">
581
- <xsl:call-template name="CreateRunProp">
582
- <xsl:with-param name="mathvariant" select="$mathvariant"/>
583
- <xsl:with-param name="fontstyle" select="$fontstyle"/>
584
- <xsl:with-param name="fontweight" select="$fontweight"/>
585
- <xsl:with-param name="mathcolor" select="$mathcolor"/>
586
- <xsl:with-param name="mathsize" select="$mathsize"/>
587
- <xsl:with-param name="color" select="$color"/>
588
- <xsl:with-param name="fontsize" select="$fontsize"/>
589
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
590
- <xsl:with-param name="fNor">
591
- <xsl:call-template name="FNor">
592
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
593
- </xsl:call-template>
594
- </xsl:with-param>
595
- <xsl:with-param name="fLit">
596
- <xsl:call-template name="FLit">
597
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
598
- </xsl:call-template>
599
- </xsl:with-param>
600
- </xsl:call-template>
601
- <t>
602
- <xsl:call-template name="OutputText">
603
- <xsl:with-param name="sInput">
604
- <xsl:choose>
605
- <xsl:when test="namespace-uri($ndTokenFirst) = 'http://www.w3.org/1998/Math/MathML' and local-name($ndTokenFirst) = 'ms'">
606
- <xsl:call-template name="OutputMs">
607
- <xsl:with-param name="msCur" select="$ndTokenFirst"/>
608
- </xsl:call-template>
609
- </xsl:when>
610
- <xsl:otherwise>
611
- <xsl:value-of select="normalize-space($ndTokenFirst)"/>
612
- </xsl:otherwise>
613
- </xsl:choose>
614
- <xsl:for-each select="$ndTokenFirst/following-sibling::*[position() &lt; $cndRun]">
615
- <xsl:choose>
616
- <xsl:when test="namespace-uri(.) = 'http://www.w3.org/1998/Math/MathML' and local-name(.) = 'ms'">
617
- <xsl:call-template name="OutputMs">
618
- <xsl:with-param name="msCur" select="."/>
619
- </xsl:call-template>
620
- </xsl:when>
621
- <xsl:otherwise>
622
- <xsl:value-of select="normalize-space(.)"/>
623
- </xsl:otherwise>
624
- </xsl:choose>
625
- </xsl:for-each>
626
- </xsl:with-param>
627
- </xsl:call-template>
628
- </t>
629
- </xsl:when>
630
- <xsl:otherwise>
631
-
632
- <!--if cndRun lt;= 0, then iNextNonToken = 0,
633
- and iPrecNonToken gt;= 0. In either case, b/c there
634
- is no next different property or non-Token
635
- (which is implied by the nndBeforeLast being equal to 0)
636
- you can put all the remaining mi, mn, and mo's into one
637
- group.-->
638
- <xsl:call-template name="CreateRunProp">
639
- <xsl:with-param name="mathvariant" select="$mathvariant"/>
640
- <xsl:with-param name="fontstyle" select="$fontstyle"/>
641
- <xsl:with-param name="fontweight" select="$fontweight"/>
642
- <xsl:with-param name="mathcolor" select="$mathcolor"/>
643
- <xsl:with-param name="mathsize" select="$mathsize"/>
644
- <xsl:with-param name="color" select="$color"/>
645
- <xsl:with-param name="fontsize" select="$fontsize"/>
646
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
647
- <xsl:with-param name="fNor">
648
- <xsl:call-template name="FNor">
649
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
650
- </xsl:call-template>
651
- </xsl:with-param>
652
- <xsl:with-param name="fLit">
653
- <xsl:call-template name="FLit">
654
- <xsl:with-param name="ndCur" select="$ndTokenFirst"/>
655
- </xsl:call-template>
656
- </xsl:with-param>
657
- </xsl:call-template>
658
- <t>
659
-
660
- <!--Create the Run, first output current, then in a
661
- for-each, because all the following siblings are
662
- mn, mi, and mo's that conform to the run's properties,
663
- group them together-->
664
- <xsl:call-template name="OutputText">
665
- <xsl:with-param name="sInput">
666
- <xsl:choose>
667
- <xsl:when test="namespace-uri($ndTokenFirst) = 'http://www.w3.org/1998/Math/MathML' and local-name($ndTokenFirst) = 'ms'">
668
- <xsl:call-template name="OutputMs">
669
- <xsl:with-param name="msCur" select="$ndTokenFirst"/>
670
- </xsl:call-template>
671
- </xsl:when>
672
- <xsl:otherwise>
673
- <xsl:value-of select="normalize-space($ndTokenFirst)"/>
674
- </xsl:otherwise>
675
- </xsl:choose>
676
- <xsl:for-each select="$ndTokenFirst/following-sibling::*[self::mml:mi or self::mml:mn or self::mml:mo or self::mml:ms or self::mml:mtext]">
677
- <xsl:choose>
678
- <xsl:when test="namespace-uri(.) = 'http://www.w3.org/1998/Math/MathML' and local-name(.) = 'ms'">
679
- <xsl:call-template name="OutputMs">
680
- <xsl:with-param name="msCur" select="."/>
681
- </xsl:call-template>
682
- </xsl:when>
683
- <xsl:otherwise>
684
- <xsl:value-of select="normalize-space(.)"/>
685
- </xsl:otherwise>
686
- </xsl:choose>
687
- </xsl:for-each>
688
- </xsl:with-param>
689
- </xsl:call-template>
690
- </t>
691
- </xsl:otherwise>
692
- </xsl:choose>
693
- </r>
694
-
695
- <!--The run was terminated by an mi, mn, mo, ms, or mtext with different properties,
696
- therefore, call-template CreateRunWithSameProp, using cndRun+1 node as new start node-->
697
- <xsl:if test="$nndBeforeLim!=0 and ($ndTokenFirst/following-sibling::*[$cndRun]/self::mml:mi or $ndTokenFirst/following-sibling::*[$cndRun]/self::mml:mn or $ndTokenFirst/following-sibling::*[$cndRun]/self::mml:mo or $ndTokenFirst/following-sibling::*[$cndRun]/self::mml:ms or $ndTokenFirst/following-sibling::*[$cndRun]/self::mml:mtext) and (count($ndTokenFirst/following-sibling::*[$cndRun]/mml:mglyph) = 0)">
698
- <xsl:call-template name="CreateRunWithSameProp">
699
- <xsl:with-param name="mathbackground">
700
- <xsl:choose>
701
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@mathbackground">
702
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mathbackground"/>
703
- </xsl:when>
704
- <xsl:otherwise>
705
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:mathbackground"/>
706
- </xsl:otherwise>
707
- </xsl:choose>
708
- </xsl:with-param>
709
- <xsl:with-param name="mathcolor">
710
- <xsl:choose>
711
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@mathcolor">
712
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mathcolor"/>
713
- </xsl:when>
714
- <xsl:otherwise>
715
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:mathcolor"/>
716
- </xsl:otherwise>
717
- </xsl:choose>
718
- </xsl:with-param>
719
- <xsl:with-param name="mathvariant">
720
- <xsl:choose>
721
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@mathvariant">
722
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mathvariant"/>
723
- </xsl:when>
724
- <xsl:otherwise>
725
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:mathvariant"/>
726
- </xsl:otherwise>
727
- </xsl:choose>
728
- </xsl:with-param>
729
- <xsl:with-param name="color">
730
- <xsl:choose>
731
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@color">
732
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@color"/>
733
- </xsl:when>
734
- <xsl:otherwise>
735
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:color"/>
736
- </xsl:otherwise>
737
- </xsl:choose>
738
- </xsl:with-param>
739
- <xsl:with-param name="font-family">
740
- <xsl:choose>
741
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@font-family">
742
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@font-family"/>
743
- </xsl:when>
744
- <xsl:otherwise>
745
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:font-family"/>
746
- </xsl:otherwise>
747
- </xsl:choose>
748
- </xsl:with-param>
749
- <xsl:with-param name="fontsize">
750
- <xsl:choose>
751
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@fontsize">
752
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@fontsize"/>
753
- </xsl:when>
754
- <xsl:otherwise>
755
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:fontsize"/>
756
- </xsl:otherwise>
757
- </xsl:choose>
758
- </xsl:with-param>
759
- <xsl:with-param name="fontstyle">
760
- <xsl:choose>
761
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@fontstyle">
762
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@fontstyle"/>
763
- </xsl:when>
764
- <xsl:otherwise>
765
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:fontstyle"/>
766
- </xsl:otherwise>
767
- </xsl:choose>
768
- </xsl:with-param>
769
- <xsl:with-param name="fontweight">
770
- <xsl:choose>
771
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@fontweight">
772
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@fontweight"/>
773
- </xsl:when>
774
- <xsl:otherwise>
775
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:fontweight"/>
776
- </xsl:otherwise>
777
- </xsl:choose>
778
- </xsl:with-param>
779
- <xsl:with-param name="mathsize">
780
- <xsl:choose>
781
- <xsl:when test="$ndTokenFirst/following-sibling::*[$cndRun]/@mathsize">
782
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mathsize"/>
783
- </xsl:when>
784
- <xsl:otherwise>
785
- <xsl:value-of select="$ndTokenFirst/following-sibling::*[$cndRun]/@mml:mathsize"/>
786
- </xsl:otherwise>
787
- </xsl:choose>
788
- </xsl:with-param>
789
- <xsl:with-param name="ndTokenFirst" select="$ndTokenFirst/following-sibling::*[$cndRun]"/>
790
- </xsl:call-template>
791
- </xsl:if>
792
- </xsl:template>
793
-
794
- <!-- %%Template: FNor
795
- Given the context of ndCur, determine if ndCur should be omml's normal style.
796
- -->
797
- <xsl:template name="FNor">
798
- <xsl:param name="ndCur" select="."/>
799
- <xsl:choose>
800
- <!-- Is the current node an mml:mtext, or if this is an mglyph whose parent is
801
- an mml:mtext. -->
802
- <xsl:when test="$ndCur/self::mml:mtext or ($ndCur/self::mml:mglyph and parent::mml:mtext)">1</xsl:when>
803
- <xsl:otherwise>0</xsl:otherwise>
804
- </xsl:choose>
805
- </xsl:template>
806
-
807
- <!-- %%Template: FLit
808
- Given the context of ndCur, determine if ndCur should have the
809
- run omml property of lit (literal, no build up).
810
- -->
811
- <xsl:template name="FLit">
812
- <xsl:param name="ndCur" select="."/>
813
- <xsl:variable name="sLowerActiontype">
814
- <xsl:choose>
815
- <xsl:when test="$ndCur/ancestor::mml:maction[@actiontype='lit']/@actiontype">
816
- <xsl:value-of select="translate($ndCur/ancestor::mml:maction[@actiontype='lit']/@actiontype, $StrUCAlphabet, $StrLCAlphabet)"/>
817
- </xsl:when>
818
- <xsl:otherwise>
819
- <xsl:value-of select="translate($ndCur/ancestor::mml:maction[@actiontype='lit']/@mml:actiontype, $StrUCAlphabet, $StrLCAlphabet)"/>
820
- </xsl:otherwise>
821
- </xsl:choose>
822
- </xsl:variable>
823
- <xsl:choose>
824
- <xsl:when test="$sLowerActiontype='lit'">1</xsl:when>
825
- <xsl:otherwise>0</xsl:otherwise>
826
- </xsl:choose>
827
- </xsl:template>
828
-
829
- <!-- %%Template: CreateRunProp
830
- -->
831
- <xsl:template name="CreateRunProp">
832
- <xsl:param name="mathbackground"/>
833
- <xsl:param name="mathcolor"/>
834
- <xsl:param name="mathvariant"/>
835
- <xsl:param name="color"/>
836
- <xsl:param name="font-family">Cambria Math</xsl:param>
837
- <xsl:param name="fontsize"/>
838
- <xsl:param name="fontstyle"/>
839
- <xsl:param name="fontweight"/>
840
- <xsl:param name="mathsize"/>
841
- <xsl:param name="ndCur"/>
842
- <xsl:param name="fNor"/>
843
- <xsl:param name="fLit"/>
844
- <!-- NN 20180315 Yuck. Get that away from here -->
845
- <!--
846
- <w:rPr>
847
- <xsl:call-template name="mathrRpHook"/>
848
- <w:rFonts w:ascii="{$font-family}" w:eastAsia="{$font-family}" w:hAnsi="{$font-family}"
849
- w:cs="{$font-family}"/>
850
- <xsl:choose>
851
- <xsl:when test="$fontweight=''"/>
852
- <xsl:when test="$fontweight='bold'">
853
- <w:b/>
854
- </xsl:when>
855
- <xsl:when test="$fontweight='normal'">
856
- <w:b w:val="0"/>
857
- </xsl:when>
858
- </xsl:choose>
859
- <xsl:choose>
860
- <xsl:when test="$fontstyle=''"/>
861
- <xsl:when test="$fontstyle='italic'">
862
- <w:i/>
863
- </xsl:when>
864
- <xsl:when test="$fontstyle='normal'">
865
- <w:i w:val="0"/>
866
- </xsl:when>
867
- </xsl:choose>
868
- </w:rPr>
869
- -->
870
- <xsl:variable name="mstyleColor">
871
- <xsl:if test="not(not($ndCur))">
872
- <xsl:choose>
873
- <xsl:when test="$ndCur/ancestor::mml:mstyle[@color][1]/@color">
874
- <xsl:value-of select="$ndCur/ancestor::mml:mstyle[@color][1]/@color"/>
875
- </xsl:when>
876
- <xsl:otherwise>
877
- <xsl:value-of select="$ndCur/ancestor::mml:mstyle[@color][1]/@mml:color"/>
878
- </xsl:otherwise>
879
- </xsl:choose>
880
- </xsl:if>
881
- </xsl:variable>
882
- <!-- NN 20200831 https://github.com/metanorma/metanorma-nist/issues/155 Read in ancestor mstyle -->
883
- <xsl:variable name="mathvariant2">
884
- <xsl:choose>
885
- <xsl:when test="$mathvariant=''">
886
- <xsl:value-of select="$ndCur/ancestor::mml:mstyle[@mathvariant][1]/@mathvariant"/>
887
- </xsl:when>
888
- <xsl:otherwise>
889
- <xsl:value-of select="$mathvariant"/>
890
- </xsl:otherwise>
891
- </xsl:choose>
892
- </xsl:variable>
893
- <!-- END NN -->
894
- <xsl:call-template name="CreateMathRPR">
895
- <xsl:with-param name="mathvariant" select="$mathvariant2"/>
896
- <xsl:with-param name="fontstyle" select="$fontstyle"/>
897
- <xsl:with-param name="fontweight" select="$fontweight"/>
898
- <xsl:with-param name="ndCur" select="$ndCur"/>
899
- <xsl:with-param name="fNor" select="$fNor"/>
900
- <xsl:with-param name="fLit" select="$fLit"/>
901
- </xsl:call-template>
902
- </xsl:template>
903
-
904
- <!-- %%Template: CreateMathRPR
905
- -->
906
- <xsl:template name="CreateMathRPR">
907
- <xsl:param name="mathvariant"/>
908
- <xsl:param name="fontstyle"/>
909
- <xsl:param name="fontweight"/>
910
- <xsl:param name="ndCur"/>
911
- <xsl:param name="fNor"/>
912
- <xsl:param name="fLit"/>
913
- <xsl:variable name="sFontCur">
914
- <xsl:call-template name="GetFontCur">
915
- <xsl:with-param name="mathvariant" select="$mathvariant"/>
916
- <xsl:with-param name="fontstyle" select="$fontstyle"/>
917
- <xsl:with-param name="fontweight" select="$fontweight"/>
918
- <xsl:with-param name="ndCur" select="$ndCur"/>
919
- </xsl:call-template>
920
- </xsl:variable>
921
- <xsl:if test="$fLit=1 or $fNor=1 or ($sFontCur!='italic' and $sFontCur!='')">
922
- <rPr>
923
- <xsl:if test="$fNor=1">
924
- <nor/>
925
- </xsl:if>
926
- <xsl:if test="$fLit=1">
927
- <lit/>
928
- </xsl:if>
929
- <xsl:call-template name="CreateMathScrStyProp">
930
- <xsl:with-param name="font" select="$sFontCur"/>
931
- <xsl:with-param name="fNor" select="$fNor"/>
932
- </xsl:call-template>
933
- </rPr>
934
- </xsl:if>
935
- </xsl:template>
936
-
937
- <!-- %%Template: GetFontCur
938
- -->
939
- <xsl:template name="GetFontCur">
940
- <xsl:param name="ndCur"/>
941
- <xsl:param name="mathvariant"/>
942
- <xsl:param name="fontstyle"/>
943
- <xsl:param name="fontweight"/>
944
- <xsl:choose>
945
- <xsl:when test="$mathvariant!=''">
946
- <xsl:value-of select="$mathvariant"/>
947
- </xsl:when>
948
- <xsl:when test="not($ndCur)">
949
- <xsl:value-of select="'italic'"/>
950
- </xsl:when>
951
- <!--<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) &lt;= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN' or $ndCur/self::mml:mo">-->
952
- <!-- https://github.com/metanorma/metanorma-nist/issues/155 : DO NOT italicise mml:mo -->
953
- <xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) &lt;= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN'">
954
-
955
- <!-- The default for the above three cases is fontstyle=italic fontweight=normal.-->
956
- <xsl:choose>
957
- <xsl:when test="$fontstyle='normal' and $fontweight='bold'">
958
- <!-- In omml, a sty of 'b' (which is what bold is translated into)
959
- implies a normal fontstyle -->
960
- <xsl:value-of select="'bold'"/>
961
- </xsl:when>
962
- <xsl:when test="$fontstyle='normal'">
963
- <xsl:value-of select="'normal'"/>
964
- </xsl:when>
965
- <xsl:when test="$fontweight='bold'">
966
- <xsl:value-of select="'bi'"/>
967
- </xsl:when>
968
- <xsl:when test="$fontweight='normal'">
969
- <xsl:value-of select="'i'"/>
970
- </xsl:when>
971
- <xsl:otherwise>
972
- <xsl:value-of select="'italic'"/>
973
- </xsl:otherwise>
974
- </xsl:choose>
975
- </xsl:when>
976
- <xsl:otherwise>
977
- <!--Default is fontweight = 'normal' and fontstyle='normal'-->
978
- <xsl:choose>
979
- <xsl:when test="$fontstyle='italic' and $fontweight='bold'">
980
- <xsl:value-of select="'bi'"/>
981
- </xsl:when>
982
- <xsl:when test="$fontstyle='italic'">
983
- <xsl:value-of select="'italic'"/>
984
- </xsl:when>
985
- <xsl:when test="$fontweight='normal'">
986
- <xsl:value-of select="'italic'"/>
987
- </xsl:when>
988
- <xsl:when test="$fontweight='bold'">
989
- <xsl:value-of select="'bold'"/>
990
- </xsl:when>
991
- <xsl:otherwise>
992
- <xsl:value-of select="'normal'"/>
993
- </xsl:otherwise>
994
- </xsl:choose>
995
- </xsl:otherwise>
996
- </xsl:choose>
997
- </xsl:template>
998
-
999
-
1000
- <!-- %%Template: CreateMathScrStyProp
1001
- -->
1002
- <xsl:template name="CreateMathScrStyProp">
1003
- <xsl:param name="font"/>
1004
- <xsl:param name="fNor" select="0"/>
1005
- <xsl:choose>
1006
- <xsl:when test="$font='normal' and $fNor=0">
1007
- <sty>
1008
- <xsl:attribute name="m:val">p</xsl:attribute>
1009
- </sty>
1010
- </xsl:when>
1011
- <xsl:when test="$font='bold'">
1012
- <sty>
1013
- <xsl:attribute name="m:val">b</xsl:attribute>
1014
- </sty>
1015
- </xsl:when>
1016
- <xsl:when test="$font='italic'">
1017
- <!-- NN 20200901 https://github.com/metanorma/metanorma-itu/issues/173 italic needs to be added explicitly to mtext -->
1018
- <xsl:if test="$fNor=1">
1019
- <sty>
1020
- <xsl:attribute name="m:val">i</xsl:attribute>
1021
- </sty>
1022
- </xsl:if>
1023
- </xsl:when>
1024
- <xsl:when test="$font='script'">
1025
- <scr>
1026
- <xsl:attribute name="m:val">script</xsl:attribute>
1027
- </scr>
1028
- </xsl:when>
1029
- <xsl:when test="$font='bold-script'">
1030
- <scr>
1031
- <xsl:attribute name="m:val">script</xsl:attribute>
1032
- </scr>
1033
- <sty>
1034
- <xsl:attribute name="m:val">b</xsl:attribute>
1035
- </sty>
1036
- </xsl:when>
1037
- <xsl:when test="$font='double-struck'">
1038
- <scr>
1039
- <xsl:attribute name="m:val">double-struck</xsl:attribute>
1040
- </scr>
1041
- <sty>
1042
- <xsl:attribute name="m:val">p</xsl:attribute>
1043
- </sty>
1044
- </xsl:when>
1045
- <xsl:when test="$font='fraktur'">
1046
- <scr>
1047
- <xsl:attribute name="m:val">fraktur</xsl:attribute>
1048
- </scr>
1049
- <sty>
1050
- <xsl:attribute name="m:val">p</xsl:attribute>
1051
- </sty>
1052
- </xsl:when>
1053
- <xsl:when test="$font='bold-fraktur'">
1054
- <scr>
1055
- <xsl:attribute name="m:val">fraktur</xsl:attribute>
1056
- </scr>
1057
- <sty>
1058
- <xsl:attribute name="m:val">b</xsl:attribute>
1059
- </sty>
1060
- </xsl:when>
1061
- <xsl:when test="$font='sans-serif'">
1062
- <scr>
1063
- <xsl:attribute name="m:val">sans-serif</xsl:attribute>
1064
- </scr>
1065
- <sty>
1066
- <xsl:attribute name="m:val">p</xsl:attribute>
1067
- </sty>
1068
- </xsl:when>
1069
- <xsl:when test="$font='bold-sans-serif'">
1070
- <scr>
1071
- <xsl:attribute name="m:val">sans-serif</xsl:attribute>
1072
- </scr>
1073
- <sty>
1074
- <xsl:attribute name="m:val">b</xsl:attribute>
1075
- </sty>
1076
- </xsl:when>
1077
- <xsl:when test="$font='sans-serif-italic'">
1078
- <scr>
1079
- <xsl:attribute name="m:val">sans-serif</xsl:attribute>
1080
- </scr>
1081
- </xsl:when>
1082
- <xsl:when test="$font='sans-serif-bold-italic'">
1083
- <scr>
1084
- <xsl:attribute name="m:val">sans-serif</xsl:attribute>
1085
- </scr>
1086
- <sty>
1087
- <xsl:attribute name="m:val">bi</xsl:attribute>
1088
- </sty>
1089
- </xsl:when>
1090
- <xsl:when test="$font='monospace'">
1091
- <!-- We can't do monospace, so leave empty -->
1092
- <!-- NN 2020 https://github.com/metanorma/html2doc/issues/47 no, we will -->
1093
- <scr>
1094
- <xsl:attribute name="m:val">monospace</xsl:attribute>
1095
- </scr>
1096
- <sty>
1097
- <xsl:attribute name="m:val">p</xsl:attribute>
1098
- </sty>
1099
- </xsl:when>
1100
- <xsl:when test="$font='bold'">
1101
- <sty>
1102
- <xsl:attribute name="m:val">b</xsl:attribute>
1103
- </sty>
1104
- </xsl:when>
1105
- <xsl:when test="$font='bi' or $font='bold-italic'">
1106
- <sty>
1107
- <xsl:attribute name="m:val">bi</xsl:attribute>
1108
- </sty>
1109
- </xsl:when>
1110
- </xsl:choose>
1111
- </xsl:template>
1112
-
1113
- <xsl:template name="FBar">
1114
- <xsl:param name="sLineThickness"/>
1115
- <xsl:variable name="sLowerLineThickness"
1116
- select="translate($sLineThickness, $StrUCAlphabet, $StrLCAlphabet)"/>
1117
- <xsl:choose>
1118
- <xsl:when test="string-length($sLowerLineThickness)=0 or $sLowerLineThickness='thin' or $sLowerLineThickness='medium' or $sLowerLineThickness='thick'">1</xsl:when>
1119
- <xsl:otherwise>
1120
- <xsl:variable name="fStrContainsNonZeroDigit">
1121
- <xsl:call-template name="FStrContainsNonZeroDigit">
1122
- <xsl:with-param name="s" select="$sLowerLineThickness"/>
1123
- </xsl:call-template>
1124
- </xsl:variable>
1125
- <xsl:choose>
1126
- <xsl:when test="$fStrContainsNonZeroDigit=1">1</xsl:when>
1127
- <xsl:otherwise>0</xsl:otherwise>
1128
- </xsl:choose>
1129
- </xsl:otherwise>
1130
- </xsl:choose>
1131
- </xsl:template>
1132
-
1133
-
1134
- <!-- %%Template: match mfrac
1135
- -->
1136
- <xsl:template mode="mml" match="mml:mfrac">
1137
- <xsl:variable name="fBar">
1138
- <xsl:call-template name="FBar">
1139
- <xsl:with-param name="sLineThickness">
1140
- <xsl:choose>
1141
- <xsl:when test="@linethickness">
1142
- <xsl:value-of select="@linethickness"/>
1143
- </xsl:when>
1144
- <xsl:otherwise>
1145
- <xsl:value-of select="@mml:linethickness"/>
1146
- </xsl:otherwise>
1147
- </xsl:choose>
1148
- </xsl:with-param>
1149
- </xsl:call-template>
1150
- </xsl:variable>
1151
-
1152
- <f>
1153
- <fPr>
1154
- <type>
1155
- <xsl:attribute name="m:val">
1156
- <xsl:choose>
1157
- <xsl:when test="$fBar=0">noBar</xsl:when>
1158
- <xsl:when test="@bevelled='true' or @mml:bevelled='true'">skw</xsl:when>
1159
- <xsl:otherwise>bar</xsl:otherwise>
1160
- </xsl:choose>
1161
- </xsl:attribute>
1162
- </type>
1163
- </fPr>
1164
- <num>
1165
- <xsl:call-template name="CreateArgProp"/>
1166
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1167
- </num>
1168
- <den>
1169
- <xsl:call-template name="CreateArgProp"/>
1170
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1171
- </den>
1172
- </f>
1173
- </xsl:template>
1174
-
1175
- <!-- %%Template: match menclose msqrt
1176
- -->
1177
- <xsl:template mode="mml" match="mml:menclose | mml:msqrt">
1178
- <xsl:variable name="sLowerCaseNotation">
1179
- <xsl:choose>
1180
- <xsl:when test="@notation">
1181
- <xsl:value-of select="translate(@notation, $StrUCAlphabet, $StrLCAlphabet)"/>
1182
- </xsl:when>
1183
- <xsl:otherwise>
1184
- <xsl:value-of select="translate(@mml:notation, $StrUCAlphabet, $StrLCAlphabet)"/>
1185
- </xsl:otherwise>
1186
- </xsl:choose>
1187
- </xsl:variable>
1188
- <xsl:choose>
1189
- <!-- Take care of default -->
1190
- <xsl:when test="$sLowerCaseNotation='radical' or not($sLowerCaseNotation) or $sLowerCaseNotation='' or self::mml:msqrt">
1191
- <rad>
1192
- <radPr>
1193
- <degHide>
1194
- <xsl:attribute name="m:val">on</xsl:attribute>
1195
- </degHide>
1196
- </radPr>
1197
- <deg>
1198
- <xsl:call-template name="CreateArgProp"/>
1199
- </deg>
1200
- <e>
1201
- <xsl:call-template name="CreateArgProp"/>
1202
- <xsl:apply-templates mode="mml"/>
1203
- </e>
1204
- </rad>
1205
- </xsl:when>
1206
- <xsl:otherwise>
1207
- <xsl:choose>
1208
- <xsl:when test="$sLowerCaseNotation='actuarial' or $sLowerCaseNotation='longdiv'"/>
1209
- <xsl:otherwise>
1210
- <borderBox>
1211
- <!-- Dealing with more complex notation attribute -->
1212
- <xsl:variable name="fBox">
1213
- <xsl:choose>
1214
- <!-- Word doesn't have circle and roundedbox concepts, therefore, map both to a
1215
- box. -->
1216
- <xsl:when test="contains($sLowerCaseNotation, 'box') or contains($sLowerCaseNotation, 'circle') or contains($sLowerCaseNotation, 'roundedbox')">1</xsl:when>
1217
- <xsl:otherwise>0</xsl:otherwise>
1218
- </xsl:choose>
1219
- </xsl:variable>
1220
- <xsl:variable name="fTop">
1221
- <xsl:choose>
1222
- <xsl:when test="contains($sLowerCaseNotation, 'top')">1</xsl:when>
1223
- <xsl:otherwise>0</xsl:otherwise>
1224
- </xsl:choose>
1225
- </xsl:variable>
1226
- <xsl:variable name="fBot">
1227
- <xsl:choose>
1228
- <xsl:when test="contains($sLowerCaseNotation, 'bottom')">1</xsl:when>
1229
- <xsl:otherwise>0</xsl:otherwise>
1230
- </xsl:choose>
1231
- </xsl:variable>
1232
- <xsl:variable name="fLeft">
1233
- <xsl:choose>
1234
- <xsl:when test="contains($sLowerCaseNotation, 'left')">1</xsl:when>
1235
- <xsl:otherwise>0</xsl:otherwise>
1236
- </xsl:choose>
1237
- </xsl:variable>
1238
- <xsl:variable name="fRight">
1239
- <xsl:choose>
1240
- <xsl:when test="contains($sLowerCaseNotation, 'right')">1</xsl:when>
1241
- <xsl:otherwise>0</xsl:otherwise>
1242
- </xsl:choose>
1243
- </xsl:variable>
1244
- <xsl:variable name="fStrikeH">
1245
- <xsl:choose>
1246
- <xsl:when test="contains($sLowerCaseNotation, 'horizontalstrike')">1</xsl:when>
1247
- <xsl:otherwise>0</xsl:otherwise>
1248
- </xsl:choose>
1249
- </xsl:variable>
1250
- <xsl:variable name="fStrikeV">
1251
- <xsl:choose>
1252
- <xsl:when test="contains($sLowerCaseNotation, 'verticalstrike')">1</xsl:when>
1253
- <xsl:otherwise>0</xsl:otherwise>
1254
- </xsl:choose>
1255
- </xsl:variable>
1256
- <xsl:variable name="fStrikeBLTR">
1257
- <xsl:choose>
1258
- <xsl:when test="contains($sLowerCaseNotation, 'updiagonalstrike')">1</xsl:when>
1259
- <xsl:otherwise>0</xsl:otherwise>
1260
- </xsl:choose>
1261
- </xsl:variable>
1262
- <xsl:variable name="fStrikeTLBR">
1263
- <xsl:choose>
1264
- <xsl:when test="contains($sLowerCaseNotation, 'downdiagonalstrike')">1</xsl:when>
1265
- <xsl:otherwise>0</xsl:otherwise>
1266
- </xsl:choose>
1267
- </xsl:variable>
1268
-
1269
- <!-- Should we create borderBoxPr?
1270
- We should if the enclosure isn't Word's default, which is
1271
- a plain box -->
1272
- <xsl:if test="$fStrikeH=1 or $fStrikeV=1 or $fStrikeBLTR=1 or $fStrikeTLBR=1 or ($fBox=0 and not($fTop=1 and $fBot=1 and $fLeft=1 and $fRight=1) )">
1273
- <borderBoxPr>
1274
- <xsl:if test="$fBox=0">
1275
- <xsl:if test="$fTop=0">
1276
- <hideTop>
1277
- <xsl:attribute name="m:val">on</xsl:attribute>
1278
- </hideTop>
1279
- </xsl:if>
1280
- <xsl:if test="$fBot=0">
1281
- <hideBot>
1282
- <xsl:attribute name="m:val">on</xsl:attribute>
1283
- </hideBot>
1284
- </xsl:if>
1285
- <xsl:if test="$fLeft=0">
1286
- <hideLeft>
1287
- <xsl:attribute name="m:val">on</xsl:attribute>
1288
- </hideLeft>
1289
- </xsl:if>
1290
- <xsl:if test="$fRight=0">
1291
- <hideRight>
1292
- <xsl:attribute name="m:val">on</xsl:attribute>
1293
- </hideRight>
1294
- </xsl:if>
1295
- </xsl:if>
1296
- <xsl:if test="$fStrikeH=1">
1297
- <strikeH>
1298
- <xsl:attribute name="m:val">on</xsl:attribute>
1299
- </strikeH>
1300
- </xsl:if>
1301
- <xsl:if test="$fStrikeV=1">
1302
- <strikeV>
1303
- <xsl:attribute name="m:val">on</xsl:attribute>
1304
- </strikeV>
1305
- </xsl:if>
1306
- <xsl:if test="$fStrikeBLTR=1">
1307
- <strikeBLTR>
1308
- <xsl:attribute name="m:val">on</xsl:attribute>
1309
- </strikeBLTR>
1310
- </xsl:if>
1311
- <xsl:if test="$fStrikeTLBR=1">
1312
- <strikeTLBR>
1313
- <xsl:attribute name="m:val">on</xsl:attribute>
1314
- </strikeTLBR>
1315
- </xsl:if>
1316
- </borderBoxPr>
1317
- </xsl:if>
1318
- <e>
1319
- <xsl:call-template name="CreateArgProp"/>
1320
- <xsl:apply-templates mode="mml"/>
1321
- </e>
1322
- </borderBox>
1323
- </xsl:otherwise>
1324
- </xsl:choose>
1325
- </xsl:otherwise>
1326
- </xsl:choose>
1327
- </xsl:template>
1328
-
1329
- <!-- %%Template: CreateArgProp
1330
- -->
1331
- <xsl:template name="CreateArgProp">
1332
- <xsl:if test="not(count(ancestor-or-self::mml:mstyle[@scriptlevel='0' or @scriptlevel='1' or @scriptlevel='2'])=0) or not(count(ancestor-or-self::mml:mstyle[@mml:scriptlevel='0' or @mml:scriptlevel='1' or @mml:scriptlevel='2'])=0)">
1333
- <argPr>
1334
- <scrLvl>
1335
- <xsl:attribute name="m:val">
1336
- <xsl:choose>
1337
- <xsl:when test="ancestor-or-self::mml:mstyle[@scriptlevel][1]/@scriptlevel">
1338
- <xsl:value-of select="ancestor-or-self::mml:mstyle[@scriptlevel][1]/@scriptlevel"/>
1339
- </xsl:when>
1340
- <xsl:otherwise>
1341
- <xsl:value-of select="ancestor-or-self::mml:mstyle[@scriptlevel][1]/@mml:scriptlevel"/>
1342
- </xsl:otherwise>
1343
- </xsl:choose>
1344
- </xsl:attribute>
1345
- </scrLvl>
1346
- </argPr>
1347
- </xsl:if>
1348
- </xsl:template>
1349
-
1350
- <!-- %%Template: match mroot
1351
- -->
1352
- <xsl:template mode="mml" match="mml:mroot">
1353
- <rad>
1354
- <radPr>
1355
- <degHide>
1356
- <xsl:attribute name="m:val">off</xsl:attribute>
1357
- </degHide>
1358
- </radPr>
1359
- <deg>
1360
- <xsl:call-template name="CreateArgProp"/>
1361
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1362
- </deg>
1363
- <e>
1364
- <xsl:call-template name="CreateArgProp"/>
1365
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1366
- </e>
1367
- </rad>
1368
- </xsl:template>
1369
-
1370
- <!-- MathML has no concept of a linear fraction. When transforming a linear fraction
1371
- from Omml to MathML, we create the following MathML:
1372
-
1373
- <mml:mrow>
1374
- <mml:mrow>
1375
- // numerator
1376
- </mml:mrow>
1377
- <mml:mo>/</mml:mo>
1378
- <mml:mrow>
1379
- // denominator
1380
- </mml:mrow>
1381
- </mml:mrow>
1382
-
1383
- This template looks for four things:
1384
- 1. ndCur is an mml:mrow
1385
- 2. ndCur has three children
1386
- 3. The second child is an <mml:mo>
1387
- 4. The second child's text is '/'
1388
-
1389
- -->
1390
- <xsl:template name="FLinearFrac">
1391
- <xsl:param name="ndCur" select="."/>
1392
- <xsl:variable name="sNdText">
1393
- <xsl:value-of select="normalize-space($ndCur/*[2])"/>
1394
- </xsl:variable>
1395
-
1396
- <xsl:choose>
1397
- <!-- I spy a linear fraction -->
1398
- <xsl:when test="$ndCur/self::mml:mrow and count($ndCur/*)=3 and $ndCur/*[2][self::mml:mo] and $sNdText='/'">1</xsl:when>
1399
- <xsl:otherwise>0</xsl:otherwise>
1400
- </xsl:choose>
1401
- </xsl:template>
1402
-
1403
-
1404
- <!-- Though presentation mathml can certainly typeset any generic function with the
1405
- appropriate function operator spacing, presentation MathML has no concept of
1406
- a function structure like omml does. In order to preserve the omml <func>
1407
- element, we must establish how an omml <func> element looks in mml. This
1408
- is shown below:
1409
-
1410
- <mml:mrow>
1411
- <mml:mrow>
1412
- // function name
1413
- </mml:mrow>
1414
- <mml:mo>&#x02061;</mml:mo>
1415
- <mml:mrow>
1416
- // function argument
1417
- </mml:mrow>
1418
- </mml:mrow>
1419
-
1420
- This template looks for six things to be true:
1421
- 1. ndCur is an mml:mrow
1422
- 2. ndCur has three children
1423
- 3. The first child is an <mml:mrow>
1424
- 4. The second child is an <mml:mo>
1425
- 5. The third child is an <mml:mrow>
1426
- 6. The second child's text is '&#x02061;'
1427
- -->
1428
- <xsl:template name="FIsFunc">
1429
- <xsl:param name="ndCur" select="."/>
1430
- <xsl:variable name="sNdText">
1431
- <xsl:value-of select="normalize-space($ndCur/*[2])"/>
1432
- </xsl:variable>
1433
-
1434
- <xsl:choose>
1435
- <!-- Is this an omml function -->
1436
- <xsl:when test="count($ndCur/*)=3 and $ndCur/self::*[self::mml:mrow] and $ndCur/*[2][self::mml:mo] and $sNdText='⁡'">1</xsl:when>
1437
- <xsl:otherwise>0</xsl:otherwise>
1438
- </xsl:choose>
1439
- </xsl:template>
1440
-
1441
-
1442
- <!-- Given the node of the linear fraction's parent mrow,
1443
- make a linear fraction -->
1444
- <xsl:template name="MakeLinearFraction">
1445
- <xsl:param name="ndCur" select="."/>
1446
- <f>
1447
- <fPr>
1448
- <type>
1449
- <xsl:attribute name="m:val">lin</xsl:attribute>
1450
- </type>
1451
- </fPr>
1452
- <num>
1453
- <xsl:call-template name="CreateArgProp"/>
1454
- <xsl:apply-templates mode="mml" select="$ndCur/*[1]"/>
1455
- </num>
1456
- <den>
1457
- <xsl:call-template name="CreateArgProp"/>
1458
- <xsl:apply-templates mode="mml" select="$ndCur/*[3]"/>
1459
- </den>
1460
- </f>
1461
- </xsl:template>
1462
-
1463
-
1464
- <!-- Given the node of the function's parent mrow,
1465
- make an omml function -->
1466
- <xsl:template name="WriteFunc">
1467
- <xsl:param name="ndCur" select="."/>
1468
-
1469
- <func>
1470
- <fName>
1471
- <xsl:apply-templates mode="mml" select="$ndCur/child::*[1]"/>
1472
- </fName>
1473
- <e>
1474
- <xsl:apply-templates mode="mml" select="$ndCur/child::*[3]"/>
1475
- </e>
1476
- </func>
1477
- </xsl:template>
1478
-
1479
-
1480
- <!-- MathML doesn't have the concept of nAry structures. The best approximation
1481
- to these is to have some under/over or sub/sup followed by an mrow or mstyle.
1482
-
1483
- In the case that we've come across some under/over or sub/sup that contains an
1484
- nAry operator, this function handles the following sibling to the nAry structure.
1485
-
1486
- If the following sibling is:
1487
-
1488
- mml:mstyle, then apply templates to the children of this mml:mstyle
1489
-
1490
- mml:mrow, determine if this mrow is a linear fraction
1491
- (see comments for FlinearFrac template).
1492
- If so, make an Omml linear fraction.
1493
- If not, apply templates as was done for mml:mstyle.
1494
-
1495
- -->
1496
- <xsl:template name="NaryHandleMrowMstyle">
1497
- <xsl:param name="ndCur" select="."/>
1498
- <!-- if the next sibling is an mrow, pull it in by
1499
- doing whatever we would have done to its children.
1500
- The mrow itself will be skipped, see template above. -->
1501
- <xsl:choose>
1502
- <xsl:when test="$ndCur[self::mml:mrow]">
1503
- <!-- Check for linear fraction -->
1504
- <xsl:variable name="fLinearFrac">
1505
- <xsl:call-template name="FLinearFrac">
1506
- <xsl:with-param name="ndCur" select="$ndCur"/>
1507
- </xsl:call-template>
1508
- </xsl:variable>
1509
- <xsl:choose>
1510
- <xsl:when test="$fLinearFrac=1">
1511
- <xsl:call-template name="MakeLinearFraction">
1512
- <xsl:with-param name="ndCur" select="$ndCur"/>
1513
- </xsl:call-template>
1514
- </xsl:when>
1515
- <xsl:otherwise>
1516
- <xsl:variable name="fFunc">
1517
- <xsl:call-template name="FIsFunc">
1518
- <xsl:with-param name="ndCur" select="."/>
1519
- </xsl:call-template>
1520
- </xsl:variable>
1521
- <xsl:choose>
1522
- <xsl:when test="$fFunc=1">
1523
- <xsl:call-template name="WriteFunc">
1524
- <xsl:with-param name="ndCur" select="."/>
1525
- </xsl:call-template>
1526
- </xsl:when>
1527
- <xsl:otherwise>
1528
- <xsl:apply-templates mode="mml" select="$ndCur/*"/>
1529
- </xsl:otherwise>
1530
- </xsl:choose>
1531
- </xsl:otherwise>
1532
- </xsl:choose>
1533
- </xsl:when>
1534
- <xsl:when test="$ndCur[self::mml:mstyle]">
1535
- <xsl:apply-templates mode="mml" select="$ndCur/*"/>
1536
- </xsl:when>
1537
- </xsl:choose>
1538
- </xsl:template>
1539
-
1540
-
1541
- <!-- MathML munder/mover can represent several Omml constructs
1542
- (m:bar, m:limLow, m:limUpp, m:acc, m:groupChr, etc.). The following
1543
- templates (FIsBar, FIsAcc, and FIsGroupChr) are used to determine
1544
- which of these Omml constructs an munder/mover should be translated into. -->
1545
-
1546
- <!-- Note: ndCur should only be an munder/mover MathML element.
1547
-
1548
- ndCur should be interpretted as an m:bar if
1549
- 1) its respective accent attribute is not true
1550
- 2) its second child is an mml:mo
1551
- 3) the character of the mml:mo is the correct under/over bar. -->
1552
- <xsl:template name="FIsBar">
1553
- <xsl:param name="ndCur"/>
1554
- <xsl:variable name="fUnder">
1555
- <xsl:choose>
1556
- <xsl:when test="$ndCur[self::mml:munder]">1</xsl:when>
1557
- <xsl:otherwise>0</xsl:otherwise>
1558
- </xsl:choose>
1559
- </xsl:variable>
1560
- <xsl:variable name="sLowerCaseAccent">
1561
- <xsl:choose>
1562
- <xsl:when test="$fUnder=1">
1563
- <xsl:choose>
1564
- <xsl:when test="$ndCur/@accentunder">
1565
- <xsl:value-of select="translate($ndCur/@accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
1566
- </xsl:when>
1567
- <xsl:otherwise>
1568
- <xsl:value-of select="translate($ndCur/@mml:accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
1569
- </xsl:otherwise>
1570
- </xsl:choose>
1571
- </xsl:when>
1572
- <xsl:otherwise>
1573
- <xsl:choose>
1574
- <xsl:when test="$ndCur/@accent">
1575
- <xsl:value-of select="translate($ndCur/@accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1576
- </xsl:when>
1577
- <xsl:otherwise>
1578
- <xsl:value-of select="translate($ndCur/@mml:accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1579
- </xsl:otherwise>
1580
- </xsl:choose>
1581
- </xsl:otherwise>
1582
- </xsl:choose>
1583
- </xsl:variable>
1584
- <xsl:variable name="fAccent">
1585
- <xsl:choose>
1586
- <xsl:when test="$sLowerCaseAccent='true'">1</xsl:when>
1587
- <xsl:otherwise>0</xsl:otherwise>
1588
- </xsl:choose>
1589
- </xsl:variable>
1590
-
1591
- <xsl:choose>
1592
- <!-- The script is unaccented and the second child is an mo -->
1593
- <xsl:when test="$fAccent = 0 and $ndCur/child::*[2]/self::mml:mo">
1594
- <xsl:variable name="sOperator">
1595
- <xsl:value-of select="$ndCur/child::*[2]"/>
1596
- </xsl:variable>
1597
- <xsl:choose>
1598
- <!-- Should we write an underbar? -->
1599
- <xsl:when test="$fUnder = 1">
1600
- <xsl:choose>
1601
- <xsl:when test="$sOperator = '̲'">1</xsl:when>
1602
- <xsl:otherwise>0</xsl:otherwise>
1603
- </xsl:choose>
1604
- </xsl:when>
1605
- <!-- Should we write an overbar? -->
1606
- <xsl:otherwise>
1607
- <xsl:choose>
1608
- <xsl:when test="$sOperator = '¯'">1</xsl:when>
1609
- <xsl:otherwise>0</xsl:otherwise>
1610
- </xsl:choose>
1611
- </xsl:otherwise>
1612
- </xsl:choose>
1613
- </xsl:when>
1614
- <xsl:otherwise>0</xsl:otherwise>
1615
- </xsl:choose>
1616
- </xsl:template>
1617
-
1618
- <!-- Note: ndCur should only be an mover MathML element.
1619
-
1620
- ndCur should be interpretted as an m:acc if
1621
- 1) its accent attribute is true
1622
- 2) its second child is an mml:mo
1623
- 3) there is only one character in the mml:mo -->
1624
- <xsl:template name="FIsAcc">
1625
- <xsl:param name="ndCur" select="."/>
1626
-
1627
- <xsl:variable name="sLowerCaseAccent">
1628
- <xsl:choose>
1629
- <xsl:when test="$ndCur/@accent">
1630
- <xsl:value-of select="translate($ndCur/@accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1631
- </xsl:when>
1632
- <xsl:otherwise>
1633
- <xsl:value-of select="translate($ndCur/@mml:accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1634
- </xsl:otherwise>
1635
- </xsl:choose>
1636
- </xsl:variable>
1637
- <xsl:variable name="fAccent">
1638
- <xsl:choose>
1639
- <xsl:when test="$sLowerCaseAccent='true'">1</xsl:when>
1640
- <xsl:otherwise>0</xsl:otherwise>
1641
- </xsl:choose>
1642
- </xsl:variable>
1643
-
1644
- <xsl:choose>
1645
- <!-- The script is accented and the second child is an mo -->
1646
- <xsl:when test="$fAccent = 1 and $ndCur/child::*[2] = mml:mo">
1647
- <xsl:variable name="sOperator">
1648
- <xsl:value-of select="$ndCur/child::*[2]"/>
1649
- </xsl:variable>
1650
- <xsl:choose>
1651
- <!-- There is only one operator, this is a valid Omml accent! -->
1652
- <xsl:when test="string-length($sOperator) = 1">1</xsl:when>
1653
- <!-- More than one accented operator. This isn't a valid
1654
- omml accent -->
1655
- <xsl:otherwise>0</xsl:otherwise>
1656
- </xsl:choose>
1657
- </xsl:when>
1658
- <!-- Not accented, not an operator, or both, but in any case, this is
1659
- not an Omml accent. -->
1660
- <xsl:otherwise>0</xsl:otherwise>
1661
- </xsl:choose>
1662
- </xsl:template>
1663
-
1664
-
1665
- <!-- Is ndCur a groupChr?
1666
- ndCur is a groupChr if:
1667
-
1668
- 1. The accent is false (note: accent attribute
1669
- for munder is accentunder).
1670
- 2. ndCur is an munder or mover.
1671
- 3. ndCur has two children
1672
- 4. Of these two children, one is an mml:mo and the other is an mml:mrow
1673
- 5. The number of characters in the mml:mo is 1.
1674
-
1675
- If all of the above are true, then return 1, else return 0.
1676
- -->
1677
- <xsl:template name="FIsGroupChr">
1678
- <xsl:param name="ndCur" select="."/>
1679
- <xsl:variable name="fUnder">
1680
- <xsl:choose>
1681
- <xsl:when test="$ndCur[self::mml:munder]">1</xsl:when>
1682
- <xsl:otherwise>0</xsl:otherwise>
1683
- </xsl:choose>
1684
- </xsl:variable>
1685
- <xsl:variable name="sLowerCaseAccent">
1686
- <xsl:choose>
1687
- <xsl:when test="$fUnder=1">
1688
- <xsl:choose>
1689
- <xsl:when test="$ndCur/@accentunder">
1690
- <xsl:value-of select="translate($ndCur/@accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
1691
- </xsl:when>
1692
- <xsl:otherwise>
1693
- <xsl:value-of select="translate($ndCur/@mml:accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
1694
- </xsl:otherwise>
1695
- </xsl:choose>
1696
- </xsl:when>
1697
- <xsl:otherwise>
1698
- <xsl:choose>
1699
- <xsl:when test="$ndCur/@accent">
1700
- <xsl:value-of select="translate($ndCur/@accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1701
- </xsl:when>
1702
- <xsl:otherwise>
1703
- <xsl:value-of select="translate($ndCur/@mml:accent, $StrUCAlphabet, $StrLCAlphabet)"/>
1704
- </xsl:otherwise>
1705
- </xsl:choose>
1706
- </xsl:otherwise>
1707
- </xsl:choose>
1708
- </xsl:variable>
1709
-
1710
- <xsl:variable name="fAccentFalse">
1711
- <xsl:choose>
1712
- <xsl:when test="$sLowerCaseAccent='false'">1</xsl:when>
1713
- <xsl:otherwise>0</xsl:otherwise>
1714
- </xsl:choose>
1715
- </xsl:variable>
1716
-
1717
- <xsl:choose>
1718
- <xsl:when test="$fAccentFalse=1 and $ndCur[self::mml:munder or self::mml:mover] and count($ndCur/child::*)=2 and (($ndCur/child::*[1][self::mml:mrow] and $ndCur/child::*[2][self::mml:mo]) or ($ndCur/child::*[1][self::mml:mo] and $ndCur/child::*[2][self::mml:mrow]))">
1719
- <xsl:variable name="sOperator">
1720
- <xsl:value-of select="$ndCur/child::mml:mo"/>
1721
- </xsl:variable>
1722
- <xsl:choose>
1723
- <xsl:when test="string-length($sOperator) &lt;= 1">1</xsl:when>
1724
- <xsl:otherwise>0</xsl:otherwise>
1725
- </xsl:choose>
1726
- </xsl:when>
1727
-
1728
- <xsl:otherwise>0</xsl:otherwise>
1729
- </xsl:choose>
1730
- </xsl:template>
1731
-
1732
-
1733
- <!-- %%Template: match munder
1734
- -->
1735
- <xsl:template mode="mml" match="mml:munder">
1736
- <xsl:variable name="fNary">
1737
- <xsl:call-template name="isNary">
1738
- <xsl:with-param name="ndCur" select="child::*[1]"/>
1739
- </xsl:call-template>
1740
- </xsl:variable>
1741
- <xsl:choose>
1742
- <xsl:when test="$fNary='true'">
1743
- <nary>
1744
- <xsl:call-template name="CreateNaryProp">
1745
- <xsl:with-param name="chr">
1746
- <xsl:value-of select="normalize-space(child::*[1])"/>
1747
- </xsl:with-param>
1748
- <xsl:with-param name="sMathmlType" select="'munder'"/>
1749
- </xsl:call-template>
1750
- <sub>
1751
- <xsl:call-template name="CreateArgProp"/>
1752
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1753
- </sub>
1754
- <sup>
1755
- <xsl:call-template name="CreateArgProp"/>
1756
- </sup>
1757
- <e>
1758
- <xsl:call-template name="CreateArgProp"/>
1759
- <xsl:call-template name="NaryHandleMrowMstyle">
1760
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
1761
- </xsl:call-template>
1762
- </e>
1763
- </nary>
1764
- </xsl:when>
1765
- <xsl:otherwise>
1766
- <!-- Should this munder be interpreted as an OMML m:bar? -->
1767
- <xsl:variable name="fIsBar">
1768
- <xsl:call-template name="FIsBar">
1769
- <xsl:with-param name="ndCur" select="."/>
1770
- </xsl:call-template>
1771
- </xsl:variable>
1772
- <xsl:choose>
1773
- <xsl:when test="$fIsBar=1">
1774
- <bar>
1775
- <barPr>
1776
- <pos m:val="bot"/>
1777
- </barPr>
1778
- <e>
1779
- <xsl:call-template name="CreateArgProp"/>
1780
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1781
- </e>
1782
- </bar>
1783
- </xsl:when>
1784
- <xsl:otherwise>
1785
- <!-- It isn't an integral or underbar, is this a groupChr? -->
1786
- <xsl:variable name="fGroupChr">
1787
- <xsl:call-template name="FIsGroupChr">
1788
- <xsl:with-param name="ndCur" select="."/>
1789
- </xsl:call-template>
1790
- </xsl:variable>
1791
- <xsl:choose>
1792
- <xsl:when test="$fGroupChr=1">
1793
- <groupChr>
1794
- <xsl:call-template name="CreateGroupChrPr">
1795
- <xsl:with-param name="chr">
1796
- <xsl:value-of select="mml:mo"/>
1797
- </xsl:with-param>
1798
- <xsl:with-param name="pos">
1799
- <xsl:choose>
1800
- <xsl:when test="child::*[1][self::mml:mrow]">bot</xsl:when>
1801
- <xsl:otherwise>top</xsl:otherwise>
1802
- </xsl:choose>
1803
- </xsl:with-param>
1804
- <xsl:with-param name="vertJc">top</xsl:with-param>
1805
- </xsl:call-template>
1806
- <e>
1807
- <xsl:apply-templates mode="mml" select="mml:mrow"/>
1808
- </e>
1809
- </groupChr>
1810
- </xsl:when>
1811
- <xsl:otherwise>
1812
- <!-- Generic munder -->
1813
- <limLow>
1814
- <e>
1815
- <xsl:call-template name="CreateArgProp"/>
1816
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1817
- </e>
1818
- <lim>
1819
- <xsl:call-template name="CreateArgProp"/>
1820
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1821
- </lim>
1822
- </limLow>
1823
- </xsl:otherwise>
1824
- </xsl:choose>
1825
- </xsl:otherwise>
1826
- </xsl:choose>
1827
- </xsl:otherwise>
1828
- </xsl:choose>
1829
- </xsl:template>
1830
-
1831
-
1832
- <!-- Given the values for chr, pos, and vertJc, create an omml
1833
- groupChr's groupChrPr -->
1834
- <xsl:template name="CreateGroupChrPr">
1835
- <xsl:param name="chr">⏟</xsl:param>
1836
- <xsl:param name="pos" select="bot"/>
1837
- <xsl:param name="vertJc" select="top"/>
1838
- <groupChrPr>
1839
- <chr>
1840
- <xsl:attribute name="m:val">
1841
- <xsl:value-of select="$chr"/>
1842
- </xsl:attribute>
1843
- </chr>
1844
- <pos>
1845
- <xsl:attribute name="m:val">
1846
- <xsl:value-of select="$pos"/>
1847
- </xsl:attribute>
1848
- </pos>
1849
- <vertJc>
1850
- <xsl:attribute name="m:val">
1851
- <xsl:value-of select="$vertJc"/>
1852
- </xsl:attribute>
1853
- </vertJc>
1854
- </groupChrPr>
1855
- </xsl:template>
1856
-
1857
-
1858
- <!-- %%Template: match mover
1859
- -->
1860
- <xsl:template mode="mml" match="mml:mover">
1861
- <xsl:variable name="fNary">
1862
- <xsl:call-template name="isNary">
1863
- <xsl:with-param name="ndCur" select="child::*[1]"/>
1864
- </xsl:call-template>
1865
- </xsl:variable>
1866
- <xsl:choose>
1867
- <xsl:when test="$fNary='true'">
1868
- <nary>
1869
- <xsl:call-template name="CreateNaryProp">
1870
- <xsl:with-param name="chr">
1871
- <xsl:value-of select="normalize-space(child::*[1])"/>
1872
- </xsl:with-param>
1873
- <xsl:with-param name="sMathmlType" select="'mover'"/>
1874
- </xsl:call-template>
1875
- <sub>
1876
- <xsl:call-template name="CreateArgProp"/>
1877
- </sub>
1878
- <sup>
1879
- <xsl:call-template name="CreateArgProp"/>
1880
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1881
- </sup>
1882
- <e>
1883
- <xsl:call-template name="CreateArgProp"/>
1884
- <xsl:call-template name="NaryHandleMrowMstyle">
1885
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
1886
- </xsl:call-template>
1887
- </e>
1888
- </nary>
1889
- </xsl:when>
1890
- <xsl:otherwise>
1891
- <!-- Should this munder be interpreted as an OMML m:bar or m:acc? -->
1892
-
1893
- <!-- Check to see if this is an m:bar -->
1894
- <xsl:variable name="fIsBar">
1895
- <xsl:call-template name="FIsBar">
1896
- <xsl:with-param name="ndCur" select="."/>
1897
- </xsl:call-template>
1898
- </xsl:variable>
1899
- <xsl:choose>
1900
- <xsl:when test="$fIsBar = 1">
1901
- <bar>
1902
- <barPr>
1903
- <pos m:val="top"/>
1904
- </barPr>
1905
- <e>
1906
- <xsl:call-template name="CreateArgProp"/>
1907
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1908
- </e>
1909
- </bar>
1910
- </xsl:when>
1911
- <xsl:otherwise>
1912
- <!-- Not an m:bar, should it be an m:acc? -->
1913
- <xsl:variable name="fIsAcc">
1914
- <xsl:call-template name="FIsAcc">
1915
- <xsl:with-param name="ndCur" select="."/>
1916
- </xsl:call-template>
1917
- </xsl:variable>
1918
- <xsl:choose>
1919
- <xsl:when test="$fIsAcc=1">
1920
- <acc>
1921
- <accPr>
1922
- <chr>
1923
- <xsl:attribute name="m:val">
1924
- <xsl:value-of select="child::*[2]"/>
1925
- </xsl:attribute>
1926
- </chr>
1927
- </accPr>
1928
- <e>
1929
- <xsl:call-template name="CreateArgProp"/>
1930
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1931
- </e>
1932
- </acc>
1933
- </xsl:when>
1934
- <xsl:otherwise>
1935
- <!-- This isn't an integral, overbar or accent,
1936
- could it be a groupChr? -->
1937
- <xsl:variable name="fGroupChr">
1938
- <xsl:call-template name="FIsGroupChr">
1939
- <xsl:with-param name="ndCur" select="."/>
1940
- </xsl:call-template>
1941
- </xsl:variable>
1942
- <xsl:choose>
1943
- <xsl:when test="$fGroupChr=1">
1944
- <groupChr>
1945
- <xsl:call-template name="CreateGroupChrPr">
1946
- <xsl:with-param name="chr">
1947
- <xsl:value-of select="mml:mo"/>
1948
- </xsl:with-param>
1949
- <xsl:with-param name="pos">
1950
- <xsl:choose>
1951
- <xsl:when test="child::*[1][self::mml:mrow]">top</xsl:when>
1952
- <xsl:otherwise>bot</xsl:otherwise>
1953
- </xsl:choose>
1954
- </xsl:with-param>
1955
- <xsl:with-param name="vertJc">bot</xsl:with-param>
1956
- </xsl:call-template>
1957
- <e>
1958
- <xsl:apply-templates mode="mml" select="mml:mrow"/>
1959
- </e>
1960
- </groupChr>
1961
- </xsl:when>
1962
- <xsl:otherwise>
1963
- <!-- Generic mover -->
1964
- <limUpp>
1965
- <e>
1966
- <xsl:call-template name="CreateArgProp"/>
1967
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
1968
- </e>
1969
- <lim>
1970
- <xsl:call-template name="CreateArgProp"/>
1971
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
1972
- </lim>
1973
- </limUpp>
1974
- </xsl:otherwise>
1975
- </xsl:choose>
1976
- </xsl:otherwise>
1977
- </xsl:choose>
1978
- </xsl:otherwise>
1979
- </xsl:choose>
1980
- </xsl:otherwise>
1981
- </xsl:choose>
1982
- </xsl:template>
1983
-
1984
-
1985
- <!-- %%Template: match munderover
1986
- -->
1987
- <xsl:template mode="mml" match="mml:munderover">
1988
- <xsl:variable name="fNary">
1989
- <xsl:call-template name="isNary">
1990
- <xsl:with-param name="ndCur" select="child::*[1]"/>
1991
- </xsl:call-template>
1992
- </xsl:variable>
1993
- <xsl:choose>
1994
- <xsl:when test="$fNary='true'">
1995
- <nary>
1996
- <xsl:call-template name="CreateNaryProp">
1997
- <xsl:with-param name="chr">
1998
- <xsl:value-of select="normalize-space(child::*[1])"/>
1999
- </xsl:with-param>
2000
- <xsl:with-param name="sMathmlType" select="'munderover'"/>
2001
- </xsl:call-template>
2002
- <sub>
2003
- <xsl:call-template name="CreateArgProp"/>
2004
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2005
- </sub>
2006
- <sup>
2007
- <xsl:call-template name="CreateArgProp"/>
2008
- <xsl:apply-templates mode="mml" select="child::*[3]"/>
2009
- </sup>
2010
- <e>
2011
- <xsl:call-template name="CreateArgProp"/>
2012
- <xsl:call-template name="NaryHandleMrowMstyle">
2013
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
2014
- </xsl:call-template>
2015
- </e>
2016
- </nary>
2017
- </xsl:when>
2018
- <xsl:otherwise>
2019
- <limUpp>
2020
- <e>
2021
- <xsl:call-template name="CreateArgProp"/>
2022
- <limLow>
2023
- <e>
2024
- <xsl:call-template name="CreateArgProp"/>
2025
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2026
- </e>
2027
- <lim>
2028
- <xsl:call-template name="CreateArgProp"/>
2029
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2030
- </lim>
2031
- </limLow>
2032
- </e>
2033
- <lim>
2034
- <xsl:call-template name="CreateArgProp"/>
2035
- <xsl:apply-templates mode="mml" select="child::*[3]"/>
2036
- </lim>
2037
- </limUpp>
2038
- </xsl:otherwise>
2039
- </xsl:choose>
2040
- </xsl:template>
2041
-
2042
- <!-- %%Template: match mfenced -->
2043
- <xsl:template mode="mml" match="mml:mfenced">
2044
- <d>
2045
- <xsl:call-template name="CreateDelimProp">
2046
- <xsl:with-param name="fChOpenValid">
2047
- <xsl:choose>
2048
- <xsl:when test="@open">
2049
- <xsl:value-of select="1"/>
2050
- </xsl:when>
2051
- <xsl:when test="@mml:open">
2052
- <xsl:value-of select="1"/>
2053
- </xsl:when>
2054
- <xsl:otherwise>
2055
- <xsl:value-of select="0"/>
2056
- </xsl:otherwise>
2057
- </xsl:choose>
2058
- </xsl:with-param>
2059
- <xsl:with-param name="chOpen">
2060
- <xsl:choose>
2061
- <xsl:when test="@open">
2062
- <xsl:value-of select="@open"/>
2063
- </xsl:when>
2064
- <xsl:otherwise>
2065
- <xsl:value-of select="@mml:open"/>
2066
- </xsl:otherwise>
2067
- </xsl:choose>
2068
- </xsl:with-param>
2069
- <xsl:with-param name="fChSeparatorsValid">
2070
- <xsl:choose>
2071
- <xsl:when test="@separators">
2072
- <xsl:value-of select="1"/>
2073
- </xsl:when>
2074
- <xsl:when test="@mml:separators">
2075
- <xsl:value-of select="1"/>
2076
- </xsl:when>
2077
- <xsl:otherwise>
2078
- <xsl:value-of select="0"/>
2079
- </xsl:otherwise>
2080
- </xsl:choose>
2081
- </xsl:with-param>
2082
- <xsl:with-param name="chSeparators">
2083
- <xsl:choose>
2084
- <xsl:when test="@separators">
2085
- <xsl:value-of select="@separators"/>
2086
- </xsl:when>
2087
- <xsl:otherwise>
2088
- <xsl:value-of select="@mml:separators"/>
2089
- </xsl:otherwise>
2090
- </xsl:choose>
2091
- </xsl:with-param>
2092
- <xsl:with-param name="fChCloseValid">
2093
- <xsl:choose>
2094
- <xsl:when test="@close">
2095
- <xsl:value-of select="1"/>
2096
- </xsl:when>
2097
- <xsl:when test="@mml:close">
2098
- <xsl:value-of select="1"/>
2099
- </xsl:when>
2100
- <xsl:otherwise>
2101
- <xsl:value-of select="0"/>
2102
- </xsl:otherwise>
2103
- </xsl:choose>
2104
- </xsl:with-param>
2105
- <xsl:with-param name="chClose">
2106
- <xsl:choose>
2107
- <xsl:when test="@close">
2108
- <xsl:value-of select="@close"/>
2109
- </xsl:when>
2110
- <xsl:otherwise>
2111
- <xsl:value-of select="@mml:close"/>
2112
- </xsl:otherwise>
2113
- </xsl:choose>
2114
- </xsl:with-param>
2115
- </xsl:call-template>
2116
- <xsl:for-each select="*">
2117
- <e>
2118
- <xsl:call-template name="CreateArgProp"/>
2119
- <xsl:apply-templates mode="mml" select="."/>
2120
- </e>
2121
- </xsl:for-each>
2122
- </d>
2123
- </xsl:template>
2124
-
2125
- <!-- %%Template: CreateDelimProp
2126
-
2127
- Given the characters to use as open, close and separators for
2128
- the delim object, create the m:dPr (delim properties).
2129
-
2130
- MathML can have any number of separators in an mfenced object, but
2131
- OMML can only represent one separator for each d (delim) object.
2132
- So, we pick the first separator specified.
2133
- -->
2134
- <xsl:template name="CreateDelimProp">
2135
- <xsl:param name="fChOpenValid"/>
2136
- <xsl:param name="chOpen"/>
2137
- <xsl:param name="fChSeparatorsValid"/>
2138
- <xsl:param name="chSeparators"/>
2139
- <xsl:param name="fChCloseValid"/>
2140
- <xsl:param name="chClose"/>
2141
- <xsl:variable name="chSep" select="substring($chSeparators, 1, 1)"/>
2142
-
2143
- <!-- do we need a dPr at all? If everything's at its default value, then
2144
- don't bother at all -->
2145
- <xsl:if test="($fChOpenValid=1 and not($chOpen = '(')) or ($fChCloseValid=1 and not($chClose = ')')) or not($chSep = '|')">
2146
- <dPr>
2147
- <!-- the default for MathML and OMML is '('. -->
2148
- <xsl:if test="$fChOpenValid=1 and not($chOpen = '(')">
2149
- <begChr>
2150
- <xsl:attribute name="m:val">
2151
- <xsl:value-of select="$chOpen"/>
2152
- </xsl:attribute>
2153
- </begChr>
2154
- </xsl:if>
2155
-
2156
- <!-- the default for MathML is ',' and for OMML is '|' -->
2157
-
2158
- <xsl:choose>
2159
- <!-- matches OMML's default, don't bother to write anything out -->
2160
- <xsl:when test="$chSep = '|'"/>
2161
-
2162
- <!-- Not specified, use MathML's default. We test against
2163
- the existence of the actual attribute, not the substring -->
2164
- <xsl:when test="$fChSeparatorsValid=0">
2165
- <sepChr m:val=","/>
2166
- </xsl:when>
2167
-
2168
- <xsl:otherwise>
2169
- <sepChr>
2170
- <xsl:attribute name="m:val">
2171
- <xsl:value-of select="$chSep"/>
2172
- </xsl:attribute>
2173
- </sepChr>
2174
- </xsl:otherwise>
2175
- </xsl:choose>
2176
-
2177
- <!-- the default for MathML and OMML is ')'. -->
2178
- <xsl:if test="$fChCloseValid=1 and not($chClose = ')')">
2179
- <endChr>
2180
- <xsl:attribute name="m:val">
2181
- <xsl:value-of select="$chClose"/>
2182
- </xsl:attribute>
2183
- </endChr>
2184
- </xsl:if>
2185
- </dPr>
2186
- </xsl:if>
2187
- </xsl:template>
2188
-
2189
- <!-- %%Template: OutputMs
2190
- -->
2191
- <xsl:template name="OutputMs">
2192
- <xsl:param name="msCur"/>
2193
- <xsl:choose>
2194
- <xsl:when test="(not($msCur/@lquote) or $msCur/@lquote='') and (not($msCur/@mml:lquote) or $msCur/@mml:lquote='')">
2195
- <xsl:text>"</xsl:text>
2196
- </xsl:when>
2197
- <xsl:otherwise>
2198
- <xsl:choose>
2199
- <xsl:when test="$msCur/@lquote">
2200
- <xsl:value-of select="$msCur/@lquote"/>
2201
- </xsl:when>
2202
- <xsl:otherwise>
2203
- <xsl:value-of select="$msCur/@mml:lquote"/>
2204
- </xsl:otherwise>
2205
- </xsl:choose>
2206
- </xsl:otherwise>
2207
- </xsl:choose>
2208
- <xsl:value-of select="normalize-space($msCur)"/>
2209
- <xsl:choose>
2210
- <xsl:when test="(not($msCur/@rquote) or $msCur/@rquote='') and (not($msCur/@mml:rquote) or $msCur/@mml:rquote='')">
2211
- <xsl:text>"</xsl:text>
2212
- </xsl:when>
2213
- <xsl:otherwise>
2214
- <xsl:choose>
2215
- <xsl:when test="$msCur/@rquote">
2216
- <xsl:value-of select="$msCur/@rquote"/>
2217
- </xsl:when>
2218
- <xsl:otherwise>
2219
- <xsl:value-of select="$msCur/@mml:rquote"/>
2220
- </xsl:otherwise>
2221
- </xsl:choose>
2222
- </xsl:otherwise>
2223
- </xsl:choose>
2224
- </xsl:template>
2225
-
2226
- <!-- %%Template: match msub
2227
- -->
2228
- <xsl:template mode="mml" match="mml:msub">
2229
- <xsl:variable name="fNary">
2230
- <xsl:call-template name="isNary">
2231
- <xsl:with-param name="ndCur" select="child::*[1]"/>
2232
- </xsl:call-template>
2233
- </xsl:variable>
2234
- <xsl:choose>
2235
- <xsl:when test="$fNary='true'">
2236
- <nary>
2237
- <xsl:call-template name="CreateNaryProp">
2238
- <xsl:with-param name="chr">
2239
- <xsl:value-of select="normalize-space(child::*[1])"/>
2240
- </xsl:with-param>
2241
- <xsl:with-param name="sMathmlType" select="'msub'"/>
2242
- </xsl:call-template>
2243
- <sub>
2244
- <xsl:call-template name="CreateArgProp"/>
2245
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2246
- </sub>
2247
- <sup>
2248
- <xsl:call-template name="CreateArgProp"/>
2249
- </sup>
2250
- <e>
2251
- <xsl:call-template name="CreateArgProp"/>
2252
- <xsl:call-template name="NaryHandleMrowMstyle">
2253
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
2254
- </xsl:call-template>
2255
- </e>
2256
- </nary>
2257
- </xsl:when>
2258
- <xsl:otherwise>
2259
- <sSub>
2260
- <e>
2261
- <xsl:call-template name="CreateArgProp"/>
2262
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2263
- </e>
2264
- <sub>
2265
- <xsl:call-template name="CreateArgProp"/>
2266
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2267
- </sub>
2268
- </sSub>
2269
- </xsl:otherwise>
2270
- </xsl:choose>
2271
- </xsl:template>
2272
-
2273
- <!-- %%Template: match msup
2274
- -->
2275
- <xsl:template mode="mml" match="mml:msup">
2276
- <xsl:variable name="fNary">
2277
- <xsl:call-template name="isNary">
2278
- <xsl:with-param name="ndCur" select="child::*[1]"/>
2279
- </xsl:call-template>
2280
- </xsl:variable>
2281
- <xsl:choose>
2282
- <xsl:when test="$fNary='true'">
2283
- <nary>
2284
- <xsl:call-template name="CreateNaryProp">
2285
- <xsl:with-param name="chr">
2286
- <xsl:value-of select="normalize-space(child::*[1])"/>
2287
- </xsl:with-param>
2288
- <xsl:with-param name="sMathmlType" select="'msup'"/>
2289
- </xsl:call-template>
2290
- <sub>
2291
- <xsl:call-template name="CreateArgProp"/>
2292
- </sub>
2293
- <sup>
2294
- <xsl:call-template name="CreateArgProp"/>
2295
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2296
- </sup>
2297
- <e>
2298
- <xsl:call-template name="CreateArgProp"/>
2299
- <xsl:call-template name="NaryHandleMrowMstyle">
2300
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
2301
- </xsl:call-template>
2302
- </e>
2303
- </nary>
2304
- </xsl:when>
2305
- <xsl:otherwise>
2306
- <sSup>
2307
- <e>
2308
- <xsl:call-template name="CreateArgProp"/>
2309
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2310
- </e>
2311
- <sup>
2312
- <xsl:call-template name="CreateArgProp"/>
2313
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2314
- </sup>
2315
- </sSup>
2316
- </xsl:otherwise>
2317
- </xsl:choose>
2318
- </xsl:template>
2319
-
2320
- <!-- %%Template: match msubsup
2321
- -->
2322
- <xsl:template mode="mml" match="mml:msubsup">
2323
- <xsl:variable name="fNary">
2324
- <xsl:call-template name="isNary">
2325
- <xsl:with-param name="ndCur" select="child::*[1]"/>
2326
- </xsl:call-template>
2327
- </xsl:variable>
2328
- <xsl:choose>
2329
- <xsl:when test="$fNary='true'">
2330
- <nary>
2331
- <xsl:call-template name="CreateNaryProp">
2332
- <xsl:with-param name="chr">
2333
- <xsl:value-of select="normalize-space(child::*[1])"/>
2334
- </xsl:with-param>
2335
- <xsl:with-param name="sMathmlType" select="'msubsup'"/>
2336
- </xsl:call-template>
2337
- <sub>
2338
- <xsl:call-template name="CreateArgProp"/>
2339
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2340
- </sub>
2341
- <sup>
2342
- <xsl:call-template name="CreateArgProp"/>
2343
- <xsl:apply-templates mode="mml" select="child::*[3]"/>
2344
- </sup>
2345
- <e>
2346
- <xsl:call-template name="CreateArgProp"/>
2347
- <xsl:call-template name="NaryHandleMrowMstyle">
2348
- <xsl:with-param name="ndCur" select="following-sibling::*[1]"/>
2349
- </xsl:call-template>
2350
- </e>
2351
- </nary>
2352
- </xsl:when>
2353
- <xsl:otherwise>
2354
- <sSubSup>
2355
- <e>
2356
- <xsl:call-template name="CreateArgProp"/>
2357
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2358
- </e>
2359
- <sub>
2360
- <xsl:call-template name="CreateArgProp"/>
2361
- <xsl:apply-templates mode="mml" select="child::*[2]"/>
2362
- </sub>
2363
- <sup>
2364
- <xsl:call-template name="CreateArgProp"/>
2365
- <xsl:apply-templates mode="mml" select="child::*[3]"/>
2366
- </sup>
2367
- </sSubSup>
2368
- </xsl:otherwise>
2369
- </xsl:choose>
2370
- </xsl:template>
2371
-
2372
- <!-- %%Template: SplitScripts
2373
-
2374
- Takes an collection of nodes, and splits them
2375
- odd and even into sup and sub scripts. Used for dealing with
2376
- mmultiscript.
2377
-
2378
- This template assumes you want to output both a sub and sup element.
2379
- -->
2380
- <xsl:template name="SplitScripts">
2381
- <xsl:param name="ndScripts"/>
2382
- <sub>
2383
- <xsl:call-template name="CreateArgProp"/>
2384
- <xsl:apply-templates mode="mml" select="$ndScripts[(position() mod 2) = 1]"/>
2385
- </sub>
2386
- <sup>
2387
- <xsl:call-template name="CreateArgProp"/>
2388
- <xsl:apply-templates mode="mml" select="$ndScripts[(position() mod 2) = 0]"/>
2389
- </sup>
2390
- </xsl:template>
2391
-
2392
- <!-- %%Template: match mmultiscripts
2393
-
2394
- There is some subtlety with the mml:mprescripts element. Everything that comes before
2395
- that is considered a script (as opposed to a pre-script), but it need not be present.
2396
- -->
2397
- <xsl:template mode="mml" match="mml:mmultiscripts">
2398
-
2399
- <!-- count the nodes. Everything that comes after a mml:mprescripts is considered a pre-script;
2400
- Everything that does not have an mml:mprescript as a preceding-sibling (and is not itself
2401
- mml:mprescript) is a script, except for the first child which is always the base.
2402
- The mml:none element is a place holder for a sub/sup element slot.
2403
-
2404
- mmultisript pattern:
2405
- <mmultiscript>
2406
- (base)
2407
- (sub sup)* // Where <none/> can replace a sub/sup entry to preserve pattern.
2408
- <mprescripts />
2409
- (presub presup)*
2410
- </mmultiscript>
2411
- -->
2412
- <!-- Count of presecript nodes that we'd print (this is essentially anything but the none placeholder. -->
2413
- <xsl:variable name="cndPrescriptStrict"
2414
- select="count(mml:mprescripts[1]/following-sibling::*[not(self::mml:none)])"/>
2415
- <!-- Count of all super script excluding mml:none -->
2416
- <xsl:variable name="cndSuperScript"
2417
- select="count(*[not(preceding-sibling::mml:mprescripts) and not(self::mml:mprescripts) and ((position() mod 2) = 1) and not(self::mml:none)]) - 1"/>
2418
- <!-- Count of all sup script excluding mml:none -->
2419
- <xsl:variable name="cndSubScript"
2420
- select="count(*[not(preceding-sibling::mml:mprescripts) and not(self::mml:mprescripts) and ((position() mod 2) = 0) and not(self::mml:none)])"/>
2421
- <!-- Count of all scripts excluding mml:none -->
2422
- <xsl:variable name="cndScriptStrict" select="$cndSuperScript + $cndSubScript"/>
2423
- <!-- Count of all scripts including mml:none. This is essentially all nodes before the
2424
- first mml:mprescripts except the base. -->
2425
- <xsl:variable name="cndScript"
2426
- select="count(*[not(preceding-sibling::mml:mprescripts) and not(self::mml:mprescripts)]) - 1"/>
2427
-
2428
- <xsl:choose>
2429
- <!-- The easy case first. No prescripts, and no script ... just a base -->
2430
- <xsl:when test="$cndPrescriptStrict &lt;= 0 and $cndScriptStrict &lt;= 0">
2431
- <xsl:apply-templates mode="mml" select="*[1]"/>
2432
- </xsl:when>
2433
-
2434
- <!-- Next, if there are no prescripts -->
2435
- <xsl:when test="$cndPrescriptStrict &lt;= 0">
2436
- <!-- we know we have some scripts or else we would have taken the earlier
2437
- branch. -->
2438
- <xsl:choose>
2439
- <!-- We have both sub and super scripts-->
2440
- <xsl:when test="$cndSuperScript &gt; 0 and $cndSubScript &gt; 0">
2441
- <sSubSup>
2442
- <e>
2443
- <xsl:call-template name="CreateArgProp"/>
2444
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2445
- </e>
2446
-
2447
- <!-- Every child except the first is a script. Do the split -->
2448
- <xsl:call-template name="SplitScripts">
2449
- <xsl:with-param name="ndScripts" select="*[position() &gt; 1]"/>
2450
- </xsl:call-template>
2451
- </sSubSup>
2452
- </xsl:when>
2453
- <!-- Just a sub script -->
2454
- <xsl:when test="$cndSubScript &gt; 0">
2455
- <sSub>
2456
- <e>
2457
- <xsl:call-template name="CreateArgProp"/>
2458
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2459
- </e>
2460
-
2461
- <!-- No prescripts and no super scripts, therefore, it's a sub. -->
2462
- <sub>
2463
- <xsl:apply-templates mode="mml" select="*[position() &gt; 1]"/>
2464
- </sub>
2465
- </sSub>
2466
- </xsl:when>
2467
- <!-- Just super script -->
2468
- <xsl:otherwise>
2469
- <sSup>
2470
- <e>
2471
- <xsl:call-template name="CreateArgProp"/>
2472
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2473
- </e>
2474
-
2475
- <!-- No prescripts and no sub scripts, therefore, it's a sup. -->
2476
- <sup>
2477
- <xsl:apply-templates mode="mml" select="*[position() &gt; 1]"/>
2478
- </sup>
2479
- </sSup>
2480
- </xsl:otherwise>
2481
- </xsl:choose>
2482
- </xsl:when>
2483
-
2484
- <!-- Next, if there are no scripts -->
2485
- <xsl:when test="$cndScriptStrict &lt;= 0">
2486
- <!-- we know we have some prescripts or else we would have taken the earlier
2487
- branch. So, create an sPre and split the elements -->
2488
- <sPre>
2489
- <e>
2490
- <xsl:call-template name="CreateArgProp"/>
2491
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2492
- </e>
2493
-
2494
- <!-- The prescripts come after the mml:mprescript and if we get here
2495
- we know there exists some elements after the mml:mprescript element.
2496
-
2497
- The prescript element has no sub/subsup variation, therefore, even if
2498
- we're only writing sub, we need to write out both the sub and sup element.
2499
- -->
2500
- <xsl:call-template name="SplitScripts">
2501
- <xsl:with-param name="ndScripts" select="mml:mprescripts[1]/following-sibling::*"/>
2502
- </xsl:call-template>
2503
- </sPre>
2504
- </xsl:when>
2505
-
2506
- <!-- Finally, the case with both prescripts and scripts. Create an sPre
2507
- element to house the prescripts, with a sub/sup/subsup element at its base. -->
2508
- <xsl:otherwise>
2509
- <sPre>
2510
- <e>
2511
- <xsl:choose>
2512
- <!-- We have both sub and super scripts-->
2513
- <xsl:when test="$cndSuperScript &gt; 0 and $cndSubScript &gt; 0">
2514
- <sSubSup>
2515
- <e>
2516
- <xsl:call-template name="CreateArgProp"/>
2517
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2518
- </e>
2519
-
2520
- <!-- scripts come before the mml:mprescript but after the first child, so their
2521
- positions will be 2, 3, ... ($nndScript + 1) -->
2522
- <xsl:call-template name="SplitScripts">
2523
- <xsl:with-param name="ndScripts"
2524
- select="*[(position() &gt; 1) and (position() &lt;= ($cndScript + 1))]"/>
2525
- </xsl:call-template>
2526
- </sSubSup>
2527
- </xsl:when>
2528
- <!-- Just a sub script -->
2529
- <xsl:when test="$cndSubScript &gt; 0">
2530
- <sSub>
2531
- <e>
2532
- <xsl:call-template name="CreateArgProp"/>
2533
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2534
- </e>
2535
-
2536
- <!-- We have prescripts but no super scripts, therefore, do a sub
2537
- and apply templates to all tokens counted by cndScript. -->
2538
- <sub>
2539
- <xsl:apply-templates mode="mml" select="*[position() &gt; 1 and (position() &lt;= ($cndScript + 1))]"/>
2540
- </sub>
2541
- </sSub>
2542
- </xsl:when>
2543
- <!-- Just super script -->
2544
- <xsl:otherwise>
2545
- <sSup>
2546
- <e>
2547
- <xsl:call-template name="CreateArgProp"/>
2548
- <xsl:apply-templates mode="mml" select="child::*[1]"/>
2549
- </e>
2550
-
2551
- <!-- We have prescripts but no sub scripts, therefore, do a sub
2552
- and apply templates to all tokens counted by cndScript. -->
2553
- <sup>
2554
- <xsl:apply-templates mode="mml" select="*[position() &gt; 1 and (position() &lt;= ($cndScript + 1))]"/>
2555
- </sup>
2556
- </sSup>
2557
- </xsl:otherwise>
2558
- </xsl:choose>
2559
- </e>
2560
-
2561
- <!-- The prescripts come after the mml:mprescript and if we get here
2562
- we know there exists one such element -->
2563
- <xsl:call-template name="SplitScripts">
2564
- <xsl:with-param name="ndScripts" select="mml:mprescripts[1]/following-sibling::*"/>
2565
- </xsl:call-template>
2566
- </sPre>
2567
- </xsl:otherwise>
2568
- </xsl:choose>
2569
- </xsl:template>
2570
-
2571
- <!-- Template that determines if ndCur is an equation array.
2572
-
2573
- ndCur is an equation array if:
2574
-
2575
- 0. The table has a columnalign other than the default (center)
2576
- 1. There are are no frame lines
2577
- 2. There are no column lines
2578
- 3. There are no row lines
2579
- 4. There is no row with more than 1 column
2580
- 5. There is no row with fewer than 1 column
2581
- 6. There are no labeled rows.
2582
-
2583
- -->
2584
- <xsl:template name="FIsEqArray">
2585
- <xsl:param name="ndCur" select="."/>
2586
-
2587
- <!-- There should be no frame, columnlines, or rowlines -->
2588
- <xsl:choose>
2589
- <xsl:when test="@columnalign!='center'">0</xsl:when>
2590
- <xsl:when test="(not($ndCur/@frame) or $ndCur/@frame='' or $ndCur/@frame='none')
2591
- and (not($ndCur/@mml:frame) or $ndCur/@mml:frame='' or $ndCur/@mml:frame='none')
2592
- and (not($ndCur/@columnlines) or $ndCur/@columnlines='' or $ndCur/@columnlines='none')
2593
- and (not($ndCur/@mml:columnlines) or $ndCur/@mml:columnlines='' or $ndCur/@mml:columnlines='none')
2594
- and (not($ndCur/@rowlines) or $ndCur/@rowlines='' or $ndCur/@rowlines='none')
2595
- and (not($ndCur/@mml:rowlines) or $ndCur/@mml:rowlines='' or $ndCur/@mml:rowlines='none')
2596
- and not($ndCur/mml:mtr[count(mml:mtd) &gt; 1])
2597
- and not($ndCur/mml:mtr[count(mml:mtd) &lt; 1])
2598
- and not($ndCur/mml:mlabeledtr)">1</xsl:when>
2599
- <xsl:otherwise>0</xsl:otherwise>
2600
- </xsl:choose>
2601
- </xsl:template>
2602
-
2603
- <!-- Template used to determine if we should ignore a collection when iterating through
2604
- a mathml equation array row.
2605
-
2606
- So far, the only thing that needs to be ignored is the argument of an nary. We
2607
- can ignore this since it is output when we apply-templates to the munder[over]/msub[sup].
2608
- -->
2609
- <xsl:template name="FIgnoreCollection">
2610
- <xsl:param name="ndCur" select="."/>
2611
-
2612
- <xsl:variable name="fNaryArgument">
2613
- <xsl:call-template name="FIsNaryArgument">
2614
- <xsl:with-param name="ndCur" select="$ndCur"/>
2615
- </xsl:call-template>
2616
- </xsl:variable>
2617
-
2618
- <xsl:choose>
2619
- <xsl:when test="$fNaryArgument=1">1</xsl:when>
2620
- <xsl:otherwise>0</xsl:otherwise>
2621
- </xsl:choose>
2622
- </xsl:template>
2623
-
2624
- <!-- Template used to determine if we've already encountered an maligngroup or malignmark.
2625
-
2626
- This is needed because omml has an implicit spacing alignment (omml spacing alignment =
2627
- mathml's maligngroup element) at the beginning of each equation array row. Therefore,
2628
- the first maligngroup (implied or explicit) we encounter does not need to be output.
2629
- This template recursively searches up the xml tree and looks at previous siblings to see
2630
- if they have a descendant that is an maligngroup or malignmark. We look for the malignmark
2631
- to find the implicit maligngroup.
2632
- -->
2633
- <xsl:template name="FFirstAlignAlreadyFound">
2634
- <xsl:param name="ndCur" select="."/>
2635
-
2636
- <xsl:choose>
2637
- <xsl:when test="count($ndCur/preceding-sibling::*[descendant-or-self::mml:maligngroup or descendant-or-self::mml:malignmark]) &gt; 0">1</xsl:when>
2638
- <xsl:when test="not($ndCur/parent::mml:mtd)">
2639
- <xsl:call-template name="FFirstAlignAlreadyFound">
2640
- <xsl:with-param name="ndCur" select="$ndCur/parent::*"/>
2641
- </xsl:call-template>
2642
- </xsl:when>
2643
- <xsl:otherwise>0</xsl:otherwise>
2644
- </xsl:choose>
2645
- </xsl:template>
2646
-
2647
- <!-- This template builds a string that is result of concatenating a given string several times.
2648
-
2649
- Given strToRepeat, create a string that has strToRepeat repeated iRepitions times.
2650
- -->
2651
- <xsl:template name="ConcatStringRepeat">
2652
- <xsl:param name="strToRepeat" select="''"/>
2653
- <xsl:param name="iRepetitions" select="0"/>
2654
- <xsl:param name="strBuilding" select="''"/>
2655
-
2656
- <xsl:choose>
2657
- <xsl:when test="$iRepetitions &lt;= 0">
2658
- <xsl:value-of select="$strBuilding"/>
2659
- </xsl:when>
2660
- <xsl:otherwise>
2661
- <xsl:call-template name="ConcatStringRepeat">
2662
- <xsl:with-param name="strToRepeat" select="$strToRepeat"/>
2663
- <xsl:with-param name="iRepetitions" select="$iRepetitions - 1"/>
2664
- <xsl:with-param name="strBuilding" select="concat($strBuilding, $strToRepeat)"/>
2665
- </xsl:call-template>
2666
- </xsl:otherwise>
2667
- </xsl:choose>
2668
- </xsl:template>
2669
-
2670
- <!-- This template determines if ndCur is a special collection.
2671
- By special collection, I mean is ndCur the outer element of some special grouping
2672
- of mathml elements that actually represents some over all omml structure.
2673
-
2674
- For instance, is ndCur a linear fraction, or an omml function.
2675
- -->
2676
- <xsl:template name="FSpecialCollection">
2677
- <xsl:param name="ndCur" select="."/>
2678
- <xsl:choose>
2679
- <xsl:when test="$ndCur/self::mml:mrow">
2680
- <xsl:variable name="fLinearFraction">
2681
- <xsl:call-template name="FLinearFrac">
2682
- <xsl:with-param name="ndCur" select="$ndCur"/>
2683
- </xsl:call-template>
2684
- </xsl:variable>
2685
- <xsl:variable name="fFunc">
2686
- <xsl:call-template name="FIsFunc">
2687
- <xsl:with-param name="ndCur" select="$ndCur"/>
2688
- </xsl:call-template>
2689
- </xsl:variable>
2690
- <xsl:choose>
2691
- <xsl:when test="$fLinearFraction=1 or $fFunc=1">1</xsl:when>
2692
- <xsl:otherwise>0</xsl:otherwise>
2693
- </xsl:choose>
2694
- </xsl:when>
2695
- <xsl:otherwise>0</xsl:otherwise>
2696
- </xsl:choose>
2697
- </xsl:template>
2698
-
2699
- <!-- This template iterates through the children of an equation array row (mtr) and outputs
2700
- the equation.
2701
-
2702
- This template does all the work to output ampersands and skip the right elements when needed.
2703
- -->
2704
- <xsl:template name="ProcessEqArrayRow">
2705
- <xsl:param name="ndCur" select="."/>
2706
-
2707
- <xsl:for-each select="$ndCur/*">
2708
- <xsl:variable name="fSpecialCollection">
2709
- <xsl:call-template name="FSpecialCollection">
2710
- <xsl:with-param name="ndCur" select="."/>
2711
- </xsl:call-template>
2712
- </xsl:variable>
2713
- <xsl:variable name="fIgnoreCollection">
2714
- <xsl:call-template name="FIgnoreCollection">
2715
- <xsl:with-param name="ndCur" select="."/>
2716
- </xsl:call-template>
2717
- </xsl:variable>
2718
- <xsl:choose>
2719
- <!-- If we have an alignment element output the ampersand. -->
2720
- <xsl:when test="self::mml:maligngroup or self::mml:malignmark">
2721
- <!-- Omml has an implied spacing alignment at the beginning of each equation.
2722
- Therefore, if this is the first ampersand to be output, don't actually output. -->
2723
- <xsl:variable name="fFirstAlignAlreadyFound">
2724
- <xsl:call-template name="FFirstAlignAlreadyFound">
2725
- <xsl:with-param name="ndCur" select="."/>
2726
- </xsl:call-template>
2727
- </xsl:variable>
2728
- <!-- Don't output unless it is an malignmark or we have already previously found an alignment point. -->
2729
- <xsl:if test="self::mml:malignmark or $fFirstAlignAlreadyFound=1">
2730
- <r>
2731
- <t>&amp;</t>
2732
- </r>
2733
- </xsl:if>
2734
- </xsl:when>
2735
- <!-- If this node is an non-special mrow or mstyle and we aren't supposed to ignore this collection, then
2736
- go ahead an apply templates to this node. -->
2737
- <xsl:when test="$fIgnoreCollection=0 and ((self::mml:mrow and $fSpecialCollection=0) or self::mml:mstyle)">
2738
- <xsl:call-template name="ProcessEqArrayRow">
2739
- <xsl:with-param name="ndCur" select="."/>
2740
- </xsl:call-template>
2741
- </xsl:when>
2742
- <!-- At this point we have some mathml structure (fraction, nary, non-grouping element, etc.) -->
2743
- <!-- If this mathml structure has alignment groups or marks as children, then extract those since
2744
- omml can't handle that. -->
2745
- <xsl:when test="descendant::mml:maligngroup or descendant::mml:malignmark">
2746
- <xsl:variable name="cMalignGroups">
2747
- <xsl:value-of select="count(descendant::mml:maligngroup)"/>
2748
- </xsl:variable>
2749
- <xsl:variable name="cMalignMarks">
2750
- <xsl:value-of select="count(descendant::mml:malignmark)"/>
2751
- </xsl:variable>
2752
- <!-- Output all maligngroups and malignmarks as '&amp;' -->
2753
- <xsl:if test="$cMalignGroups + $cMalignMarks &gt; 0">
2754
- <xsl:variable name="str">
2755
- <xsl:call-template name="ConcatStringRepeat">
2756
- <xsl:with-param name="strToRepeat" select="'&amp;'"/>
2757
- <xsl:with-param name="iRepetitions" select="$cMalignGroups + $cMalignMarks"/>
2758
- <xsl:with-param name="strBuilding" select="''"/>
2759
- </xsl:call-template>
2760
- </xsl:variable>
2761
- <r>
2762
- <t>
2763
- <xsl:call-template name="OutputText">
2764
- <xsl:with-param name="sInput" select="$str"/>
2765
- </xsl:call-template>
2766
- </t>
2767
- </r>
2768
- </xsl:if>
2769
- <!-- Now that the '&amp;' have been extracted, just apply-templates to this node.-->
2770
- <xsl:apply-templates mode="mml" select="."/>
2771
- </xsl:when>
2772
- <!-- If there are no alignment points as descendants, then go ahead and output this node. -->
2773
- <xsl:otherwise>
2774
- <xsl:apply-templates mode="mml" select="."/>
2775
- </xsl:otherwise>
2776
- </xsl:choose>
2777
- </xsl:for-each>
2778
- </xsl:template>
2779
-
2780
- <!-- This template transforms mtable into its appropriate omml type.
2781
-
2782
- There are two possible omml constructs that an mtable can become: a matrix or
2783
- an equation array.
2784
-
2785
- Because omml has no generic table construct, the omml matrix is the best approximate
2786
- for a mathml table.
2787
-
2788
- Our equation array transformation is very simple. The main goal of this transform is to
2789
- allow roundtripping omml eq arrays through mathml. The template ProcessEqArrayRow was never
2790
- intended to account for many of the alignment flexibilities that are present in mathml like
2791
- using the alig attribute, using alignmark attribute in token elements, etc.
2792
-
2793
- The restrictions on this transform require <malignmark> and <maligngroup> elements to be outside of
2794
- any non-grouping mathml elements (that is, mrow and mstyle). Moreover, these elements cannot be the children of
2795
- mrows that represent linear fractions or functions. Also, <malignmark> cannot be a child
2796
- of token attributes.
2797
-
2798
- In the case that the above
2799
-
2800
- -->
2801
- <xsl:template mode="mml" match="mml:mtable">
2802
- <xsl:variable name="fEqArray">
2803
- <xsl:call-template name="FIsEqArray">
2804
- <xsl:with-param name="ndCur" select="."/>
2805
- </xsl:call-template>
2806
- </xsl:variable>
2807
- <xsl:variable name="alignment">
2808
- <xsl:value-of select="@columnalign"/>
2809
- </xsl:variable>
2810
- <xsl:choose>
2811
- <xsl:when test="$fEqArray=1">
2812
- <eqArr>
2813
- <xsl:if test="$alignment!=''">
2814
- <eqArrPr>
2815
- <baseJc m:val="{$alignment}"/>
2816
- </eqArrPr>
2817
- </xsl:if>
2818
- <xsl:for-each select="mml:mtr">
2819
- <e>
2820
- <xsl:call-template name="ProcessEqArrayRow">
2821
- <xsl:with-param name="ndCur" select="mml:mtd"/>
2822
- </xsl:call-template>
2823
- </e>
2824
- </xsl:for-each>
2825
- </eqArr>
2826
- </xsl:when>
2827
- <xsl:otherwise>
2828
- <xsl:variable name="cMaxElmtsInRow">
2829
- <xsl:call-template name="CountMaxElmtsInRow">
2830
- <xsl:with-param name="ndCur" select="*[1]"/>
2831
- <xsl:with-param name="cMaxElmtsInRow" select="0"/>
2832
- </xsl:call-template>
2833
- </xsl:variable>
2834
- <m>
2835
- <mPr>
2836
- <baseJc m:val="center"/>
2837
- <plcHide m:val="on"/>
2838
- <mcs>
2839
- <mc>
2840
- <mcPr>
2841
- <count>
2842
- <xsl:attribute name="m:val">
2843
- <xsl:value-of select="$cMaxElmtsInRow"/>
2844
- </xsl:attribute>
2845
- </count>
2846
- <mcJc m:val="{$alignment}"/>
2847
- </mcPr>
2848
- </mc>
2849
- </mcs>
2850
- </mPr>
2851
- <xsl:for-each select="*">
2852
- <xsl:choose>
2853
- <xsl:when test="self::mml:mtr or self::mml:mlabeledtr">
2854
- <mr>
2855
- <xsl:choose>
2856
- <xsl:when test="self::mml:mtr">
2857
- <xsl:for-each select="*">
2858
- <e>
2859
- <xsl:apply-templates mode="mml" select="."/>
2860
- </e>
2861
- </xsl:for-each>
2862
- <xsl:call-template name="CreateEmptyElmt">
2863
- <xsl:with-param name="cEmptyMtd" select="$cMaxElmtsInRow - count(*)"/>
2864
- </xsl:call-template>
2865
- </xsl:when>
2866
- <xsl:otherwise>
2867
- <xsl:for-each select="*[position() &gt; 1]">
2868
- <e>
2869
- <xsl:apply-templates mode="mml" select="."/>
2870
- </e>
2871
- </xsl:for-each>
2872
- <xsl:call-template name="CreateEmptyElmt">
2873
- <xsl:with-param name="cEmptyMtd" select="$cMaxElmtsInRow - (count(*) - 1)"/>
2874
- </xsl:call-template>
2875
- </xsl:otherwise>
2876
- </xsl:choose>
2877
- </mr>
2878
- </xsl:when>
2879
- <xsl:otherwise>
2880
- <mr>
2881
- <e>
2882
- <xsl:apply-templates mode="mml" select="."/>
2883
- </e>
2884
- <xsl:call-template name="CreateEmptyElmt">
2885
- <xsl:with-param name="cEmptyMtd" select="$cMaxElmtsInRow - 1"/>
2886
- </xsl:call-template>
2887
- </mr>
2888
- </xsl:otherwise>
2889
- </xsl:choose>
2890
- </xsl:for-each>
2891
- </m>
2892
- </xsl:otherwise>
2893
- </xsl:choose>
2894
- </xsl:template>
2895
- <xsl:template mode="mml" match="m:mtd">
2896
- <xsl:apply-templates mode="mml"/>
2897
- </xsl:template>
2898
- <xsl:template name="CreateEmptyElmt">
2899
- <xsl:param name="cEmptyMtd"/>
2900
- <xsl:if test="$cEmptyMtd &gt; 0">
2901
- <e/>
2902
- <xsl:call-template name="CreateEmptyElmt">
2903
- <xsl:with-param name="cEmptyMtd" select="$cEmptyMtd - 1"/>
2904
- </xsl:call-template>
2905
- </xsl:if>
2906
- </xsl:template>
2907
- <xsl:template name="CountMaxElmtsInRow">
2908
- <xsl:param name="ndCur"/>
2909
- <xsl:param name="cMaxElmtsInRow" select="0"/>
2910
- <xsl:choose>
2911
- <xsl:when test="not($ndCur)">
2912
- <xsl:value-of select="$cMaxElmtsInRow"/>
2913
- </xsl:when>
2914
- <xsl:otherwise>
2915
- <xsl:call-template name="CountMaxElmtsInRow">
2916
- <xsl:with-param name="ndCur" select="$ndCur/following-sibling::*[1]"/>
2917
- <xsl:with-param name="cMaxElmtsInRow">
2918
- <xsl:choose>
2919
- <xsl:when test="local-name($ndCur) = 'mlabeledtr' and namespace-uri($ndCur) = 'http://www.w3.org/1998/Math/MathML'">
2920
- <xsl:choose>
2921
- <xsl:when test="(count($ndCur/*) - 1) &gt; $cMaxElmtsInRow">
2922
- <xsl:value-of select="count($ndCur/*) - 1"/>
2923
- </xsl:when>
2924
- <xsl:otherwise>
2925
- <xsl:value-of select="$cMaxElmtsInRow"/>
2926
- </xsl:otherwise>
2927
- </xsl:choose>
2928
- </xsl:when>
2929
- <xsl:when test="local-name($ndCur) = 'mtr' and namespace-uri($ndCur) = 'http://www.w3.org/1998/Math/MathML'">
2930
- <xsl:choose>
2931
- <xsl:when test="count($ndCur/*) &gt; $cMaxElmtsInRow">
2932
- <xsl:value-of select="count($ndCur/*)"/>
2933
- </xsl:when>
2934
- <xsl:otherwise>
2935
- <xsl:value-of select="$cMaxElmtsInRow"/>
2936
- </xsl:otherwise>
2937
- </xsl:choose>
2938
- </xsl:when>
2939
- <xsl:otherwise>
2940
- <xsl:choose>
2941
- <xsl:when test="1 &gt; $cMaxElmtsInRow">
2942
- <xsl:value-of select="1"/>
2943
- </xsl:when>
2944
- <xsl:otherwise>
2945
- <xsl:value-of select="$cMaxElmtsInRow"/>
2946
- </xsl:otherwise>
2947
- </xsl:choose>
2948
- </xsl:otherwise>
2949
- </xsl:choose>
2950
- </xsl:with-param>
2951
- </xsl:call-template>
2952
- </xsl:otherwise>
2953
- </xsl:choose>
2954
- </xsl:template>
2955
- <xsl:template mode="mml" match="mml:mglyph">
2956
- <xsl:call-template name="CreateMglyph"/>
2957
- </xsl:template>
2958
- <xsl:template mode="mml"
2959
- match="mml:mi[child::mml:mglyph] | mml:mn[child::mml:mglyph] | mml:mo[child::mml:mglyph] | mml:ms[child::mml:mglyph] | mml:mtext[child::mml:mglyph]">
2960
- <xsl:if test="string-length(normalize-space(.)) &gt; 0">
2961
- <r>
2962
- <xsl:call-template name="CreateRunProp">
2963
- <xsl:with-param name="mathvariant">
2964
- <xsl:choose>
2965
- <xsl:when test="@mathvariant">
2966
- <xsl:value-of select="@mathvariant"/>
2967
- </xsl:when>
2968
- <xsl:otherwise>
2969
- <xsl:value-of select="@mml:mathvariant"/>
2970
- </xsl:otherwise>
2971
- </xsl:choose>
2972
- </xsl:with-param>
2973
- <xsl:with-param name="fontstyle">
2974
- <xsl:choose>
2975
- <xsl:when test="@fontstyle">
2976
- <xsl:value-of select="@fontstyle"/>
2977
- </xsl:when>
2978
- <xsl:otherwise>
2979
- <xsl:value-of select="@mml:fontstyle"/>
2980
- </xsl:otherwise>
2981
- </xsl:choose>
2982
- </xsl:with-param>
2983
- <xsl:with-param name="fontweight">
2984
- <xsl:choose>
2985
- <xsl:when test="@fontweight">
2986
- <xsl:value-of select="@fontweight"/>
2987
- </xsl:when>
2988
- <xsl:otherwise>
2989
- <xsl:value-of select="@mml:fontweight"/>
2990
- </xsl:otherwise>
2991
- </xsl:choose>
2992
- </xsl:with-param>
2993
- <xsl:with-param name="mathcolor">
2994
- <xsl:choose>
2995
- <xsl:when test="@mathcolor">
2996
- <xsl:value-of select="@mathcolor"/>
2997
- </xsl:when>
2998
- <xsl:otherwise>
2999
- <xsl:value-of select="@mml:mathcolor"/>
3000
- </xsl:otherwise>
3001
- </xsl:choose>
3002
- </xsl:with-param>
3003
- <xsl:with-param name="mathsize">
3004
- <xsl:choose>
3005
- <xsl:when test="@mathsize">
3006
- <xsl:value-of select="@mathsize"/>
3007
- </xsl:when>
3008
- <xsl:otherwise>
3009
- <xsl:value-of select="@mml:mathsize"/>
3010
- </xsl:otherwise>
3011
- </xsl:choose>
3012
- </xsl:with-param>
3013
- <xsl:with-param name="color">
3014
- <xsl:choose>
3015
- <xsl:when test="@color">
3016
- <xsl:value-of select="@color"/>
3017
- </xsl:when>
3018
- <xsl:otherwise>
3019
- <xsl:value-of select="@mml:color"/>
3020
- </xsl:otherwise>
3021
- </xsl:choose>
3022
- </xsl:with-param>
3023
- <xsl:with-param name="fontsize">
3024
- <xsl:choose>
3025
- <xsl:when test="@fontsize">
3026
- <xsl:value-of select="@fontsize"/>
3027
- </xsl:when>
3028
- <xsl:otherwise>
3029
- <xsl:value-of select="@mml:fontsize"/>
3030
- </xsl:otherwise>
3031
- </xsl:choose>
3032
- </xsl:with-param>
3033
- <xsl:with-param name="fNor">
3034
- <xsl:call-template name="FNor">
3035
- <xsl:with-param name="ndCur" select="."/>
3036
- </xsl:call-template>
3037
- </xsl:with-param>
3038
- <xsl:with-param name="fLit">
3039
- <xsl:call-template name="FLit">
3040
- <xsl:with-param name="ndCur" select="."/>
3041
- </xsl:call-template>
3042
- </xsl:with-param>
3043
- <xsl:with-param name="ndCur" select="."/>
3044
- </xsl:call-template>
3045
- <t>
3046
- <xsl:call-template name="OutputText">
3047
- <xsl:with-param name="sInput">
3048
- <xsl:choose>
3049
- <xsl:when test="self::mml:ms">
3050
- <xsl:call-template name="OutputMs">
3051
- <xsl:with-param name="msCur" select="."/>
3052
- </xsl:call-template>
3053
- </xsl:when>
3054
- <xsl:otherwise>
3055
- <xsl:value-of select="normalize-space(.)"/>
3056
- </xsl:otherwise>
3057
- </xsl:choose>
3058
- </xsl:with-param>
3059
- </xsl:call-template>
3060
- </t>
3061
- </r>
3062
- </xsl:if>
3063
- <xsl:for-each select="child::mml:mglyph">
3064
- <xsl:call-template name="CreateMglyph">
3065
- <xsl:with-param name="ndCur" select="."/>
3066
- </xsl:call-template>
3067
- </xsl:for-each>
3068
- </xsl:template>
3069
- <xsl:template name="FGlyphIndexOk">
3070
- <xsl:param name="index"/>
3071
- <xsl:if test="$index != ''">
3072
- <xsl:choose>
3073
- <xsl:when test="string(number(string(floor($index)))) = 'NaN'"/>
3074
- <xsl:when test="number($index) &lt; 32 and not(number($index) = 9 or number($index) = 10 or number($index) = 13)"/>
3075
- <xsl:when test="number($index) = 65534 or number($index) = 65535"/>
3076
- <xsl:otherwise>1</xsl:otherwise>
3077
- </xsl:choose>
3078
- </xsl:if>
3079
- </xsl:template>
3080
- <xsl:template name="CreateMglyph">
3081
- <xsl:param name="ndCur"/>
3082
- <r>
3083
- <xsl:call-template name="CreateRunProp">
3084
- <xsl:with-param name="mathvariant">
3085
- <xsl:choose>
3086
- <xsl:when test="(not(@mathvariant) or @mathvariant='') and (not(@mml:mathvariant) or @mml:mathvariant='') and (../@mathvariant!='' or ../@mml:mathvariant!='')">
3087
- <xsl:choose>
3088
- <xsl:when test="../@mathvariant">
3089
- <xsl:value-of select="../@mathvariant"/>
3090
- </xsl:when>
3091
- <xsl:otherwise>
3092
- <xsl:value-of select="../mml:mathvariant"/>
3093
- </xsl:otherwise>
3094
- </xsl:choose>
3095
- </xsl:when>
3096
- <xsl:otherwise>
3097
- <xsl:choose>
3098
- <xsl:when test="@mathvariant">
3099
- <xsl:value-of select="@mathvariant"/>
3100
- </xsl:when>
3101
- <xsl:otherwise>
3102
- <xsl:value-of select="@mml:mathvariant"/>
3103
- </xsl:otherwise>
3104
- </xsl:choose>
3105
- </xsl:otherwise>
3106
- </xsl:choose>
3107
- </xsl:with-param>
3108
- <xsl:with-param name="fontstyle">
3109
- <xsl:choose>
3110
- <xsl:when test="(not(@fontstyle) or @fontstyle='') and (not(@mml:fontstyle) or @mml:fontstyle='') and (../@fontstyle!='' or ../@mml:fontstyle!='')">
3111
- <xsl:choose>
3112
- <xsl:when test="../@fontstyle">
3113
- <xsl:value-of select="../@fontstyle"/>
3114
- </xsl:when>
3115
- <xsl:otherwise>
3116
- <xsl:value-of select="../@mml:fontstyle"/>
3117
- </xsl:otherwise>
3118
- </xsl:choose>
3119
- </xsl:when>
3120
- <xsl:otherwise>
3121
- <xsl:choose>
3122
- <xsl:when test="@fontstyle">
3123
- <xsl:value-of select="@fontstyle"/>
3124
- </xsl:when>
3125
- <xsl:otherwise>
3126
- <xsl:value-of select="@mml:fontstyle"/>
3127
- </xsl:otherwise>
3128
- </xsl:choose>
3129
- </xsl:otherwise>
3130
- </xsl:choose>
3131
- </xsl:with-param>
3132
- <xsl:with-param name="fontweight">
3133
- <xsl:choose>
3134
- <xsl:when test="(not(@fontweight) or @fontweight='') and (not(@mml:fontweight) or @mml:fontweight='') and (../@fontweight!='' or ../@mml:fontweight!='')">
3135
- <xsl:choose>
3136
- <xsl:when test="../@fontweight">
3137
- <xsl:value-of select="../@fontweight"/>
3138
- </xsl:when>
3139
- <xsl:otherwise>
3140
- <xsl:value-of select="../@mml:fontweight"/>
3141
- </xsl:otherwise>
3142
- </xsl:choose>
3143
- </xsl:when>
3144
- <xsl:otherwise>
3145
- <xsl:choose>
3146
- <xsl:when test="@fontweight">
3147
- <xsl:value-of select="@fontweight"/>
3148
- </xsl:when>
3149
- <xsl:otherwise>
3150
- <xsl:value-of select="@mml:fontweight"/>
3151
- </xsl:otherwise>
3152
- </xsl:choose>
3153
- </xsl:otherwise>
3154
- </xsl:choose>
3155
- </xsl:with-param>
3156
- <xsl:with-param name="mathcolor">
3157
- <xsl:choose>
3158
- <xsl:when test="(not(@mathcolor) or @mathcolor='') and (not(@mml:mathcolor) or @mml:mathcolor='') and (../@mathcolor!='' or ../@mml:mathcolor!='')">
3159
- <xsl:choose>
3160
- <xsl:when test="../@mathcolor">
3161
- <xsl:value-of select="../@mathcolor"/>
3162
- </xsl:when>
3163
- <xsl:otherwise>
3164
- <xsl:value-of select="../@mml:mathcolor"/>
3165
- </xsl:otherwise>
3166
- </xsl:choose>
3167
- </xsl:when>
3168
- <xsl:otherwise>
3169
- <xsl:choose>
3170
- <xsl:when test="@mathcolor">
3171
- <xsl:value-of select="@mathcolor"/>
3172
- </xsl:when>
3173
- <xsl:otherwise>
3174
- <xsl:value-of select="@mml:mathcolor"/>
3175
- </xsl:otherwise>
3176
- </xsl:choose>
3177
- </xsl:otherwise>
3178
- </xsl:choose>
3179
- </xsl:with-param>
3180
- <xsl:with-param name="mathsize">
3181
- <xsl:choose>
3182
- <xsl:when test="(not(@mathsize) or @mathsize='') and (not(@mml:mathsize) or @mml:mathsize='') and (../@mathsize!='' or ../@mml:mathsize!='')">
3183
- <xsl:choose>
3184
- <xsl:when test="../@mathsize">
3185
- <xsl:value-of select="../@mathsize"/>
3186
- </xsl:when>
3187
- <xsl:otherwise>
3188
- <xsl:value-of select="../@mathsize"/>
3189
- </xsl:otherwise>
3190
- </xsl:choose>
3191
- </xsl:when>
3192
- <xsl:otherwise>
3193
- <xsl:choose>
3194
- <xsl:when test="@mathsize">
3195
- <xsl:value-of select="@mathsize"/>
3196
- </xsl:when>
3197
- <xsl:otherwise>
3198
- <xsl:value-of select="@mml:mathsize"/>
3199
- </xsl:otherwise>
3200
- </xsl:choose>
3201
- </xsl:otherwise>
3202
- </xsl:choose>
3203
- </xsl:with-param>
3204
- <xsl:with-param name="color">
3205
- <xsl:choose>
3206
- <xsl:when test="(not(@color) or @color='') and (not(@mml:color) or @mml:color='') and (../@color!='' or ../@mml:color!='')">
3207
- <xsl:choose>
3208
- <xsl:when test="../@color">
3209
- <xsl:value-of select="../@color"/>
3210
- </xsl:when>
3211
- <xsl:otherwise>
3212
- <xsl:value-of select="../@mml:color"/>
3213
- </xsl:otherwise>
3214
- </xsl:choose>
3215
- </xsl:when>
3216
- <xsl:otherwise>
3217
- <xsl:choose>
3218
- <xsl:when test="@color">
3219
- <xsl:value-of select="@color"/>
3220
- </xsl:when>
3221
- <xsl:otherwise>
3222
- <xsl:value-of select="@mml:color"/>
3223
- </xsl:otherwise>
3224
- </xsl:choose>
3225
- </xsl:otherwise>
3226
- </xsl:choose>
3227
- </xsl:with-param>
3228
- <xsl:with-param name="fontsize">
3229
- <xsl:choose>
3230
- <xsl:when test="(not(@fontsize) or @fontsize='') and (not(@mml:fontsize) or @mml:fontsize='') and (../@fontsize!='' or ../@mml:fontsize!='')">
3231
- <xsl:choose>
3232
- <xsl:when test="../@fontsize">
3233
- <xsl:value-of select="../@fontsize"/>
3234
- </xsl:when>
3235
- <xsl:otherwise>
3236
- <xsl:value-of select="../@mml:fontsize"/>
3237
- </xsl:otherwise>
3238
- </xsl:choose>
3239
- </xsl:when>
3240
- <xsl:otherwise>
3241
- <xsl:choose>
3242
- <xsl:when test="@fontsize">
3243
- <xsl:value-of select="@fontsize"/>
3244
- </xsl:when>
3245
- <xsl:otherwise>
3246
- <xsl:value-of select="@mml:fontsize"/>
3247
- </xsl:otherwise>
3248
- </xsl:choose>
3249
- </xsl:otherwise>
3250
- </xsl:choose>
3251
- </xsl:with-param>
3252
- <xsl:with-param name="ndCur" select="."/>
3253
- <xsl:with-param name="font-family">
3254
- <xsl:choose>
3255
- <xsl:when test="@fontfamily">
3256
- <xsl:value-of select="@fontfamily"/>
3257
- </xsl:when>
3258
- <xsl:otherwise>
3259
- <xsl:value-of select="@mml:fontfamily"/>
3260
- </xsl:otherwise>
3261
- </xsl:choose>
3262
- </xsl:with-param>
3263
- <xsl:with-param name="fNor">
3264
- <xsl:call-template name="FNor">
3265
- <xsl:with-param name="ndCur" select="."/>
3266
- </xsl:call-template>
3267
- </xsl:with-param>
3268
- <xsl:with-param name="fLit">
3269
- <xsl:call-template name="FLit">
3270
- <xsl:with-param name="ndCur" select="."/>
3271
- </xsl:call-template>
3272
- </xsl:with-param>
3273
- </xsl:call-template>
3274
- <xsl:variable name="shouldGlyphUseIndex">
3275
- <xsl:call-template name="FGlyphIndexOk">
3276
- <xsl:with-param name="index">
3277
- <xsl:choose>
3278
- <xsl:when test="@index">
3279
- <xsl:value-of select="@index"/>
3280
- </xsl:when>
3281
- <xsl:otherwise>
3282
- <xsl:value-of select="@mml:index"/>
3283
- </xsl:otherwise>
3284
- </xsl:choose>
3285
- </xsl:with-param>
3286
- </xsl:call-template>
3287
- </xsl:variable>
3288
- <xsl:choose>
3289
- <xsl:when test="not($shouldGlyphUseIndex = '1')">
3290
- <t>
3291
- <xsl:choose>
3292
- <xsl:when test="@alt">
3293
- <xsl:value-of select="@alt"/>
3294
- </xsl:when>
3295
- <xsl:otherwise>
3296
- <xsl:value-of select="@mml:alt"/>
3297
- </xsl:otherwise>
3298
- </xsl:choose>
3299
- </t>
3300
- </xsl:when>
3301
- <xsl:otherwise>
3302
- <xsl:variable name="nHexIndex">
3303
- <xsl:call-template name="ConvertDecToHex">
3304
- <xsl:with-param name="index">
3305
- <xsl:choose>
3306
- <xsl:when test="@index">
3307
- <xsl:value-of select="@index"/>
3308
- </xsl:when>
3309
- <xsl:otherwise>
3310
- <xsl:value-of select="@mml:index"/>
3311
- </xsl:otherwise>
3312
- </xsl:choose>
3313
- </xsl:with-param>
3314
- </xsl:call-template>
3315
- </xsl:variable>
3316
- <t>
3317
- <xsl:text disable-output-escaping="yes">&amp;#x</xsl:text>
3318
- <xsl:value-of select="$nHexIndex"/>
3319
- <xsl:text>;</xsl:text>
3320
- </t>
3321
- </xsl:otherwise>
3322
- </xsl:choose>
3323
- </r>
3324
- </xsl:template>
3325
- <xsl:template name="ConvertDecToHex">
3326
- <xsl:param name="index"/>
3327
- <xsl:if test="$index &gt; 0">
3328
- <xsl:call-template name="ConvertDecToHex">
3329
- <xsl:with-param name="index" select="floor($index div 16)"/>
3330
- </xsl:call-template>
3331
- <xsl:choose>
3332
- <xsl:when test="$index mod 16 &lt; 10">
3333
- <xsl:value-of select="$index mod 16"/>
3334
- </xsl:when>
3335
- <xsl:otherwise>
3336
- <xsl:choose>
3337
- <xsl:when test="$index mod 16 = 10">A</xsl:when>
3338
- <xsl:when test="$index mod 16 = 11">B</xsl:when>
3339
- <xsl:when test="$index mod 16 = 12">C</xsl:when>
3340
- <xsl:when test="$index mod 16 = 13">D</xsl:when>
3341
- <xsl:when test="$index mod 16 = 14">E</xsl:when>
3342
- <xsl:when test="$index mod 16 = 15">F</xsl:when>
3343
- <xsl:otherwise>A</xsl:otherwise>
3344
- </xsl:choose>
3345
- </xsl:otherwise>
3346
- </xsl:choose>
3347
- </xsl:if>
3348
- </xsl:template>
3349
-
3350
- <xsl:template name="FStrContainsNonZeroDigit">
3351
- <xsl:param name="s"/>
3352
-
3353
- <!-- Translate any nonzero digit into a 9 -->
3354
- <xsl:variable name="sNonZeroDigitsToNineDigit" select="translate($s, '12345678', '99999999')"/>
3355
- <xsl:choose>
3356
- <!-- Search for 9s -->
3357
- <xsl:when test="contains($sNonZeroDigitsToNineDigit, '9')">1</xsl:when>
3358
- <xsl:otherwise>0</xsl:otherwise>
3359
- </xsl:choose>
3360
- </xsl:template>
3361
-
3362
- <xsl:template name="FStrContainsDigits">
3363
- <xsl:param name="s"/>
3364
-
3365
- <!-- Translate any digit into a 0 -->
3366
- <xsl:variable name="sDigitsToZeroDigit" select="translate($s, '123456789', '000000000')"/>
3367
- <xsl:choose>
3368
- <!-- Search for 0s -->
3369
- <xsl:when test="contains($sDigitsToZeroDigit, '0')">1</xsl:when>
3370
- <xsl:otherwise>0</xsl:otherwise>
3371
- </xsl:choose>
3372
- </xsl:template>
3373
-
3374
-
3375
- <!-- Used to determine if mpadded attribute {width, height, depth }
3376
- indicates to show everything.
3377
-
3378
- Unlike mathml, whose mpadded structure has great flexibility in modifying the
3379
- bounding box's width, height, and depth, Word can only have zero or full width, height, and depth.
3380
- Thus, if the width, height, or depth attributes indicate any kind of nonzero width, height,
3381
- or depth, we'll translate that into a show full width, height, or depth for OMML. Only if the attribute
3382
- indicates a zero width, height, or depth, will we report back FFull as false.
3383
-
3384
- Example: s=0% -> FFull returns 0.
3385
- s=2% -> FFull returns 1.
3386
- s=0.1em -> FFull returns 1.
3387
-
3388
- -->
3389
- <xsl:template name="FFull">
3390
- <xsl:param name="s"/>
3391
-
3392
- <xsl:variable name="fStrContainsNonZeroDigit">
3393
- <xsl:call-template name="FStrContainsNonZeroDigit">
3394
- <xsl:with-param name="s" select="$s"/>
3395
- </xsl:call-template>
3396
- </xsl:variable>
3397
-
3398
- <xsl:variable name="fStrContainsDigits">
3399
- <xsl:call-template name="FStrContainsDigits">
3400
- <xsl:with-param name="s" select="$s"/>
3401
- </xsl:call-template>
3402
- </xsl:variable>
3403
-
3404
- <xsl:choose>
3405
- <!-- String contained non-zero digit -->
3406
- <xsl:when test="$fStrContainsNonZeroDigit=1">1</xsl:when>
3407
- <!-- String didn't contain a non-zero digit, but it did contain digits.
3408
- This must mean that all digits in the string were 0s. -->
3409
- <xsl:when test="$fStrContainsDigits=1">0</xsl:when>
3410
- <!-- Else, no digits, therefore, return true.
3411
- We return true in the otherwise condition to take account for the possibility
3412
- in MathML to say something like width="height". -->
3413
- <xsl:otherwise>1</xsl:otherwise>
3414
- </xsl:choose>
3415
- </xsl:template>
3416
-
3417
-
3418
- <!-- Just outputs phant properties, doesn't do any fancy
3419
- thinking of its own, just obeys the defaults of
3420
- phants. -->
3421
- <xsl:template name="CreatePhantPropertiesCore">
3422
- <xsl:param name="fShow" select="1"/>
3423
- <xsl:param name="fFullWidth" select="1"/>
3424
- <xsl:param name="fFullHeight" select="1"/>
3425
- <xsl:param name="fFullDepth" select="1"/>
3426
-
3427
- <xsl:if test="$fShow=0 or $fFullWidth=0 or $fFullHeight=0 or $fFullDepth=0">
3428
- <phantPr>
3429
- <xsl:if test="$fShow=0">
3430
- <show>
3431
- <xsl:attribute name="m:val">off</xsl:attribute>
3432
- </show>
3433
- </xsl:if>
3434
- <xsl:if test="$fFullWidth=0">
3435
- <zeroWid>
3436
- <xsl:attribute name="m:val">on</xsl:attribute>
3437
- </zeroWid>
3438
- </xsl:if>
3439
- <xsl:if test="$fFullHeight=0">
3440
- <zeroAsc>
3441
- <xsl:attribute name="m:val">on</xsl:attribute>
3442
- </zeroAsc>
3443
- </xsl:if>
3444
- <xsl:if test="$fFullDepth=0">
3445
- <zeroDesc>
3446
- <xsl:attribute name="m:val">on</xsl:attribute>
3447
- </zeroDesc>
3448
- </xsl:if>
3449
- </phantPr>
3450
- </xsl:if>
3451
- </xsl:template>
3452
-
3453
- <!-- Figures out if we should factor in width, height, and depth attributes.
3454
-
3455
- If so, then it
3456
- gets these attributes, does some processing to figure out what the attributes indicate,
3457
- then passes these indications to CreatePhantPropertiesCore.
3458
-
3459
- If we aren't supposed to factor in width, height, or depth, then we'll just output the show
3460
- attribute. -->
3461
- <xsl:template name="CreatePhantProperties">
3462
- <xsl:param name="ndCur" select="."/>
3463
- <xsl:param name="fShow" select="1"/>
3464
-
3465
- <xsl:choose>
3466
- <!-- In the special case that we have an mphantom with one child which is an mpadded, then we should
3467
- subsume the mpadded attributes into the mphantom attributes. The test statement below imples the
3468
- 'one child which is an mpadded'. The first part, that the parent of mpadded is an mphantom, is implied
3469
- by being in this template, which is only called when we've encountered an mphantom.
3470
-
3471
- Word outputs its invisible phantoms with smashing as
3472
-
3473
- <mml:mphantom>
3474
- <mml:mpadded . . . >
3475
-
3476
- </mml:mpadded>
3477
- </mml:mphantom>
3478
-
3479
- This test is used to allow roundtripping smashed invisible phantoms. -->
3480
- <xsl:when test="count($ndCur/child::*)=1 and count($ndCur/mml:mpadded)=1">
3481
- <xsl:variable name="sLowerCaseWidth">
3482
- <xsl:choose>
3483
- <xsl:when test="$ndCur/mml:mpadded/@width">
3484
- <xsl:value-of select="translate($ndCur/mml:mpadded/@width, $StrUCAlphabet, $StrLCAlphabet)"/>
3485
- </xsl:when>
3486
- <xsl:otherwise>
3487
- <xsl:value-of select="translate($ndCur/mml:mpadded/@mml:width, $StrUCAlphabet, $StrLCAlphabet)"/>
3488
- </xsl:otherwise>
3489
- </xsl:choose>
3490
- </xsl:variable>
3491
- <xsl:variable name="sLowerCaseHeight">
3492
- <xsl:choose>
3493
- <xsl:when test="$ndCur/mml:mpadded/@height">
3494
- <xsl:value-of select="translate($ndCur/mml:mpadded/@height, $StrUCAlphabet, $StrLCAlphabet)"/>
3495
- </xsl:when>
3496
- <xsl:otherwise>
3497
- <xsl:value-of select="translate($ndCur/mml:mpadded/@mml:height, $StrUCAlphabet, $StrLCAlphabet)"/>
3498
- </xsl:otherwise>
3499
- </xsl:choose>
3500
- </xsl:variable>
3501
- <xsl:variable name="sLowerCaseDepth">
3502
- <xsl:choose>
3503
- <xsl:when test="$ndCur/mml:mpadded/@depth">
3504
- <xsl:value-of select="translate($ndCur/mml:mpadded/@depth, $StrUCAlphabet, $StrLCAlphabet)"/>
3505
- </xsl:when>
3506
- <xsl:otherwise>
3507
- <xsl:value-of select="translate($ndCur/mml:mpadded/@mml:depth, $StrUCAlphabet, $StrLCAlphabet)"/>
3508
- </xsl:otherwise>
3509
- </xsl:choose>
3510
- </xsl:variable>
3511
-
3512
- <xsl:variable name="fFullWidth">
3513
- <xsl:call-template name="FFull">
3514
- <xsl:with-param name="s" select="$sLowerCaseWidth"/>
3515
- </xsl:call-template>
3516
- </xsl:variable>
3517
- <xsl:variable name="fFullHeight">
3518
- <xsl:call-template name="FFull">
3519
- <xsl:with-param name="s" select="$sLowerCaseHeight"/>
3520
- </xsl:call-template>
3521
- </xsl:variable>
3522
- <xsl:variable name="fFullDepth">
3523
- <xsl:call-template name="FFull">
3524
- <xsl:with-param name="s" select="$sLowerCaseDepth"/>
3525
- </xsl:call-template>
3526
- </xsl:variable>
3527
-
3528
- <xsl:call-template name="CreatePhantPropertiesCore">
3529
- <xsl:with-param name="fShow" select="$fShow"/>
3530
- <xsl:with-param name="fFullWidth" select="$fFullWidth"/>
3531
- <xsl:with-param name="fFullHeight" select="$fFullHeight"/>
3532
- <xsl:with-param name="fFullDepth" select="$fFullDepth"/>
3533
- </xsl:call-template>
3534
- </xsl:when>
3535
- <xsl:otherwise>
3536
- <xsl:call-template name="CreatePhantPropertiesCore">
3537
- <xsl:with-param name="fShow" select="$fShow"/>
3538
- </xsl:call-template>
3539
- </xsl:otherwise>
3540
- </xsl:choose>
3541
- </xsl:template>
3542
-
3543
- <xsl:template mode="mml" match="mml:mpadded">
3544
- <xsl:choose>
3545
- <xsl:when test="count(parent::mml:mphantom)=1 and count(preceding-sibling::*)=0 and count(following-sibling::*)=0">
3546
- <!-- This mpadded is inside an mphantom that has already setup phantom attributes, therefore, just apply templates -->
3547
- <xsl:apply-templates mode="mml"/>
3548
- </xsl:when>
3549
- <xsl:otherwise>
3550
- <xsl:variable name="sLowerCaseWidth">
3551
- <xsl:choose>
3552
- <xsl:when test="@width">
3553
- <xsl:value-of select="@width"/>
3554
- </xsl:when>
3555
- <xsl:otherwise>
3556
- <xsl:value-of select="@mml:width"/>
3557
- </xsl:otherwise>
3558
- </xsl:choose>
3559
- </xsl:variable>
3560
- <xsl:variable name="sLowerCaseHeight">
3561
- <xsl:choose>
3562
- <xsl:when test="@height">
3563
- <xsl:value-of select="@height"/>
3564
- </xsl:when>
3565
- <xsl:otherwise>
3566
- <xsl:value-of select="@mml:height"/>
3567
- </xsl:otherwise>
3568
- </xsl:choose>
3569
- </xsl:variable>
3570
- <xsl:variable name="sLowerCaseDepth">
3571
- <xsl:choose>
3572
- <xsl:when test="@depth">
3573
- <xsl:value-of select="@depth"/>
3574
- </xsl:when>
3575
- <xsl:otherwise>
3576
- <xsl:value-of select="@mml:depth"/>
3577
- </xsl:otherwise>
3578
- </xsl:choose>
3579
- </xsl:variable>
3580
-
3581
- <xsl:variable name="fFullWidth">
3582
- <xsl:call-template name="FFull">
3583
- <xsl:with-param name="s" select="$sLowerCaseWidth"/>
3584
- </xsl:call-template>
3585
- </xsl:variable>
3586
- <xsl:variable name="fFullHeight">
3587
- <xsl:call-template name="FFull">
3588
- <xsl:with-param name="s" select="$sLowerCaseHeight"/>
3589
- </xsl:call-template>
3590
- </xsl:variable>
3591
- <xsl:variable name="fFullDepth">
3592
- <xsl:call-template name="FFull">
3593
- <xsl:with-param name="s" select="$sLowerCaseDepth"/>
3594
- </xsl:call-template>
3595
- </xsl:variable>
3596
-
3597
- <phant>
3598
- <xsl:call-template name="CreatePhantPropertiesCore">
3599
- <xsl:with-param name="fShow" select="1"/>
3600
- <xsl:with-param name="fFullWidth" select="$fFullWidth"/>
3601
- <xsl:with-param name="fFullHeight" select="$fFullHeight"/>
3602
- <xsl:with-param name="fFullDepth" select="$fFullDepth"/>
3603
- </xsl:call-template>
3604
- <e>
3605
- <xsl:apply-templates mode="mml"/>
3606
- </e>
3607
- </phant>
3608
- </xsl:otherwise>
3609
- </xsl:choose>
3610
- </xsl:template>
3611
-
3612
- <xsl:template mode="mml" match="mml:mphantom">
3613
- <phant>
3614
- <xsl:call-template name="CreatePhantProperties">
3615
- <xsl:with-param name="ndCur" select="."/>
3616
- <xsl:with-param name="fShow" select="0"/>
3617
- </xsl:call-template>
3618
- <e>
3619
- <xsl:apply-templates mode="mml"/>
3620
- </e>
3621
- </phant>
3622
- </xsl:template>
3623
-
3624
- <xsl:template name="isNaryOper">
3625
- <xsl:param name="sNdCur"/>
3626
- <xsl:value-of select="($sNdCur = '∫' or $sNdCur = '∬' or $sNdCur = '∭' or $sNdCur = '∮' or $sNdCur = '∯' or $sNdCur = '∰' or $sNdCur = '∲' or $sNdCur = '∳' or $sNdCur = '∱' or $sNdCur = '∩' or $sNdCur = '∪' or $sNdCur = '∏' or $sNdCur = '∐' or $sNdCur = '∑')"/>
3627
- </xsl:template>
3628
-
3629
-
3630
- <xsl:template name="isNary">
3631
- <!-- ndCur is the element around the nAry operator -->
3632
- <xsl:param name="ndCur"/>
3633
- <xsl:variable name="sNdCur">
3634
- <xsl:value-of select="normalize-space($ndCur)"/>
3635
- </xsl:variable>
3636
-
3637
- <xsl:variable name="fNaryOper">
3638
- <xsl:call-template name="isNaryOper">
3639
- <xsl:with-param name="sNdCur" select="$sNdCur"/>
3640
- </xsl:call-template>
3641
- </xsl:variable>
3642
-
3643
- <!-- Narys shouldn't be MathML accents. -->
3644
- <xsl:variable name="fUnder">
3645
- <xsl:choose>
3646
- <xsl:when test="$ndCur/parent::*[self::mml:munder]">1</xsl:when>
3647
- <xsl:otherwise>0</xsl:otherwise>
3648
- </xsl:choose>
3649
- </xsl:variable>
3650
-
3651
- <xsl:variable name="sLowerCaseAccent">
3652
- <xsl:choose>
3653
- <xsl:when test="$fUnder=1">
3654
- <xsl:choose>
3655
- <xsl:when test="$ndCur/parent::*[self::mml:munder]/@accentunder">
3656
- <xsl:value-of select="translate($ndCur/parent::*[self::mml:munder]/@accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
3657
- </xsl:when>
3658
- <xsl:otherwise>
3659
- <xsl:value-of select="translate($ndCur/parent::*[self::mml:munder]/@mml:accentunder, $StrUCAlphabet, $StrLCAlphabet)"/>
3660
- </xsl:otherwise>
3661
- </xsl:choose>
3662
- </xsl:when>
3663
- <xsl:otherwise>
3664
- <xsl:choose>
3665
- <xsl:when test="$ndCur/parent::*/@accent">
3666
- <xsl:value-of select="translate($ndCur/parent::*/@accent, $StrUCAlphabet, $StrLCAlphabet)"/>
3667
- </xsl:when>
3668
- <xsl:otherwise>
3669
- <xsl:value-of select="translate($ndCur/parent::*/@mml:accent, $StrUCAlphabet, $StrLCAlphabet)"/>
3670
- </xsl:otherwise>
3671
- </xsl:choose>
3672
- </xsl:otherwise>
3673
- </xsl:choose>
3674
- </xsl:variable>
3675
-
3676
- <xsl:variable name="fAccent">
3677
- <xsl:choose>
3678
- <xsl:when test="$sLowerCaseAccent='true'">1</xsl:when>
3679
- <xsl:otherwise>0</xsl:otherwise>
3680
- </xsl:choose>
3681
- </xsl:variable>
3682
-
3683
- <xsl:choose>
3684
- <!-- This ndCur is in fact part of an nAry if
3685
-
3686
- 1) The last descendant of ndCur (which could be ndCur itself) is an operator.
3687
- 2) Along that chain of descendants we only encounter mml:mo, mml:mstyle, and mml:mrow elements.
3688
- 3) the operator in mml:mo is a valid nAry operator
3689
- 4) The nAry is not accented.
3690
- -->
3691
- <xsl:when test="$fNaryOper = 'true' and $fAccent=0 and $ndCur/descendant-or-self::*[last()]/self::mml:mo and not($ndCur/descendant-or-self::*[not(self::mml:mo or self::mml:mstyle or self::mml:mrow)])">
3692
- <xsl:value-of select="true()"/>
3693
- </xsl:when>
3694
- <xsl:otherwise>
3695
- <xsl:value-of select="false()"/>
3696
- </xsl:otherwise>
3697
- </xsl:choose>
3698
- </xsl:template>
3699
-
3700
- <xsl:template name="CreateNaryProp">
3701
- <xsl:param name="chr"/>
3702
- <xsl:param name="sMathmlType"/>
3703
- <naryPr>
3704
- <chr>
3705
- <xsl:attribute name="m:val">
3706
- <xsl:value-of select="$chr"/>
3707
- </xsl:attribute>
3708
- </chr>
3709
- <limLoc>
3710
- <xsl:attribute name="m:val">
3711
- <xsl:choose>
3712
- <xsl:when test="$sMathmlType='munder' or $sMathmlType='mover' or $sMathmlType='munderover'">
3713
- <xsl:text>undOvr</xsl:text>
3714
- </xsl:when>
3715
- <xsl:when test="$sMathmlType='msub' or $sMathmlType='msup' or $sMathmlType='msubsup'">
3716
- <xsl:text>subSup</xsl:text>
3717
- </xsl:when>
3718
- </xsl:choose>
3719
- </xsl:attribute>
3720
- </limLoc>
3721
- <grow>
3722
- <xsl:attribute name="m:val">
3723
- <xsl:value-of select="'on'"/>
3724
- </xsl:attribute>
3725
- </grow>
3726
- <subHide>
3727
- <xsl:attribute name="m:val">
3728
- <xsl:choose>
3729
- <xsl:when test="$sMathmlType='mover' or $sMathmlType='msup'">
3730
- <xsl:text>on</xsl:text>
3731
- </xsl:when>
3732
- <xsl:otherwise>
3733
- <xsl:text>off</xsl:text>
3734
- </xsl:otherwise>
3735
- </xsl:choose>
3736
- </xsl:attribute>
3737
- </subHide>
3738
- <supHide>
3739
- <xsl:attribute name="m:val">
3740
- <xsl:choose>
3741
- <xsl:when test="$sMathmlType='munder' or $sMathmlType='msub'">
3742
- <xsl:text>on</xsl:text>
3743
- </xsl:when>
3744
- <xsl:otherwise>
3745
- <xsl:text>off</xsl:text>
3746
- </xsl:otherwise>
3747
- </xsl:choose>
3748
- </xsl:attribute>
3749
- </supHide>
3750
- </naryPr>
3751
- </xsl:template>
3752
-
3753
- <xsl:template name="mathrRpHook"/>
3754
- </xsl:stylesheet>