1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
|
<?xml version="1.0" encoding="utf-8"?>
<!--
This style sheet is used in the Math4All project. This project
will provide an on-line math method for secondary and tertiary
education. In addition to the web-bases content the project
provides high quality typeset output as well.
This stylesheet is a copy of the one used by the group of Arjeh
Cohen (TU Eindhoven). This steet has multiple authors: David
Carlisle, and Clare M. So and Hans Cuypers (also see notice
below.)
In due time we may extend this sheet with options needed for the
project (alternative rendering, additional dictionaries).
Hans Hagen, PRAGMA ADE, Hasselt NL / 2006-04-14
-->
<!-- ********************************************************** -->
<!-- XSL Transform of OpenMath to Content MathML -->
<!-- (Based on initial version by David Carlisle) -->
<!-- -->
<!-- Author: Clare M. So <clare@scl.csd.uwo.ca> -->
<!-- -->
<!-- May to August 2002 -->
<!-- -->
<!-- (Last updated July 9, 2003) -->
<!-- ********************************************************** -->
<!-- ********************************************************** -->
<!-- CHANGE LOG -->
<!-- ********************************************************** -->
<!-- May 13, 2003 - Add template nthdiff of calculus1 CD -->
<!-- May 14, 2003 - Add templates for moreerrors CD -->
<!-- May 15, 2003 - Split templates for multiset1, set1, -->
<!-- and list1 CDs -->
<!-- Split templates for s_dist1 and s_data1 CDs -->
<!-- June 4, 2003 - Fix bugs in splitting set1, multiset1, and -->
<!-- set1 CDs -->
<!-- - Add templates for transc3 CD -->
<!-- July 9, 2003 - Add template for nthdiff -->
<!-- Special MathML entities -->
<!DOCTYPE stylesheet [
<!ENTITY pi "π">
<!ENTITY e "𡑾">
<!ENTITY ee "𡑾">
<!ENTITY ExponentialE "𡑾">
<!ENTITY ImaginaryI "ⅈ">
<!ENTITY ii "ⅈ">
<!ENTITY gamma "γ">
<!ENTITY infin "∞">
<!ENTITY infty "∞">
<!ENTITY true "󰀂">
<!ENTITY false "󰀃">
<!ENTITY NotANumber "󰀁">
<!ENTITY NaN "󰀁">
]>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:om="http://www.openmath.org/OpenMath"
xmlns="http://www.w3.org/1998/Math/MathML"
exclude-result-prefixes="om"
version="1.0">
<!-- xsl:output method="xml" indent="yes"/ -->
<xsl:output method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="defaultOMSpriority">-10</xsl:variable>
<!-- **************************************************** -->
<!-- ****************** Basic Elements ****************** -->
<!-- **************************************************** -->
<!-- OMOBJ (D. Carlisle) / adapted by HH -->
<xsl:template match="om:OMOBJ">
<xsl:choose>
<xsl:when test="@style='inline'">
<imath>
<xsl:apply-templates/>
</imath>
</xsl:when>
<xsl:when test="@style='display'">
<dmath>
<xsl:apply-templates/>
</dmath>
</xsl:when>
<xsl:otherwise>
<math>
<xsl:apply-templates/>
</math>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- OMI (D. Carlisle) -->
<xsl:template match="om:OMI">
<cn type="integer">
<xsl:variable name="x" select="normalize-space(.)"/>
<xsl:choose>
<xsl:when test="contains($x,'x')">
<xsl:attribute name="base">16</xsl:attribute>
<xsl:value-of select="concat(substring-before($x,'x'),substring-after($x,'x'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$x"/> <!-- default is decimal -->
</xsl:otherwise>
</xsl:choose>
</cn>
</xsl:template>
<!-- OMV (D. Carlisle) -->
<xsl:template match="om:OMV">
<ci>
<xsl:value-of select="normalize-space(@name)"/>
</ci>
</xsl:template>
<!-- OMF (decimal) -->
<xsl:template match="om:OMF[@dec]">
<cn>
<xsl:value-of select="normalize-space(@dec)"/>
</cn>
</xsl:template>
<!-- OMF (hex) -->
<xsl:template match="om:OMF[@hex]">
<cn base="16">
<xsl:value-of select="normalize-space(@hex)"/>
</cn>
</xsl:template>
<!-- OMA (D. Carlisle) -->
<xsl:template match="om:OMA">
<apply>
<xsl:apply-templates/>
</apply>
</xsl:template>
<!-- OMB -->
<!-- Note: No Content MathML equivalent -->
<xsl:template match="om:OMB">
<mtext definitionURL="http://www.openmath.org/objects#OMB">
<xsl:value-of select="."/>
</mtext>
</xsl:template>
<!-- OMSTR (D. Carlisle) -->
<!-- Note: mtext is a presentational MathML tag -->
<xsl:template match="om:OMSTR">
<mtext>
<xsl:value-of select="."/>
</mtext>
</xsl:template>
<!-- ***************************************************** -->
<!-- ****************** MathML group ******************** -->
<!-- ***************************************************** -->
<!-- Content Dicitionary: alg1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: zero, one -->
<!-- Trivial cases: none -->
<xsl:template match="om:OMS[@cd='alg1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- zero -->
<xsl:template match="om:OMS[@cd='alg1' and @name='zero']">
<cn type="integer">0</cn>
</xsl:template>
<!-- one -->
<xsl:template match="om:OMS[@cd='alg1' and @name='one']">
<cn type="integer">1</cn>
</xsl:template>
<!-- Content Dictionary: arith1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD conatains: abs, divide, gcd, lcm, minus, plus, power, product,
root, sum, unary_minus -->
<!-- Trivial Cases: abs, divide, gcd, lcm, minus, plus -->
<xsl:template match="om:OMS[@cd='arith1']">
<xsl:element name="{@name}">
<xsl:choose>
<xsl:when test="@name='times'">
<xsl:choose>
<xsl:when test="../@style='empty'">
<xsl:attribute name='symbol'></xsl:attribute>
</xsl:when>
<xsl:when test="../@style='cross'">
<xsl:attribute name='symbol'>times</xsl:attribute>
</xsl:when>
<xsl:when test="../@style=''">
<!-- inherit from parent times -->
</xsl:when>
<xsl:otherwise>
<xsl:attribute name='symbol'><xsl:value-of select="../@style"/></xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@name='divide'">
<xsl:choose>
<xsl:when test="../@style='inline'">
<xsl:attribute name='alternative'>b</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="@name='plus'">
<xsl:choose>
<xsl:when test="../@style='empty'">
<xsl:attribute name='alternative'>b</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- forget about it -->
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- unary_minus -->
<xsl:template match="om:OMS[@cd='arith1' and @name='unary_minus']">
<minus/>
</xsl:template>
<!-- root -->
<xsl:template match="om:OMA[om:OMS[@cd='arith1' and @name='root']]">
<apply>
<root/>
<degree>
<xsl:apply-templates select="*[3]"/>
</degree>
<xsl:apply-templates select="*[2]"/>
</apply>
</xsl:template>
<!-- sum and product -->
<xsl:template match="om:OMA[om:OMS[@cd='arith1' and (@name='sum' or @name='product')]]">
<apply>
<xsl:element name="{om:OMS[1]/@name}"/>
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="3"/> <!-- the bounded var is in the func -->
</xsl:apply-templates>
</bvar>
<xsl:apply-templates select="*[2]"/> <!-- range of product/summation -->
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: bigfloat1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: bigfloat, bigfloatprec -->
<!-- Trivial cases: none -->
<!-- bigfloat -->
<xsl:template match="om:OMA[om:OMS[@cd='bigfloat1' and @name='bigfloat']]">
<apply>
<times/>
<xsl:apply-templates select="*[2]"/>
<apply>
<power/>
<xsl:apply-templates select="*[3]"/>
<xsl:apply-templates select="*[4]"/>
</apply>
</apply>
</xsl:template>
<!-- bigfloatprec -->
<!-- Note: No Content MathML equivalent -->
<xsl:template match="om:OMS[@cd='bigfloat1' and @name='bigfloatprec']">
<csymbol encoding="OpenMath"
definitionURL="http://www.openmath.org/cd/bigfloat1#bigfloatprec"/>
</xsl:template>
<!-- Content Dictionary: calculus1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: defint, diff, int, nthdiff, partialdiff -->
<!-- Trivial cases: partialdiff -->
<xsl:template match="om:OMS[@cd='calculus1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- diff, int -->
<xsl:template match="om:OMA[om:OMS[@cd='calculus1' and (@name='diff' or @name='int')]]">
<apply>
<xsl:element name="{om:OMS[1]/@name}"/>
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="2"/>
</xsl:apply-templates>
</bvar>
<xsl:apply-templates select="*[2]"/>
</apply>
</xsl:template>
<!-- defint -->
<xsl:template match="om:OMA[om:OMS[@cd='calculus1' and @name='defint']]">
<apply>
<int/> <!-- pretty much the same as sum and product... CHECK domainofapp -->
<bvar> <!-- perphaps write a method for the similar parts... -->
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="3"/>
</xsl:apply-templates>
</bvar>
<xsl:apply-templates select="*[2]"/> <!-- range of diff -->
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:template>
<!-- nthdiff -->
<xsl:template match="om:OMA[om:OMS[@cd='calculus1' and @name='nthdiff']]">
<apply>
<diff/>
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="3"/>
</xsl:apply-templates>
<xsl:apply-templates select="*[2]"/>
</bvar>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:template>
<!-- Content Dictionaries: complex1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: argument, complex_cartesian, complex_polar, conjugate,
imaginary, real -->
<!-- Trivial cases: conjugate, imaginary, real -->
<xsl:template match="om:OMS[@cd='complex1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- argument -->
<xsl:template match="om:OMS[@cd='complex1' and @name='argument']">
<arg/>
</xsl:template>
<!-- complex_cartesian or complex_polar -->
<xsl:template match="om:OMA[om:OMS[@cd='complex1' and (@name='complex_cartesian' or @name='complex_polar')]]">
<xsl:variable name="type_name" select="translate(om:OMS[1]/@name,'_','-')"/>
<xsl:choose>
<xsl:when test="child::om:OMV or child::om:OMA">
<apply>
<csymbol definitionURL="{concat('http://www.openmath.org/cd/complex1#',om:OMS[1]/@name)}"/>
<xsl:apply-templates select="*[2]"/>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:when>
<xsl:otherwise>
<cn type="{$type_name}">
<xsl:apply-templates select="*[2]" mode="convert"/>
<sep/>
<xsl:apply-templates select="*[3]" mode="convert"/>
</cn>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Content Dictionary: fns1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: domain, domainofapplication, identity, image, inverse,
lambda, left_compose, left_inverse, right_inverse -->
<!-- Trivial cases: domain, image, inverse -->
<xsl:template match="om:OMS[@cd='fns1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- domainofapplication -->
<xsl:template match="om:OMA[om:OMS[@cd='fns1' and @name='domainofapplication']]">
<domainofapplication>
<xsl:apply-templates select="*[2]"/>
</domainofapplication>
</xsl:template>
<!-- identity -->
<xsl:template match="om:OMS[@cd='fns1' and @name='identity']">
<ident/>
</xsl:template>
<!-- lambda -->
<xsl:template match="om:OMBIND[om:OMS[@cd='fns1' and @name='lambda']]">
<lambda>
<xsl:for-each select="om:OMBVAR/child::om:OMV">
<bvar>
<xsl:apply-templates select="."/>
</bvar>
</xsl:for-each>
<xsl:apply-templates select="*[3]"/>
</lambda>
</xsl:template>
<!-- range -->
<xsl:template match="om:OMS[@cd='fns1' and @name='range']">
<codomain/>
</xsl:template>
<!-- left_compose -->
<xsl:template match="om:OMS[@cd='fns1' and @name='left_compose']">
<compose/>
</xsl:template>
<!-- left_inverse -->
<xsl:template match="om:OMS[@cd='fns1' and @name='left_inverse']">
<inverse/>
</xsl:template>
<!-- right_inverse -->
<!-- Note: No Content MathML equivalent -->
<xsl:template match="om:OMS[@cd='fns1' and @name='right_inverse']">
<inverse encoding="OpenMath" definitionURL="http://www.openmath.org/cd/fns1#right_inverse"/>
</xsl:template>
<!-- Content Dictionary: integer1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: factorial, factorof, quotient, remainder -->
<!-- Trivial cases: factorof, factorial, quotient -->
<xsl:template match="om:OMS[@cd='integer1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- remainder -->
<xsl:template match="om:OMS[@cd='integer1' and @name='remainder']">
<rem/>
</xsl:template>
<!-- Content Dictionary: interval1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: integer_interval, interval, interval_oo, interval_cc,
interval_oc, interval_co -->
<!-- Trivial case: none -->
<!-- (All) -->
<xsl:template match="om:OMA[om:OMS[@cd='interval1']]">
<interval>
<xsl:choose>
<xsl:when test="om:OMS[1]/@name='interval_oo'">
<xsl:attribute name='closure'>open</xsl:attribute>
</xsl:when>
<xsl:when test="om:OMS[1]/@name='interval_cc'">
<xsl:attribute name='closure'>closed</xsl:attribute>
</xsl:when>
<xsl:when test="om:OMS[1]/@name='interval_oc'">
<xsl:attribute name='closure'>open-closed</xsl:attribute>
</xsl:when>
<xsl:when test="om:OMS[1]/@name='interval_co'">
<xsl:attribute name='closure'>closed-open</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:apply-templates select="*[2]"/>
<xsl:apply-templates select="*[3]"/>
</interval>
</xsl:template>
<!-- Content Dictionary: linalg1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: determinant, matrix_selector, outerproduct,
scalarproduct, transpose, vector_selector, vector_product -->
<!-- Trivial cases: determinant, outerproduct, scalarproduct, transpose,
vectorproduct -->
<xsl:template match="om:OMS[@cd='linalg1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- vector_selector -->
<xsl:template match="om:OMA[om:OMS[@cd='linalg1' and @name='vector_selector']]">
<apply>
<selector/>
<xsl:apply-templates select="*[3]"/> <!-- the vector -->
<xsl:apply-templates select="*[2]"/>
</apply>
</xsl:template>
<!-- matrix_selector -->
<xsl:template match="om:OMA[om:OMS[@cd='linalg1' and @name='matrix_selector']]">
<apply>
<selector/>
<xsl:apply-templates select="*[4]"/> <!-- the matrix -->
<xsl:apply-templates select="*[3]"/>
<xsl:apply-templates select="*[2]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: linalg2 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: matrix, matrixrow, vector -->
<!-- Trivial cases: none -->
<!-- matrixrow, matrix -->
<xsl:template match="om:OMA[om:OMS[@cd='linalg2']]">
<xsl:element name="{om:OMS[1]/@name}">
<xsl:apply-templates select="*[position()>1]"/>
</xsl:element>
</xsl:template>
<!-- (row) vector -->
<xsl:template match="om:OMA[om:OMS[@cd='linalg2' and @name='vector']]">
<apply>
<transpose/>
<vector>
<xsl:apply-templates select="*[position()>1]"/>
</vector>
</apply>
</xsl:template>
<!-- Content Dictionary: limit1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: above, below, bothsides, limit, null -->
<!-- Trivial cases: none -->
<!-- both_sides, above, below, null -->
<xsl:template match="om:OMA[om:OMS[@cd='limit1']]">
<apply>
<limit/>
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="4"/>
</xsl:apply-templates>
</bvar>
<xsl:choose>
<xsl:when test="om:OMS[2]/@name='null'">
<lowlimit>
<xsl:apply-templates select="*[2]"/>
</lowlimit>
</xsl:when>
<xsl:otherwise>
<condition>
<apply>
<tendsto>
<xsl:choose>
<xsl:when test="om:OMS[2]/@name='both_sides'">
<xsl:attribute name="type">all</xsl:attribute>
</xsl:when>
<xsl:when test="om:OMS[2]/@name='above'">
<xsl:attribute name="type">above</xsl:attribute>
</xsl:when>
<xsl:when test="om:OMS[2]/@name='below'">
<xsl:attribute name="type">below</xsl:attribute>
</xsl:when>
</xsl:choose>
</tendsto>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="4"/>
</xsl:apply-templates>
<xsl:apply-templates select="*[2]"/>
</apply>
</condition>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="*[4]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: list1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: list, map, suchthat -->
<!-- Trivial cases: none -->
<!-- list -->
<xsl:template match="om:OMA[om:OMS[@cd='list1' and @name='list']]">
<list>
<xsl:apply-templates select="*[position()>1]"/>
</list>
</xsl:template>
<!-- map -->
<xsl:template match="om:OMA[om:OMS[@cd='list1' and @name='map']]">
<list>
<xsl:apply-templates select="." mode="map"/>
</list>
</xsl:template>
<!-- suchthat -->
<xsl:template match="om:OMA[om:OMS[@cd='list1' and @name='suchthat']]">
<list>
<xsl:apply-templates select="." mode="suchthat"/>
</list>
</xsl:template>
<!-- Content Dictionary: logic1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: and, equivalent, false, implies, not, or, true, xor -->
<!-- Trivial cases: all -->
<xsl:template match="om:OMS[@cd='logic1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- Content Dictionary: mathmltypes -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: complex_cartesian_type, complex_polar_type, constant_type,
fn_type, integer_type, list_type, matrix_type, rational_type, real_type,
set_type, type, vector_type -->
<!-- (All mathmltypes elements) -->
<xsl:template match="om:OMATTR[om:OMATP[om:OMS[@cd='mathmltypes' and @name='type']]]">
<xsl:variable name="type_name" select="normalize-space(translate(substring-before(om:OMATP/om:OMS[2]/@name,'_type'),'_','-'))"/>
<xsl:choose>
<xsl:when test="*[2]=om:OMV">
<ci type="{$type_name}">
<xsl:value-of select="normalize-space(*[2]/@name)"/>
</ci>
</xsl:when>
<xsl:when test="*[2]=om:OMI">
<cn type="{$type_name}">
<xsl:variable name="x" select="normalize-space(*[2])"/>
<xsl:choose>
<xsl:when test="contains($x,'x')">
<xsl:attribute name="base">16</xsl:attribute>
<xsl:value-of select="concat(substring-before($x,'x'),substring-after($x,'x'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$x"/> <!-- default is decimal -->
</xsl:otherwise>
</xsl:choose>
</cn>
</xsl:when>
<xsl:when test="*[2]=om:OMF[@dec]">
<cn type="{$type_name}">
<xsl:value-of select="normalize-space(*[2]/@dec)"/>
</cn>
</xsl:when>
<xsl:when test="*[2]=om:OMF[@hex]">
<cn type="{$type_name}" base="16">
<xsl:value-of select="normalize-space(*[2]/@hex)"/>
</cn>
</xsl:when>
<xsl:otherwise> <!-- MathML cannot add type attribute to other objects -->
<xsl:comment>
Content MathML cannot add type <xsl:value-of select="$type_name"/> for the object after this comment.
</xsl:comment>
<xsl:apply-templates select="*[2]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Content Dictionary: minmax1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: max, min -->
<xsl:template match="om:OMS[@cd='minmax1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- Trivial cases: none -->
<!-- max, min -->
<xsl:template match="om:OMA[om:OMS[@cd='minmax1']]">
<apply>
<xsl:element name="{om:OMS/@name}"/>
<xsl:choose>
<xsl:when test="*[2]=om:OMA[om:OMS[@cd='set1' and @name='set']]">
<xsl:apply-templates select="om:OMA/*[position()>1]"/>
</xsl:when>
<xsl:when test="*[2]=om:OMA[om:OMS[@cd='multiset1' and @name='multiset']]">
<xsl:apply-templates select="om:OMA/*[position()>1]"/>
</xsl:when>
<xsl:when test="*[2]=om:OMA[om:OMS[@cd='set1' and @name='suchthat']]">
<xsl:apply-templates select="*[2]" mode="suchthat"/>
</xsl:when>
<xsl:when test="*[2]=om:OMA[om:OMS[@cd='set1' and @name='map']]">
<xsl:apply-templates select="*[2]" mode="map"/>
</xsl:when>
<xsl:otherwise>
<bvar><ci>x</ci></bvar>
<condition>
<apply>
<in/>
<ci>x</ci>
<xsl:apply-templates select="*[2]"/>
</apply>
</condition>
</xsl:otherwise>
</xsl:choose>
</apply>
</xsl:template>
<!-- Content Dictionary: multiset1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: cartesian_product, emptyset, in, intersect, multiset,
notin, notprsubset, notsubset, prsubset, setdiff, size, subset, union -->
<!-- Trivial cases: emptyset, in, interset, notin, notprsubset, notsubset, prsubset,
subset, union -->
<xsl:template match="om:OMS[@cd='multiset1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- cartesian_product -->
<xsl:template match="om:OMS[@cd='multiset1' and @name='cartesian_product']">
<cartesianproduct/>
</xsl:template>
<!-- multiset -->
<xsl:template match="om:OMA[om:OMS[@cd='multiset1' and @name='multiset']]">
<set type="multiset">
<xsl:apply-templates select="*[position()>1]"/>
</set>
</xsl:template>
<!-- size -->
<xsl:template match="om:OMS[@cd='multiset1' and @name='size']">
<card/>
</xsl:template>
<!-- Content Dictionary: nums1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains based_integer, e, gamma, i, infinity, NaN, pi, rational -->
<!-- Trivial cases: pi, infinity -->
<xsl:template match="om:OMS[@cd='nums1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- based_integer -->
<!-- Note: Content MathML does not support base that is represented by a variable -->
<xsl:template match="om:OMA[om:OMS[@cd='nums1' and @name='based_integer']]">
<xsl:choose>
<xsl:when test="*[2]=om:OMV">
<apply>
<csymbol encoding="OpenMath" definitionURL="http://www.openmath.org/cd/nums1#based_integer"/>
<xsl:apply-templates select="*[2]"/>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:when>
<xsl:otherwise>
<cn type="integer" base="{normalize-space(*[2])}">
<xsl:value-of select="normalize-space(om:OMSTR)"/>
</cn>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- e -->
<xsl:template match="om:OMS[@cd='nums1' and @name='e']">
<exponentiale/>
</xsl:template>
<!-- gamma -->
<xsl:template match="om:OMS[@cd='nums1' and @name='gamma']">
<eulergamma/>
</xsl:template>
<!-- i -->
<xsl:template match="om:OMS[@cd='nums1' and @name='i']">
<imaginaryi/>
</xsl:template>
<!-- NaN -->
<xsl:template match="om:OMS[@cd='nums1' and @name='NaN']">
<notanumber/>
</xsl:template>
<!-- rational -->
<!-- Note: Content MathML does not support rational numbers that are
made up of variables or other mathematical objects -->
<xsl:template match="om:OMA[om:OMS[@cd='nums1' and @name='rational']]">
<xsl:choose>
<xsl:when test="child::om:OMV or child::om:OMA">
<apply>
<csymbol definitionURL="http://www.openmath.org/cd/nums1#rational"/>
<xsl:apply-templates select="*[2]"/>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:when>
<xsl:otherwise>
<cn type="rational">
<xsl:apply-templates select="*[2]" mode="convert"/>
<sep/>
<xsl:apply-templates select="*[3]" mode="convert"/>
</cn>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Content Dictionary: piece1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: otherwise, piece, piecewise -->
<!-- Trivial cases: (All of the OMSs here are almost trivial, except
that these functions are used without "apply" in Content MathML) -->
<!-- piecewise, piece, otherwise -->
<xsl:template match="om:OMA[om:OMS[@cd='piece1']]">
<xsl:element name="{om:OMS/@name}">
<xsl:apply-templates select="*[position()>1]"/>
</xsl:element>
</xsl:template>
<!-- Content Dictionary: quant1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: forall, exists -->
<!-- forall,exists -->
<xsl:template match="om:OMBIND[om:OMS[@cd='quant1']]">
<apply>
<xsl:element name="{om:OMS[1]/@name}"/>
<xsl:for-each select="om:OMBVAR/om:OMV">
<bvar>
<xsl:apply-templates select="."/>
</bvar>
</xsl:for-each>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: relation1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: approx, eq, geq, gt, leq, lt, neq -->
<!-- Trivial cases: all -->
<xsl:template match="om:OMS[@cd='relation1']">
<xsl:element name="{@name}">
<xsl:if test="../@style!=''">
<xsl:attribute name='align'><xsl:value-of select="../@style"/></xsl:attribute>
</xsl:if>
</xsl:element>
</xsl:template>
<!-- Content Dictionary: setname1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: C, N, P, Q, R, Z -->
<!-- Trivial cases: none -->
<!-- P -->
<xsl:template match="om:OMS[@cd='setname1' and @name='P']">
<primes/>
</xsl:template>
<!-- N -->
<xsl:template match="om:OMS[@cd='setname1' and @name='N']">
<naturalnumbers/>
</xsl:template>
<!-- Z -->
<xsl:template match="om:OMS[@cd='setname1' and @name='Z']">
<integers/>
</xsl:template>
<!-- Z -->
<xsl:template match="om:OMS[@cd='setname1' and @name='Q']">
<rationals/>
</xsl:template>
<!-- R -->
<xsl:template match="om:OMS[@cd='setname1' and @name='R']">
<reals/>
</xsl:template>
<!-- C -->
<xsl:template match="om:OMS[@cd='setname1' and @name='C']">
<complexes/>
</xsl:template>
<!-- Content Dictionary: rounding1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: ceiling, floor, round, trunc -->
<!-- Trivial Cases: ceiling, floor -->
<xsl:template match="om:OMS[@cd='rounding1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- trunc -->
<xsl:template match="om:OMA[om:OMS[@cd='rounding1' and @name='trunc']]">
<apply>
<quotient/>
<xsl:apply-templates select="*[2]"/>
<cn>1</cn>
</apply>
</xsl:template>
<!-- round -->
<xsl:template match="om:OMA[om:OMS[@cd='rounding1' and @name='round']]">
<piecewise>
<piece>
<apply>
<floor/>
<apply>
<plus/>
<cn>0.5</cn>
<xsl:apply-templates select="*[2]"/>
</apply>
</apply>
<apply>
<geq/>
<xsl:apply-templates select="*[2]"/>
<cn>0</cn>
</apply>
</piece>
<piece>
<apply>
<ceiling/>
<apply>
<minus/>
<xsl:apply-templates select="*[2]"/>
<cn>0.5</cn>
</apply>
</apply>
<apply>
<lt/>
<xsl:apply-templates select="*[2]"/>
<cn>0</cn>
</apply>
</piece>
</piecewise>
</xsl:template>
<!-- Content Dictionary: set1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: cartesian_product, emptyset, in, intersect, map, notin,
notprsubset, notsubset, prsubset, set, setdiff, size, subset, suchthat, union -->
<!-- Trivial cases: emptyset, in, intersect, notin, notprsubset, notsubset, prsubset
setdiff, subset, union -->
<xsl:template match="om:OMS[@cd='set1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- cartesian_product -->
<xsl:template match="om:OMS[@cd='set1' and @name='cartesian_product']">
<cartesianproduct/>
</xsl:template>
<!-- map -->
<xsl:template match="om:OMA[om:OMS[@cd='set1' and @name='map']]">
<set>
<xsl:apply-templates select="." mode="map"/>
</set>
</xsl:template>
<!-- size -->
<xsl:template match="om:OMS[@cd='set1' and @name='size']">
<card/>
</xsl:template>
<!-- suchthat -->
<xsl:template match="om:OMA[om:OMS[@cd='set1' and @name='suchthat']]">
<set>
<xsl:apply-templates select="." mode="suchthat"/>
</set>
</xsl:template>
<!-- Content Dictionary: s_data1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: mean, median, mode, moment, sdev, variance -->
<!-- Trivial cases: mean, median, mode, sdev, variance -->
<xsl:template match="om:OMS[@cd='s_data1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- moment -->
<xsl:template match="om:OMA[om:OMS[@cd='s_data1' and @name='moment']]">
<apply>
<moment/>
<degree>
<xsl:apply-templates select="*[2]"/>
</degree>
<momentabout>
<xsl:apply-templates select="*[3]"/>
</momentabout>
<xsl:apply-templates select="*[position()>3]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: s_dist1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: mean, moment, sdev, variance -->
<!-- Trivial cases: mean, sdev, variance -->
<xsl:template match="om:OMS[@cd='s_dist1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- moment -->
<xsl:template match="om:OMA[om:OMS[@cd='s_dist1' and @name='moment']]">
<apply>
<moment/>
<degree>
<xsl:apply-templates select="*[2]"/>
</degree>
<momentabout>
<xsl:apply-templates select="*[3]"/>
</momentabout>
<xsl:apply-templates select="*[position()>3]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: transc1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: arccos, arccosh, arccot, arccoth, arccsc,
arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, cos,
cosh, cot, coth, csc, csch, exp, ln, log, sec, sech, sin, sinh,
tan, tanh -->
<!-- Trivial cases: all except log -->
<xsl:template match="om:OMS[@cd='transc1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- log -->
<xsl:template match="om:OMA[om:OMS[@cd='transc1' and @name='log']]">
<apply>
<log/>
<logbase>
<xsl:apply-templates select="*[2]"/>
</logbase>
<xsl:apply-templates select="*[3]"/>
</apply>
</xsl:template>
<!-- Content Dictionary: veccalc1 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: curl, divergence, grad, Laplacian -->
<!-- Trivial cases: all except Laplacian -->
<xsl:template match="om:OMS[@cd='veccalc1']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- Laplacian -->
<!-- Note: Capital "L" -->
<xsl:template match="om:OMS[@cd='veccalc1' and @name='Laplacian']">
<laplacian/>
</xsl:template>
<!-- Content Dictionary: altenc -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: TeX_encoding, MathML_encoding -->
<!-- Trivial cases: none -->
<!-- (Everything in altenc) -->
<xsl:template match="om:OMATTR[om:OMATP[om:OMS[@cd='altenc']]]">
<semantics>
<xsl:apply-templates select="*[2]"/>
<xsl:apply-templates select="om:OMATP/child::om:OMS"/>
</semantics>
</xsl:template>
<!-- MathML_encoding -->
<xsl:template match="om:OMS[@cd='altenc' and @name='MathML_encoding']">
<annotation-xml encoding="MathML">
<xsl:value-of select="normalize-space(following-sibling::*[position()=1])"/> <!-- OMXML or OMSTR-->
</annotation-xml>
</xsl:template>
<!-- TeX_encoding -->
<xsl:template match="om:OMS[@cd='altenc' and @name='TeX_encoding']">
<annotation encoding="TeX">
<xsl:value-of select="normalize-space(following::om:OMSTR)"/>
</annotation>
</xsl:template>
<!-- **************************************************** -->
<!-- ************** Not in MathML group CDs ************* -->
<!-- **************************************************** -->
<!-- Everything below should not be handled by the Trivial case!) -->
<!-- Content Dictionary: linalg3 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- (column) vector -->
<xsl:template match="om:OMA[om:OMS[@cd='linalg3' and @name='vector']]">
<vector>
<xsl:apply-templates select="*[position()>1]"/>
</vector>
</xsl:template>
<!-- Content Dictionary: arith2 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: inverse, times -->
<!-- times -->
<!-- Note: This function is n-ary just like MathML! -->
<xsl:template match="om:OMS[@cd='arith2' and @name='times']">
<times/>
</xsl:template>
<!-- Content Dictionary: error -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- (all errors) -->
<xsl:template match="om:OME">
<mtext>
<xsl:text>ERROR:</xsl:text>
<xsl:text> Error Type: </xsl:text><xsl:value-of select="om:OMS[1]/@name"/>
<xsl:text> Error occured in CD: </xsl:text><xsl:value-of select="om:OMS[2]/@cd"/>
<xsl:text> Error occured in symbol: </xsl:text><xsl:value-of select="om:OMS[2]/@name"/>
</mtext>
</xsl:template>
<!-- Content Dictionary: moreerrors -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: algorithm, asynchronousError, encodingError, limitation,
unexpected -->
<!-- (all) -->
<xsl:template match="om:OMA[om:OMS[@cd='moreerrors']]">
<mtext>
<xsl:text>ERROR:</xsl:text>
<xsl:text> Error Type: </xsl:text><xsl:value-of select="normalize-space(om:OMS/@name)"/>
<xsl:text> Description: </xsl:text><xsl:value-of select="normalize-space(om:OMSTR)"/>
</mtext>
</xsl:template>
<!-- Content Dicitionary: transc3 -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- This CD contains: arccos, arccosh, arccot, arccoth, arccsc, arccsch,
arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, ln, log -->
<!-- (all except log) -->
<xsl:template match="om:OMS[@cd='transc3']">
<xsl:element name="{@name}"/>
</xsl:template>
<!-- log -->
<xsl:template match="om:OMA[om:OMS[@cd='transc3' and @name='log']]">
<apply>
<log/>
<logbase>
<xsl:apply-templates select="*[3]"/>
</logbase>
<xsl:apply-templates select="*[2]"/>
</apply>
</xsl:template>
<!-- **************************************************** -->
<!-- **************** EVERYTHING ELSE ******************* -->
<!-- **************************************************** -->
<!-- Note: Rather than hard code all of the CDs, I just assign the lowest
priority among all templates. -->
<xsl:template match="om:OMS[@cd and @name]" priority="-10">
<csymbol>
<xsl:attribute name="definitionURL">
<xsl:value-of select="concat(concat(concat('http://www.openmath.org/cd/',@cd),'#'),@name)"/>
</xsl:attribute>
</csymbol>
</xsl:template>
<!-- **************************************************** -->
<!-- **************** HELPER TEMPLATES ****************** -->
<!-- **************************************************** -->
<!-- All mode "convert" templates are for converting OMSs or OMIs to
numbers including in various cn containing <sep/> -->
<xsl:template match="om:OMS[@cd='alg1' and @name='zero']" mode="convert">0</xsl:template>
<xsl:template match="om:OMS[@cd='alg1' and @name='one']" mode="convert">1</xsl:template>
<xsl:template match="om:OMS" mode="convert">
<xsl:choose>
<xsl:when test="@name='pi'">π</xsl:when>
<xsl:when test="@name='i'">ⅈ</xsl:when>
<xsl:when test="@name='NaN'">&NaN;</xsl:when>
<xsl:when test="@name='gamma'">γ</xsl:when>
<xsl:when test="@name='e'">ⅇ</xsl:when>
<xsl:when test="@name='true'">&true;</xsl:when>
<xsl:when test="@name='false'">&false;</xsl:when>
<xsl:when test="@name='infinity'">∞</xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space(.)"/></xsl:otherwise> <!-- for debugging -->
</xsl:choose>
</xsl:template>
<xsl:template match="om:OMI" mode="convert">
<xsl:variable name="x" select="normalize-space(.)"/>
<xsl:choose>
<xsl:when test="contains($x,'x')">
<xsl:value-of select="concat(substring-before($x,'x'),substring-after($x,'x'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$x"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="om:OMF" mode="convert">
<xsl:value-of select="@*"/>
</xsl:template>
<!-- The following templates, with mode "map" and "suchthat", are used to contruct sets or lists
without enumerating every element -->
<xsl:template match="om:OMA" mode="map">
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="2"/>
</xsl:apply-templates>
</bvar>
<condition>
<apply>
<in/>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="2"/>
</xsl:apply-templates>
<xsl:apply-templates select="*[3]"/>
</apply>
</condition>
<xsl:apply-templates select="*[2]"/>
</xsl:template>
<xsl:template match="om:OMA" mode="suchthat">
<bvar>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="3"/>
</xsl:apply-templates>
</bvar>
<condition>
<apply>
<and/>
<xsl:apply-templates select="*[3]"/>
<apply>
<in/>
<xsl:apply-templates select="." mode="getVar">
<xsl:with-param name="NUM" select="3"/>
</xsl:apply-templates>
<xsl:apply-templates select="*[2]"/>
</apply>
</apply>
</condition>
</xsl:template>
<!-- This template is for getting bound variables (all variables in <OMBIND>) -->
<!-- Note: Default bound variable is "x" -->
<xsl:template match="om:OMA" mode="getVar">
<xsl:param name="NUM" select="3"/>
<xsl:choose>
<xsl:when test="*[$NUM]=om:OMBIND">
<xsl:apply-templates select="*[$NUM]/om:OMBVAR/om:OMV[position()>0]"/>
</xsl:when>
<xsl:otherwise> <!-- default -->
<ci>x</ci>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Added by Hans Hagen -->
<xsl:template match="om:OMS[@cd='altenc' and @name='TeX_encoding']">
<annotation encoding="TeX">
<xsl:value-of select="normalize-space(following::om:OMSTR)"/>
</annotation>
</xsl:template>
<xsl:template match="om:OMS[(@cd='math4all' or @cd='mathadore' or @cd='m4all') and @name]">
<csymbol>
<xsl:attribute name="definitionURL">
<xsl:value-of select="concat(concat('http://www.openmath.org/cd/mathadore','#'),@name)"/>
</xsl:attribute>
</csymbol>
</xsl:template>
<!--
<xsl:template match="om:OMS[@cd='mathadore' and @name]">
<csymbol>
<xsl:attribute name="definitionURL">
<xsl:value-of select="concat(concat(@cd,'#'),@name)"/>
</xsl:attribute>
</csymbol>
</xsl:template>
-->
<xsl:template match="om:OMA[om:OMS[@cd='combinat1' and @name='binomial']]">
<matrix>
<matrixrow><xsl:apply-templates select="*[2]"/></matrixrow>
<matrixrow><xsl:apply-templates select="*[3]"/></matrixrow>
</matrix>
</xsl:template>
<!-- <OMS cd="units_siprefix1" name="centi" cdbase="mathadore"/> -->
<!-- <OMS cd="units_metric1" name="metre" cdbase="mathadore"/> -->
<xsl:template match="om:OMS[contains(@cd,'units_')]">
<csymbol>
<xsl:attribute name="definitionURL">
<xsl:value-of select="concat(concat(concat(concat(
'http://www.openmath.org/cd/mathadore','#'),@cd),'@'),@name)"/>
</xsl:attribute>
</csymbol>
</xsl:template>
</xsl:stylesheet>
|