doctor_ninja 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d4dbe54c2d34c2cc0481a10f0ce79d5cb5adb12
4
- data.tar.gz: 3ff5d61d7881e9de0cb7dfe8bba073baba545d8b
3
+ metadata.gz: db1ad5b209ae3e6a5226f9358390542805b662e6
4
+ data.tar.gz: 0bc93c3b04997461dd39fea952808b1151dae903
5
5
  SHA512:
6
- metadata.gz: ae7621385d40e9fde469e28e0093ec0c2a430a3ea0279b94b76d5c878e2c8316a9ed20213a7f0fca3ddc8132056c3b71b6488e54dd52de71db39c494c50951bd
7
- data.tar.gz: ee13e6c5bde4d8a2c41e1a1edca2f98f9a36be610d89fefc5406f04ef338d9980dbd15c8355a1368f7a5973e9c0be5f60fff276646e616c081d47ef3654f48d5
6
+ metadata.gz: 73822b4d67bf11d24c064b8703722b58ff99bca1ce7a7324afdd5c38cefe8273f630db60677bdf5d60d645583ffda0e753e9de96e761463cbf910cfa94926c1d
7
+ data.tar.gz: 3aa6cf7073e3e26294306f09e337298a3d015dd5b9bda65bed2c6d82c59250ced21077f00024db83f3b333284b2a0aef8fae19a31093b73503f9a5dc5bb93ee5
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "pry", "~>0.10"
26
26
  spec.add_development_dependency "phashion", "~>1.1"
27
27
 
28
- spec.add_dependency "nokogiri", "~> 1.6"
28
+ spec.add_dependency "nokogiri", "~> 1.4"
29
29
  spec.add_dependency "rubyzip", "~> 1.1"
30
30
  spec.add_dependency "rmagick", "~> 2.13"
31
31
  end
@@ -1,2068 +1,2068 @@
1
- <?xml version="1.0" encoding="UTF-8" ?>
2
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mml="http://www.w3.org/1998/Math/MathML"
3
- xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
4
- <xsl:output method="xml" encoding="UTF-8" />
5
-
6
- <!-- %% Global Definitions -->
7
-
8
- <!-- Every single unicode character that is recognized by OMML as an operator -->
9
- <xsl:variable name="sOperators"
10
- select="concat(
11
- '&#x00A8;&#x0021;&#x0022;&#x0023;&#x0026;&#x0028;&#x0029;&#x002B;&#x002C;&#x002D;&#x002E;&#x002F;&#x003A;',
12
- '&#x003B;&#x003C;&#x003D;&#x003E;&#x003F;&#x0040;&#x005B;&#x005C;&#x005D;&#x005E;&#x005F;&#x0060;&#x007B;',
13
- '&#x007C;&#x007D;&#x007E;&#x00A1;&#x00A6;&#x00AC;&#x00AF;&#x00B0;&#x00B1;&#x00B2;&#x00B3;&#x00B4;&#x00B7;&#x00B9;&#x00BF;',
14
- '&#x00D7;&#x007E;&#x00F7;&#x02C7;&#x02D8;&#x02D9;&#x02DC;&#x02DD;&#x0300;&#x0301;&#x0302;&#x0303;&#x0304;&#x0305;&#x0306;&#x0307;&#x0308;&#x0309;',
15
- '&#x030A;&#x030B;&#x030C;&#x030D;&#x030E;&#x030F;&#x0310;&#x0311;&#x0312;&#x0313;&#x0314;&#x0315;',
16
- '&#x0316;&#x0317;&#x0318;&#x0319;&#x031A;&#x031B;&#x031C;&#x031D;&#x031E;&#x031F;&#x0320;&#x0321;',
17
- '&#x0322;&#x0323;&#x0324;&#x0325;&#x0326;&#x0327;&#x0328;&#x0329;&#x032A;&#x032B;&#x032C;&#x032D;',
18
- '&#x032E;&#x032F;&#x0330;&#x0331;&#x0332;&#x0333;&#x0334;&#x0335;&#x0336;&#x0337;&#x0338;&#x033F;',
19
- '&#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;&#x2006;&#x2009;&#x200A;&#x2010;&#x2012;&#x2013;',
20
- '&#x2014;&#x2016;&#x2020;&#x2021;&#x2022;&#x2024;&#x2025;&#x2026;&#x2032;&#x2033;&#x2034;&#x203C;',
21
- '&#x2040;&#x2044;&#x204E;&#x204F;&#x2050;&#x2057;&#x2061;&#x2062;&#x2063;&#x2070;&#x2074;&#x2075;',
22
- '&#x2076;&#x2077;&#x2078;&#x2079;&#x207A;&#x207B;&#x207C;&#x207D;&#x207E;&#x2080;&#x2081;&#x2082;',
23
- '&#x2083;&#x2084;&#x2085;&#x2086;&#x2087;&#x2088;&#x2089;&#x208A;&#x208B;&#x208C;&#x208D;&#x208E;',
24
- '&#x20D0;&#x20D1;&#x20D2;&#x20D3;&#x20D4;&#x20D5;&#x20D6;&#x20D7;&#x20D8;&#x20D9;&#x20DA;&#x20DB;',
25
- '&#x20DC;&#x20DD;&#x20DE;&#x20DF;&#x20E0;&#x20E1;&#x20E4;&#x20E5;&#x20E6;&#x20E7;&#x20E8;&#x20E9;',
26
- '&#x20EA;&#x2140;&#x2146;&#x2190;&#x2191;&#x2192;&#x2193;&#x2194;&#x2195;&#x2196;&#x2197;&#x2198;&#x2199;',
27
- '&#x219A;&#x219B;&#x219C;&#x219D;&#x219E;&#x219F;&#x21A0;&#x21A1;&#x21A2;&#x21A3;&#x21A4;&#x21A5;',
28
- '&#x21A6;&#x21A7;&#x21A8;&#x21A9;&#x21AA;&#x21AB;&#x21AC;&#x21AD;&#x21AE;&#x21AF;&#x21B0;&#x21B1;',
29
- '&#x21B2;&#x21B3;&#x21B6;&#x21B7;&#x21BA;&#x21BB;&#x21BC;&#x21BD;&#x21BE;&#x21BF;&#x21C0;&#x21C1;',
30
- '&#x21C2;&#x21C3;&#x21C4;&#x21C5;&#x21C6;&#x21C7;&#x21C8;&#x21C9;&#x21CA;&#x21CB;&#x21CC;&#x21CD;',
31
- '&#x21CE;&#x21CF;&#x21D0;&#x21D1;&#x21D2;&#x21D3;&#x21D4;&#x21D5;&#x21D6;&#x21D7;&#x21D8;&#x21D9;',
32
- '&#x21DA;&#x21DB;&#x21DC;&#x21DD;&#x21DE;&#x21DF;&#x21E0;&#x21E1;&#x21E2;&#x21E3;&#x21E4;&#x21E5;',
33
- '&#x21E6;&#x21E7;&#x21E8;&#x21E9;&#x21F3;&#x21F4;&#x21F5;&#x21F6;&#x21F7;&#x21F8;&#x21F9;&#x21FA;',
34
- '&#x21FB;&#x21FC;&#x21FD;&#x21FE;&#x21FF;&#x2200;&#x2201;&#x2202;&#x2203;&#x2204;&#x2206;&#x2207;',
35
- '&#x2208;&#x2209;&#x220A;&#x220B;&#x220C;&#x220D;&#x220F;&#x2210;&#x2211;&#x2212;&#x2213;&#x2214;',
36
- '&#x2215;&#x2216;&#x2217;&#x2218;&#x2219;&#x221A;&#x221B;&#x221C;&#x221D;&#x2223;&#x2224;&#x2225;',
37
- '&#x2226;&#x2227;&#x2228;&#x2229;&#x222A;&#x222B;&#x222C;&#x222D;&#x222E;&#x222F;&#x2230;&#x2231;',
38
- '&#x2232;&#x2233;&#x2234;&#x2235;&#x2236;&#x2237;&#x2238;&#x2239;&#x223A;&#x223B;&#x223C;&#x223D;',
39
- '&#x223E;&#x2240;&#x2241;&#x2242;&#x2243;&#x2244;&#x2245;&#x2246;&#x2247;&#x2248;&#x2249;&#x224A;',
40
- '&#x224B;&#x224C;&#x224D;&#x224E;&#x224F;&#x2250;&#x2251;&#x2252;&#x2253;&#x2254;&#x2255;&#x2256;',
41
- '&#x2257;&#x2258;&#x2259;&#x225A;&#x225B;&#x225C;&#x225D;&#x225E;&#x225F;&#x2260;&#x2261;&#x2262;',
42
- '&#x2263;&#x2264;&#x2265;&#x2266;&#x2267;&#x2268;&#x2269;&#x226A;&#x226B;&#x226C;&#x226D;&#x226E;',
43
- '&#x226F;&#x2270;&#x2271;&#x2272;&#x2273;&#x2274;&#x2275;&#x2276;&#x2277;&#x2278;&#x2279;&#x227A;',
44
- '&#x227B;&#x227C;&#x227D;&#x227E;&#x227F;&#x2280;&#x2281;&#x2282;&#x2283;&#x2284;&#x2285;&#x2286;',
45
- '&#x2287;&#x2288;&#x2289;&#x228A;&#x228B;&#x228C;&#x228D;&#x228E;&#x228F;&#x2290;&#x2291;&#x2292;',
46
- '&#x2293;&#x2294;&#x2295;&#x2296;&#x2297;&#x2298;&#x2299;&#x229A;&#x229B;&#x229C;&#x229D;&#x229E;',
47
- '&#x229F;&#x22A0;&#x22A1;&#x22A2;&#x22A3;&#x22A5;&#x22A6;&#x22A7;&#x22A8;&#x22A9;&#x22AA;&#x22AB;',
48
- '&#x22AC;&#x22AD;&#x22AE;&#x22AF;&#x22B0;&#x22B1;&#x22B2;&#x22B3;&#x22B4;&#x22B5;&#x22B6;&#x22B7;',
49
- '&#x22B8;&#x22B9;&#x22BA;&#x22BB;&#x22BC;&#x22BD;&#x22C0;&#x22C1;&#x22C2;&#x22C3;&#x22C4;&#x22C5;',
50
- '&#x22C6;&#x22C7;&#x22C8;&#x22C9;&#x22CA;&#x22CB;&#x22CC;&#x22CD;&#x22CE;&#x22CF;&#x22D0;&#x22D1;',
51
- '&#x22D2;&#x22D3;&#x22D4;&#x22D5;&#x22D6;&#x22D7;&#x22D8;&#x22D9;&#x22DA;&#x22DB;&#x22DC;&#x22DD;',
52
- '&#x22DE;&#x22DF;&#x22E0;&#x22E1;&#x22E2;&#x22E3;&#x22E4;&#x22E5;&#x22E6;&#x22E7;&#x22E8;&#x22E9;',
53
- '&#x22EA;&#x22EB;&#x22EC;&#x22ED;&#x22EE;&#x22EF;&#x22F0;&#x22F1;&#x22F2;&#x22F3;&#x22F4;&#x22F5;',
54
- '&#x22F6;&#x22F7;&#x22F8;&#x22F9;&#x22FA;&#x22FB;&#x22FC;&#x22FD;&#x22FE;&#x22FF;&#x2305;&#x2306;',
55
- '&#x2308;&#x2309;&#x230A;&#x230B;&#x231C;&#x231D;&#x231E;&#x231F;&#x2322;&#x2323;&#x2329;&#x232A;',
56
- '&#x233D;&#x233F;&#x23B0;&#x23B1;&#x23DC;&#x23DD;&#x23DE;&#x23DF;&#x23E0;&#x2502;&#x251C;&#x2524;',
57
- '&#x252C;&#x2534;&#x2581;&#x2588;&#x2592;&#x25A0;&#x25A1;&#x25AD;&#x25B2;&#x25B3;&#x25B4;&#x25B5;',
58
- '&#x25B6;&#x25B7;&#x25B8;&#x25B9;&#x25BC;&#x25BD;&#x25BE;&#x25BF;&#x25C0;&#x25C1;&#x25C2;&#x25C3;',
59
- '&#x25C4;&#x25C5;&#x25CA;&#x25CB;&#x25E6;&#x25EB;&#x25EC;&#x25F8;&#x25F9;&#x25FA;&#x25FB;&#x25FC;',
60
- '&#x25FD;&#x25FE;&#x25FF;&#x2605;&#x2606;&#x2772;&#x2773;&#x27D1;&#x27D2;&#x27D3;&#x27D4;&#x27D5;',
61
- '&#x27D6;&#x27D7;&#x27D8;&#x27D9;&#x27DA;&#x27DB;&#x27DC;&#x27DD;&#x27DE;&#x27DF;&#x27E0;&#x27E1;',
62
- '&#x27E2;&#x27E3;&#x27E4;&#x27E5;&#x27E6;&#x27E7;&#x27E8;&#x27E9;&#x27EA;&#x27EB;&#x27F0;&#x27F1;',
63
- '&#x27F2;&#x27F3;&#x27F4;&#x27F5;&#x27F6;&#x27F7;&#x27F8;&#x27F9;&#x27FA;&#x27FB;&#x27FC;&#x27FD;',
64
- '&#x27FE;&#x27FF;&#x2900;&#x2901;&#x2902;&#x2903;&#x2904;&#x2905;&#x2906;&#x2907;&#x2908;&#x2909;',
65
- '&#x290A;&#x290B;&#x290C;&#x290D;&#x290E;&#x290F;&#x2910;&#x2911;&#x2912;&#x2913;&#x2914;&#x2915;',
66
- '&#x2916;&#x2917;&#x2918;&#x2919;&#x291A;&#x291B;&#x291C;&#x291D;&#x291E;&#x291F;&#x2920;&#x2921;',
67
- '&#x2922;&#x2923;&#x2924;&#x2925;&#x2926;&#x2927;&#x2928;&#x2929;&#x292A;&#x292B;&#x292C;&#x292D;',
68
- '&#x292E;&#x292F;&#x2930;&#x2931;&#x2932;&#x2933;&#x2934;&#x2935;&#x2936;&#x2937;&#x2938;&#x2939;',
69
- '&#x293A;&#x293B;&#x293C;&#x293D;&#x293E;&#x293F;&#x2940;&#x2941;&#x2942;&#x2943;&#x2944;&#x2945;',
70
- '&#x2946;&#x2947;&#x2948;&#x2949;&#x294A;&#x294B;&#x294C;&#x294D;&#x294E;&#x294F;&#x2950;&#x2951;',
71
- '&#x2952;&#x2953;&#x2954;&#x2955;&#x2956;&#x2957;&#x2958;&#x2959;&#x295A;&#x295B;&#x295C;&#x295D;',
72
- '&#x295E;&#x295F;&#x2960;&#x2961;&#x2962;&#x2963;&#x2964;&#x2965;&#x2966;&#x2967;&#x2968;&#x2969;',
73
- '&#x296A;&#x296B;&#x296C;&#x296D;&#x296E;&#x296F;&#x2970;&#x2971;&#x2972;&#x2973;&#x2974;&#x2975;',
74
- '&#x2976;&#x2977;&#x2978;&#x2979;&#x297A;&#x297B;&#x297C;&#x297D;&#x297E;&#x297F;&#x2980;&#x2982;',
75
- '&#x2983;&#x2984;&#x2985;&#x2986;&#x2987;&#x2988;&#x2989;&#x298A;&#x298B;&#x298C;&#x298D;&#x298E;',
76
- '&#x298F;&#x2990;&#x2991;&#x2992;&#x2993;&#x2994;&#x2995;&#x2996;&#x2997;&#x2998;&#x2999;&#x299A;',
77
- '&#x29B6;&#x29B7;&#x29B8;&#x29B9;&#x29C0;&#x29C1;&#x29C4;&#x29C5;&#x29C6;&#x29C7;&#x29C8;&#x29CE;',
78
- '&#x29CF;&#x29D0;&#x29D1;&#x29D2;&#x29D3;&#x29D4;&#x29D5;&#x29D6;&#x29D7;&#x29D8;&#x29D9;&#x29DA;',
79
- '&#x29DB;&#x29DF;&#x29E1;&#x29E2;&#x29E3;&#x29E4;&#x29E5;&#x29E6;&#x29EB;&#x29F4;&#x29F5;&#x29F6;',
80
- '&#x29F7;&#x29F8;&#x29F9;&#x29FA;&#x29FB;&#x29FC;&#x29FD;&#x29FE;&#x29FF;&#x2A00;&#x2A01;&#x2A02;',
81
- '&#x2A03;&#x2A04;&#x2A05;&#x2A06;&#x2A07;&#x2A08;&#x2A09;&#x2A0A;&#x2A0B;&#x2A0C;&#x2A0D;&#x2A0E;',
82
- '&#x2A0F;&#x2A10;&#x2A11;&#x2A12;&#x2A13;&#x2A14;&#x2A15;&#x2A16;&#x2A17;&#x2A18;&#x2A19;&#x2A1A;',
83
- '&#x2A1B;&#x2A1C;&#x2A1D;&#x2A1E;&#x2A1F;&#x2A20;&#x2A21;&#x2A22;&#x2A23;&#x2A24;&#x2A25;&#x2A26;',
84
- '&#x2A27;&#x2A28;&#x2A29;&#x2A2A;&#x2A2B;&#x2A2C;&#x2A2D;&#x2A2E;&#x2A2F;&#x2A30;&#x2A31;&#x2A32;',
85
- '&#x2A33;&#x2A34;&#x2A35;&#x2A36;&#x2A37;&#x2A38;&#x2A39;&#x2A3A;&#x2A3B;&#x2A3C;&#x2A3D;&#x2A3E;',
86
- '&#x2A3F;&#x2A40;&#x2A41;&#x2A42;&#x2A43;&#x2A44;&#x2A45;&#x2A46;&#x2A47;&#x2A48;&#x2A49;&#x2A4A;',
87
- '&#x2A4B;&#x2A4C;&#x2A4D;&#x2A4E;&#x2A4F;&#x2A50;&#x2A51;&#x2A52;&#x2A53;&#x2A54;&#x2A55;&#x2A56;',
88
- '&#x2A57;&#x2A58;&#x2A59;&#x2A5A;&#x2A5B;&#x2A5C;&#x2A5D;&#x2A5E;&#x2A5F;&#x2A60;&#x2A61;&#x2A62;',
89
- '&#x2A63;&#x2A64;&#x2A65;&#x2A66;&#x2A67;&#x2A68;&#x2A69;&#x2A6A;&#x2A6B;&#x2A6C;&#x2A6D;&#x2A6E;',
90
- '&#x2A6F;&#x2A70;&#x2A71;&#x2A72;&#x2A73;&#x2A74;&#x2A75;&#x2A76;&#x2A77;&#x2A78;&#x2A79;&#x2A7A;',
91
- '&#x2A7B;&#x2A7C;&#x2A7D;&#x2A7E;&#x2A7F;&#x2A80;&#x2A81;&#x2A82;&#x2A83;&#x2A84;&#x2A85;&#x2A86;',
92
- '&#x2A87;&#x2A88;&#x2A89;&#x2A8A;&#x2A8B;&#x2A8C;&#x2A8D;&#x2A8E;&#x2A8F;&#x2A90;&#x2A91;&#x2A92;',
93
- '&#x2A93;&#x2A94;&#x2A95;&#x2A96;&#x2A97;&#x2A98;&#x2A99;&#x2A9A;&#x2A9B;&#x2A9C;&#x2A9D;&#x2A9E;',
94
- '&#x2A9F;&#x2AA0;&#x2AA1;&#x2AA2;&#x2AA3;&#x2AA4;&#x2AA5;&#x2AA6;&#x2AA7;&#x2AA8;&#x2AA9;&#x2AAA;',
95
- '&#x2AAB;&#x2AAC;&#x2AAD;&#x2AAE;&#x2AAF;&#x2AB0;&#x2AB1;&#x2AB2;&#x2AB3;&#x2AB4;&#x2AB5;&#x2AB6;',
96
- '&#x2AB7;&#x2AB8;&#x2AB9;&#x2ABA;&#x2ABB;&#x2ABC;&#x2ABD;&#x2ABE;&#x2ABF;&#x2AC0;&#x2AC1;&#x2AC2;',
97
- '&#x2AC3;&#x2AC4;&#x2AC5;&#x2AC6;&#x2AC7;&#x2AC8;&#x2AC9;&#x2ACA;&#x2ACB;&#x2ACC;&#x2ACD;&#x2ACE;',
98
- '&#x2ACF;&#x2AD0;&#x2AD1;&#x2AD2;&#x2AD3;&#x2AD4;&#x2AD5;&#x2AD6;&#x2AD7;&#x2AD8;&#x2AD9;&#x2ADA;',
99
- '&#x2ADB;&#x2ADC;&#x2ADD;&#x2ADE;&#x2ADF;&#x2AE0;&#x2AE2;&#x2AE3;&#x2AE4;&#x2AE5;&#x2AE6;&#x2AE7;',
100
- '&#x2AE8;&#x2AE9;&#x2AEA;&#x2AEB;&#x2AEC;&#x2AED;&#x2AEE;&#x2AEF;&#x2AF0;&#x2AF2;&#x2AF3;&#x2AF4;',
101
- '&#x2AF5;&#x2AF6;&#x2AF7;&#x2AF8;&#x2AF9;&#x2AFA;&#x2AFB;&#x2AFC;&#x2AFD;&#x2AFE;&#x2AFF;&#x2B04;',
102
- '&#x2B06;&#x2B07;&#x2B0C;&#x2B0D;&#x3014;&#x3015;&#x3016;&#x3017;&#x3018;&#x3019;&#xFF01;&#xFF06;',
103
- '&#xFF08;&#xFF09;&#xFF0B;&#xFF0C;&#xFF0D;&#xFF0E;&#xFF0F;&#xFF1A;&#xFF1B;&#xFF1C;&#xFF1D;&#xFF1E;',
104
- '&#xFF1F;&#xFF20;&#xFF3B;&#xFF3C;&#xFF3D;&#xFF3E;&#xFF3F;&#xFF5B;&#xFF5C;&#xFF5D;')" />
105
-
106
- <!-- A string of '-'s repeated exactly as many times as the operators above -->
107
- <xsl:variable name="sMinuses">
108
- <xsl:call-template name="SRepeatChar">
109
- <xsl:with-param name="cchRequired" select="string-length($sOperators)" />
110
- <xsl:with-param name="ch" select="'-'" />
111
- </xsl:call-template>
112
- </xsl:variable>
113
-
114
- <!-- Every single unicode character that is recognized by OMML as a number -->
115
- <xsl:variable name="sNumbers" select="'0123456789'" />
116
-
117
- <!-- A string of '0's repeated exactly as many times as the list of numbers above -->
118
- <xsl:variable name="sZeros">
119
- <xsl:call-template name="SRepeatChar">
120
- <xsl:with-param name="cchRequired" select="string-length($sNumbers)" />
121
- <xsl:with-param name="ch" select="'0'" />
122
- </xsl:call-template>
123
- </xsl:variable>
124
-
125
- <!-- %%Template: SReplace
126
-
127
- Replace all occurences of sOrig in sInput with sReplacement
128
- and return the resulting string. -->
129
- <xsl:template name="SReplace">
130
- <xsl:param name="sInput" />
131
- <xsl:param name="sOrig" />
132
- <xsl:param name="sReplacement" />
133
-
134
- <xsl:choose>
135
- <xsl:when test="not(contains($sInput, $sOrig))">
136
- <xsl:value-of select="$sInput" />
137
- </xsl:when>
138
- <xsl:otherwise>
139
- <xsl:variable name="sBefore" select="substring-before($sInput, $sOrig)" />
140
- <xsl:variable name="sAfter" select="substring-after($sInput, $sOrig)" />
141
- <xsl:variable name="sAfterProcessed">
142
- <xsl:call-template name="SReplace">
143
- <xsl:with-param name="sInput" select="$sAfter" />
144
- <xsl:with-param name="sOrig" select="$sOrig" />
145
- <xsl:with-param name="sReplacement" select="$sReplacement" />
146
- </xsl:call-template>
147
- </xsl:variable>
148
-
149
- <xsl:value-of select="concat($sBefore, concat($sReplacement, $sAfterProcessed))" />
150
- </xsl:otherwise>
151
- </xsl:choose>
152
- </xsl:template>
153
-
154
- <!-- Templates -->
155
- <xsl:template match="/">
156
- <mml:math>
157
- <xsl:apply-templates select="*" />
158
- </mml:math>
159
- </xsl:template>
160
-
161
- <xsl:template match="m:borderBox">
162
-
163
- <!-- Get Lowercase versions of properties -->
164
- <xsl:variable name="sLowerCaseHideTop" select="translate(m:borderBoxPr[last()]/m:hideTop[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
165
- 'abcdefghijklmnopqrstuvwxyz')" />
166
- <xsl:variable name="sLowerCaseHideBot" select="translate(m:borderBoxPr[last()]/m:hideBot[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
167
- 'abcdefghijklmnopqrstuvwxyz')" />
168
- <xsl:variable name="sLowerCaseHideLeft" select="translate(m:borderBoxPr[last()]/m:hideLeft[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
169
- 'abcdefghijklmnopqrstuvwxyz')" />
170
- <xsl:variable name="sLowerCaseHideRight" select="translate(m:borderBoxPr[last()]/m:hideRight[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
171
- 'abcdefghijklmnopqrstuvwxyz')" />
172
- <xsl:variable name="sLowerCaseStrikeH" select="translate(m:borderBoxPr[last()]/m:strikeH[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
173
- 'abcdefghijklmnopqrstuvwxyz')" />
174
- <xsl:variable name="sLowerCaseStrikeV" select="translate(m:borderBoxPr[last()]/m:strikeV[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
175
- 'abcdefghijklmnopqrstuvwxyz')" />
176
- <xsl:variable name="sLowerCaseStrikeBLTR" select="translate(m:borderBoxPr[last()]/m:strikeBLTR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
177
- 'abcdefghijklmnopqrstuvwxyz')" />
178
- <xsl:variable name="sLowerCaseStrikeTLBR" select="translate(m:borderBoxPr[last()]/m:strikeTLBR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
179
- 'abcdefghijklmnopqrstuvwxyz')" />
180
- <xsl:variable name="fHideTop">
181
- <xsl:call-template name="ForceTrueStrVal">
182
- <xsl:with-param name="str" select="$sLowerCaseHideTop" />
183
- </xsl:call-template>
184
- </xsl:variable>
185
- <xsl:variable name="fHideBot">
186
- <xsl:call-template name="ForceTrueStrVal">
187
- <xsl:with-param name="str" select="$sLowerCaseHideBot" />
188
- </xsl:call-template>
189
- </xsl:variable>
190
- <xsl:variable name="fHideLeft">
191
- <xsl:call-template name="ForceTrueStrVal">
192
- <xsl:with-param name="str" select="$sLowerCaseHideLeft" />
193
- </xsl:call-template>
194
- </xsl:variable>
195
- <xsl:variable name="fHideRight">
196
- <xsl:call-template name="ForceTrueStrVal">
197
- <xsl:with-param name="str" select="$sLowerCaseHideRight" />
198
- </xsl:call-template>
199
- </xsl:variable>
200
- <xsl:variable name="fStrikeH">
201
- <xsl:call-template name="ForceTrueStrVal">
202
- <xsl:with-param name="str" select="$sLowerCaseStrikeH" />
203
- </xsl:call-template>
204
- </xsl:variable>
205
- <xsl:variable name="fStrikeV">
206
- <xsl:call-template name="ForceTrueStrVal">
207
- <xsl:with-param name="str" select="$sLowerCaseStrikeV" />
208
- </xsl:call-template>
209
- </xsl:variable>
210
- <xsl:variable name="fStrikeBLTR">
211
- <xsl:call-template name="ForceTrueStrVal">
212
- <xsl:with-param name="str" select="$sLowerCaseStrikeBLTR" />
213
- </xsl:call-template>
214
- </xsl:variable>
215
- <xsl:variable name="fStrikeTLBR">
216
- <xsl:call-template name="ForceTrueStrVal">
217
- <xsl:with-param name="str" select="$sLowerCaseStrikeTLBR" />
218
- </xsl:call-template>
219
- </xsl:variable>
220
-
221
- <xsl:choose>
222
- <xsl:when test="$fHideTop=1
223
- and $fHideBot=1
224
- and $fHideLeft=1
225
- and $fHideRight=1
226
- and $fStrikeH=0
227
- and $fStrikeV=0
228
- and $fStrikeBLTR=0
229
- and $fStrikeTLBR=0">
230
- <mml:mrow>
231
- <xsl:apply-templates select="m:e[1]" />
232
- </mml:mrow>
233
- </xsl:when>
234
- <xsl:otherwise>
235
- <mml:menclose>
236
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
237
- <xsl:with-param name="fHideTop" select="$fHideTop" />
238
- <xsl:with-param name="fHideBot" select="$fHideBot" />
239
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
240
- <xsl:with-param name="fHideRight" select="$fHideRight" />
241
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
242
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
243
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
244
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
245
- </xsl:call-template>
246
- <xsl:apply-templates select="m:e[1]" />
247
- </mml:menclose>
248
- </xsl:otherwise>
249
- </xsl:choose>
250
- </xsl:template>
251
-
252
- <xsl:template match="*">
253
- <xsl:apply-templates select="*" />
254
- </xsl:template>
255
-
256
- <!--
257
- { Non-combining, Upper-combining, Lower-combining }
258
- {U+02D8, U+0306, U+032E}, // BREVE
259
- {U+00B8, U+0312, U+0327}, // CEDILLA
260
- {U+0060, U+0300, U+0316}, // GRAVE ACCENT
261
- {U+002D, U+0305, U+0332}, // HYPHEN-MINUS/OVERLINE
262
- {U+2212, U+0305, U+0332}, // MINUS SIGN/OVERLINE
263
- {U+002E, U+0305, U+0323}, // FULL STOP/DOT ABOVE
264
- {U+02D9, U+0307, U+0323}, // DOT ABOVE
265
- {U+02DD, U+030B, U+02DD}, // DOUBLE ACUTE ACCENT
266
- {U+00B4, U+0301, U+0317}, // ACUTE ACCENT
267
- {U+007E, U+0303, U+0330}, // TILDE
268
- {U+02DC, U+0303, U+0330}, // SMALL TILDE
269
- {U+00A8, U+0308, U+0324}, // DIAERESIS
270
- {U+02C7, U+030C, U+032C}, // CARON
271
- {U+005E, U+0302, U+032D}, // CIRCUMFLEX ACCENT
272
- {U+00AF, U+0305, ::::::}, // MACRON
273
- {U+005F, ::::::, U+0332}, // LOW LINE
274
- {U+2192, U+20D7, U+20EF}, // RIGHTWARDS ARROW
275
- {U+27F6, U+20D7, U+20EF}, // LONG RIGHTWARDS ARROW
276
- {U+2190, U+20D6, U+20EE}, // LEFT ARROW
277
- -->
278
- <xsl:template name="ToNonCombining">
279
- <xsl:param name="ch" />
280
- <xsl:choose>
281
- <!-- BREVE -->
282
- <xsl:when test="$ch='&#x0306;' or $ch='&#x032e;'">&#x02D8;</xsl:when>
283
- <!-- CEDILLA -->
284
- <xsl:when test="$ch='&#x0312;' or $ch='&#x0327;'">&#x00B8;</xsl:when>
285
- <!-- GRAVE ACCENT -->
286
- <xsl:when test="$ch='&#x0300;' or $ch='&#x0316;'">&#x0060;</xsl:when>
287
- <!-- HYPHEN-MINUS/OVERLINE -->
288
- <xsl:when test="$ch='&#x0305;' or $ch='&#x0332;'">&#x002D;</xsl:when>
289
- <!-- MINUS SIGN/OVERLINE -->
290
- <xsl:when test="$ch='&#x0305;' or $ch='&#x0332;'">&#x2212;</xsl:when>
291
- <!-- FULL STOP/DOT ABOVE -->
292
- <xsl:when test="$ch='&#x0305;' or $ch='&#x0323;'">&#x002E;</xsl:when>
293
- <!-- DOT ABOVE -->
294
- <xsl:when test="$ch='&#x0307;' or $ch='&#x0323;'">&#x02D9;</xsl:when>
295
- <!-- DOUBLE ACUTE ACCENT -->
296
- <xsl:when test="$ch='&#x030B;' or $ch='&#x02DD;'">&#x02DD;</xsl:when>
297
- <!-- ACUTE ACCENT -->
298
- <xsl:when test="$ch='&#x0301;' or $ch='&#x0317;'">&#x00B4;</xsl:when>
299
- <!-- TILDE -->
300
- <xsl:when test="$ch='&#x0303;' or $ch='&#x0330;'">&#x007E;</xsl:when>
301
- <!-- SMALL TILDE -->
302
- <xsl:when test="$ch='&#x0303;' or $ch='&#x0330;'">&#x02DC;</xsl:when>
303
- <!-- DIAERESIS -->
304
- <xsl:when test="$ch='&#x0308;' or $ch='&#x0324;'">&#x00A8;</xsl:when>
305
- <!-- CARON -->
306
- <xsl:when test="$ch='&#x030C;' or $ch='&#x032C;'">&#x02C7;</xsl:when>
307
- <!-- CIRCUMFLEX ACCENT -->
308
- <xsl:when test="$ch='&#x0302;' or $ch='&#x032D;'">&#x005E;</xsl:when>
309
- <!-- MACRON -->
310
- <xsl:when test="$ch='&#x0305;' ">&#x00AF;</xsl:when>
311
- <!-- LOW LINE -->
312
- <xsl:when test=" $ch='&#x0332;'">&#x005F;</xsl:when>
313
- <!-- RIGHTWARDS ARROW -->
314
- <xsl:when test="$ch='&#x20D7;' or $ch='&#x20EF;'">&#x2192;</xsl:when>
315
- <!-- LONG RIGHTWARDS ARROW -->
316
- <xsl:when test="$ch='&#x20D7;' or $ch='&#x20EF;'">&#x27F6;</xsl:when>
317
- <!-- LEFT ARROW -->
318
- <xsl:when test="$ch='&#x20D6;' or $ch='&#x20EE;'">&#x2190;</xsl:when>
319
- <xsl:otherwise>
320
- <xsl:value-of select="$ch"/>
321
- </xsl:otherwise>
322
- </xsl:choose>
323
- </xsl:template>
324
-
325
- <xsl:template match="m:acc">
326
- <mml:mover>
327
- <xsl:attribute name="accent">true</xsl:attribute>
328
- <mml:mrow>
329
- <xsl:apply-templates select="m:e[1]" />
330
- </mml:mrow>
331
- <xsl:variable name="chAcc">
332
- <xsl:choose>
333
- <xsl:when test="not(m:accPr[last()]/m:chr)">
334
- <xsl:value-of select="'&#x0302;'" />
335
- </xsl:when>
336
- <xsl:otherwise>
337
- <xsl:value-of select="substring(m:accPr/m:chr/@m:val,1,1)" />
338
- </xsl:otherwise>
339
- </xsl:choose>
340
- </xsl:variable>
341
- <xsl:variable name="chNonComb">
342
- <xsl:call-template name="ToNonCombining">
343
- <xsl:with-param name="ch" select="$chAcc" />
344
- </xsl:call-template>
345
- </xsl:variable>
346
- <xsl:choose>
347
- <xsl:when test="string-length($chAcc)=0">
348
- <mml:mo/>
349
- </xsl:when>
350
- <xsl:otherwise>
351
- <xsl:call-template name="ParseMt">
352
- <xsl:with-param name="sToParse" select="$chNonComb" />
353
- <xsl:with-param name="scr" select="m:e[1]/*/m:rPr[last()]/m:scr/@m:val" />
354
- <xsl:with-param name="sty" select="m:e[1]/*/m:rPr[last()]/m:sty/@m:val" />
355
- <xsl:with-param name="nor">
356
- <xsl:choose>
357
- <xsl:when test="count(m:e[1]/*/m:rPr[last()]/m:nor) = 0">0</xsl:when>
358
- <xsl:otherwise>
359
- <xsl:call-template name="ForceFalseStrVal">
360
- <xsl:with-param name="str" select="translate(m:e[1]/*/m:rPr[last()]/m:nor/@m:val,
361
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
362
- 'abcdefghijklmnopqrstuvwxyz')" />
363
- </xsl:call-template>
364
- </xsl:otherwise>
365
- </xsl:choose>
366
- </xsl:with-param>
367
- </xsl:call-template>
368
- </xsl:otherwise>
369
- </xsl:choose>
370
- </mml:mover>
371
- </xsl:template>
372
-
373
- <xsl:template name="OutputScript">
374
- <xsl:param name="ndCur" select="." />
375
- <xsl:choose>
376
- <!-- Only output contents of $ndCur if $ndCur exists
377
- and $ndCur has children -->
378
- <xsl:when test="count($ndCur/*) &gt; 0">
379
- <mml:mrow>
380
- <xsl:apply-templates select="$ndCur" />
381
- </mml:mrow>
382
- </xsl:when>
383
- <xsl:otherwise>
384
- <mml:none />
385
- </xsl:otherwise>
386
- </xsl:choose>
387
- </xsl:template>
388
-
389
- <xsl:template match="m:sPre">
390
- <mml:mmultiscripts>
391
- <mml:mrow>
392
- <xsl:apply-templates select="m:e[1]" />
393
- </mml:mrow>
394
- <mml:mprescripts />
395
- <xsl:call-template name="OutputScript">
396
- <xsl:with-param name="ndCur" select="m:sub[1]"/>
397
- </xsl:call-template>
398
- <xsl:call-template name="OutputScript">
399
- <xsl:with-param name="ndCur" select="m:sup[1]" />
400
- </xsl:call-template>
401
- </mml:mmultiscripts>
402
- </xsl:template>
403
-
404
- <xsl:template match="m:m">
405
- <mml:mtable>
406
- <xsl:call-template name="CreateMathMLMatrixAttr">
407
- <xsl:with-param name="mcJc" select="m:mPr[last()]/m:mcs/m:mc/m:mcPr[last()]/m:mcJc/@m:val" />
408
- </xsl:call-template>
409
- <xsl:for-each select="m:mr">
410
- <mml:mtr>
411
- <xsl:for-each select="m:e">
412
- <mml:mtd>
413
- <xsl:apply-templates select="." />
414
- </mml:mtd>
415
- </xsl:for-each>
416
- </mml:mtr>
417
- </xsl:for-each>
418
- </mml:mtable>
419
- </xsl:template>
420
-
421
- <xsl:template name="CreateMathMLMatrixAttr">
422
- <xsl:param name="mcJc" />
423
- <xsl:variable name="sLowerCaseMcjc" select="translate($mcJc, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
424
- 'abcdefghijklmnopqrstuvwxyz')" />
425
- <xsl:choose>
426
- <xsl:when test="$sLowerCaseMcjc='left'">
427
- <xsl:attribute name="columnalign">left</xsl:attribute>
428
- </xsl:when>
429
- <xsl:when test="$sLowerCaseMcjc='right'">
430
- <xsl:attribute name="columnalign">right</xsl:attribute>
431
- </xsl:when>
432
- </xsl:choose>
433
- </xsl:template>
434
-
435
- <xsl:template match="m:phant">
436
- <xsl:variable name="sLowerCaseZeroWidVal" select="translate(m:phantPr[last()]/m:zeroWid[last()]/@m:val,
437
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
438
- 'abcdefghijklmnopqrstuvwxyz')" />
439
- <xsl:variable name="sLowerCaseZeroAscVal" select="translate(m:phantPr[last()]/m:zeroAsc[last()]/@m:val,
440
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
441
- 'abcdefghijklmnopqrstuvwxyz')" />
442
- <xsl:variable name="sLowerCaseZeroDescVal" select="translate(m:phantPr[last()]/m:zeroDesc[last()]/@m:val,
443
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
444
- 'abcdefghijklmnopqrstuvwxyz')" />
445
- <xsl:variable name="sLowerCaseShowVal" select="translate(m:phantPr[last()]/m:show[last()]/@m:val,
446
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
447
- 'abcdefghijklmnopqrstuvwxyz')" />
448
-
449
-
450
- <!-- The following properties default to 'yes' unless the last value equals 'no' or there isn't any node for
451
- the property -->
452
-
453
- <xsl:variable name="fZeroWid">
454
- <xsl:choose>
455
- <xsl:when test="count(m:phantPr[last()]/m:zeroWid[last()]) = 0">0</xsl:when>
456
- <xsl:otherwise>
457
- <xsl:call-template name="ForceFalseStrVal">
458
- <xsl:with-param name="str" select="$sLowerCaseZeroWidVal" />
459
- </xsl:call-template>
460
- </xsl:otherwise>
461
- </xsl:choose>
462
- </xsl:variable>
463
- <xsl:variable name="fZeroAsc">
464
- <xsl:choose>
465
- <xsl:when test="count(m:phantPr[last()]/m:zeroAsc[last()]) = 0">0</xsl:when>
466
- <xsl:otherwise>
467
- <xsl:call-template name="ForceFalseStrVal">
468
- <xsl:with-param name="str" select="$sLowerCaseZeroAscVal" />
469
- </xsl:call-template>
470
- </xsl:otherwise>
471
- </xsl:choose>
472
- </xsl:variable>
473
- <xsl:variable name="fZeroDesc">
474
- <xsl:choose>
475
- <xsl:when test="count(m:phantPr[last()]/m:zeroDesc[last()]) = 0">0</xsl:when>
476
- <xsl:otherwise>
477
- <xsl:call-template name="ForceFalseStrVal">
478
- <xsl:with-param name="str" select="$sLowerCaseZeroDescVal" />
479
- </xsl:call-template>
480
- </xsl:otherwise>
481
- </xsl:choose>
482
- </xsl:variable>
483
-
484
- <!-- The show property defaults to 'on' unless there exists a show property and its value is 'off' -->
485
-
486
- <xsl:variable name="fShow">
487
- <xsl:call-template name="ForceFalseStrVal">
488
- <xsl:with-param name="str" select="$sLowerCaseShowVal" />
489
- </xsl:call-template>
490
- </xsl:variable>
491
-
492
- <xsl:choose>
493
- <!-- Show the phantom contents, therefore, just use mpadded. -->
494
- <xsl:when test="$fShow = 1">
495
- <xsl:element name="mml:mpadded">
496
- <xsl:call-template name="CreateMpaddedAttributes">
497
- <xsl:with-param name="fZeroWid" select="$fZeroWid" />
498
- <xsl:with-param name="fZeroAsc" select="$fZeroAsc" />
499
- <xsl:with-param name="fZeroDesc" select="$fZeroDesc" />
500
- </xsl:call-template>
501
- <mml:mrow>
502
- <xsl:apply-templates select="m:e" />
503
- </mml:mrow>
504
- </xsl:element>
505
- </xsl:when>
506
- <!-- Don't show phantom contents, but don't smash anything, therefore, just
507
- use mphantom -->
508
- <xsl:when test="$fZeroWid=0 and $fZeroAsc=0 and $fZeroDesc=0">
509
- <xsl:element name="mml:mphantom">
510
- <mml:mrow>
511
- <xsl:apply-templates select="m:e" />
512
- </mml:mrow>
513
- </xsl:element>
514
- </xsl:when>
515
- <!-- Combination -->
516
- <xsl:otherwise>
517
- <xsl:element name="mml:mphantom">
518
- <xsl:element name="mml:mpadded">
519
- <xsl:call-template name="CreateMpaddedAttributes">
520
- <xsl:with-param name="fZeroWid" select="$fZeroWid" />
521
- <xsl:with-param name="fZeroAsc" select="$fZeroAsc" />
522
- <xsl:with-param name="fZeroDesc" select="$fZeroDesc" />
523
- </xsl:call-template>
524
- <mml:mrow>
525
- <xsl:apply-templates select="m:e" />
526
- </mml:mrow>
527
- </xsl:element>
528
- </xsl:element>
529
- </xsl:otherwise>
530
- </xsl:choose>
531
- </xsl:template>
532
-
533
- <xsl:template name="CreateMpaddedAttributes">
534
- <xsl:param name="fZeroWid" />
535
- <xsl:param name="fZeroAsc" />
536
- <xsl:param name="fZeroDesc" />
537
-
538
- <xsl:if test="$fZeroWid=1">
539
- <xsl:attribute name="width">0in</xsl:attribute>
540
- </xsl:if>
541
- <xsl:if test="$fZeroAsc=1">
542
- <xsl:attribute name="height">0in</xsl:attribute>
543
- </xsl:if>
544
- <xsl:if test="$fZeroDesc=1">
545
- <xsl:attribute name="depth">0in</xsl:attribute>
546
- </xsl:if>
547
- </xsl:template>
548
-
549
-
550
-
551
- <xsl:template match="m:rad">
552
- <xsl:variable name="fDegHide">
553
- <xsl:choose>
554
- <xsl:when test="count(m:radPr[last()]/m:degHide)=0">0</xsl:when>
555
- <xsl:otherwise>
556
- <xsl:call-template name="ForceFalseStrVal">
557
- <xsl:with-param name="str" select="translate(m:radPr[last()]/m:degHide/@m:val,
558
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
559
- 'abcdefghijklmnopqrstuvwxyz')" />
560
- </xsl:call-template>
561
- </xsl:otherwise>
562
- </xsl:choose>
563
- </xsl:variable>
564
- <xsl:choose>
565
- <xsl:when test="$fDegHide=1">
566
- <mml:msqrt>
567
- <xsl:apply-templates select="m:e[1]" />
568
- </mml:msqrt>
569
- </xsl:when>
570
- <xsl:otherwise>
571
- <mml:mroot>
572
- <mml:mrow>
573
- <xsl:apply-templates select="m:e[1]" />
574
- </mml:mrow>
575
- <mml:mrow>
576
- <xsl:apply-templates select="m:deg[1]" />
577
- </mml:mrow>
578
- </mml:mroot>
579
- </xsl:otherwise>
580
- </xsl:choose>
581
- </xsl:template>
582
-
583
- <xsl:template name="OutputNaryMo">
584
- <xsl:param name="ndCur" select="." />
585
- <xsl:param name="fGrow" select="0" />
586
- <mml:mo>
587
- <xsl:choose>
588
- <xsl:when test="$fGrow=1">
589
- <xsl:attribute name="stretchy">true</xsl:attribute>
590
- </xsl:when>
591
- <xsl:otherwise>
592
- <xsl:attribute name="stretchy">false</xsl:attribute>
593
- </xsl:otherwise>
594
- </xsl:choose>
595
- <xsl:choose>
596
- <xsl:when test="not($ndCur/m:naryPr[last()]/m:chr/@m:val) or
597
- $ndCur/m:naryPr[last()]/m:chr/@m:val=''">
598
- <xsl:text>&#x222b;</xsl:text>
599
- </xsl:when>
600
- <xsl:otherwise>
601
- <xsl:value-of select="$ndCur/m:naryPr[last()]/m:chr/@m:val" />
602
- </xsl:otherwise>
603
- </xsl:choose>
604
- </mml:mo>
605
- </xsl:template>
606
-
607
- <!-- %%Template match m:nary
608
- Process an n-ary.
609
-
610
- Decides, based on which arguments are supplied, between
611
- using an mo, msup, msub, or msubsup for the n-ary operator
612
- -->
613
- <xsl:template match="m:nary">
614
- <xsl:variable name="sLowerCaseSubHide">
615
- <xsl:choose>
616
- <xsl:when test="count(m:naryPr[last()]/m:subHide) = 0">
617
- <xsl:text>off</xsl:text>
618
- </xsl:when>
619
- <xsl:otherwise>
620
- <xsl:value-of select="translate(m:naryPr[last()]/m:subHide/@m:val,
621
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
622
- 'abcdefghijklmnopqrstuvwxyz')" />
623
- </xsl:otherwise>
624
- </xsl:choose>
625
- </xsl:variable>
626
-
627
- <xsl:variable name="sLowerCaseSupHide">
628
- <xsl:choose>
629
- <xsl:when test="count(m:naryPr[last()]/m:supHide) = 0">
630
- <xsl:text>off</xsl:text>
631
- </xsl:when>
632
- <xsl:otherwise>
633
- <xsl:value-of select="translate(m:naryPr[last()]/m:supHide/@m:val,
634
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
635
- 'abcdefghijklmnopqrstuvwxyz')" />
636
- </xsl:otherwise>
637
- </xsl:choose>
638
- </xsl:variable>
639
-
640
- <xsl:variable name="sLowerCaseLimLoc">
641
- <xsl:value-of select="translate(m:naryPr[last()]/m:limLoc/@m:val,
642
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
643
- 'abcdefghijklmnopqrstuvwxyz')" />
644
- </xsl:variable>
645
-
646
- <xsl:variable name="sLowerGrow">
647
- <xsl:choose>
648
- <xsl:when test="count(m:naryPr[last()]/m:grow)=0">off</xsl:when>
649
- <xsl:otherwise>
650
- <xsl:value-of select="translate(m:naryPr[last()]/m:grow/@m:val,
651
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
652
- 'abcdefghijklmnopqrstuvwxyz')" />
653
- </xsl:otherwise>
654
- </xsl:choose>
655
- </xsl:variable>
656
-
657
- <xsl:variable name="fLimLocSubSup">
658
- <xsl:choose>
659
- <xsl:when test="count(m:naryPr[last()]/m:limLoc)=0 or $sLowerCaseLimLoc='subsup'">1</xsl:when>
660
- <xsl:otherwise>0</xsl:otherwise>
661
- </xsl:choose>
662
- </xsl:variable>
663
-
664
- <xsl:variable name="fGrow">
665
- <xsl:call-template name="ForceFalseStrVal">
666
- <xsl:with-param name="str" select="$sLowerGrow" />
667
- </xsl:call-template>
668
- </xsl:variable>
669
-
670
- <xsl:variable name="fSupHide">
671
- <xsl:call-template name="ForceFalseStrVal">
672
- <xsl:with-param name="str" select="$sLowerCaseSupHide" />
673
- </xsl:call-template>
674
- </xsl:variable>
675
-
676
- <xsl:variable name="fSubHide">
677
- <xsl:call-template name="ForceFalseStrVal">
678
- <xsl:with-param name="str" select="$sLowerCaseSubHide" />
679
- </xsl:call-template>
680
- </xsl:variable>
681
-
682
- <mml:mrow>
683
- <xsl:choose>
684
- <xsl:when test="$fSupHide=1 and $fSubHide=1">
685
- <xsl:call-template name="OutputNaryMo">
686
- <xsl:with-param name="ndCur" select="." />
687
- <xsl:with-param name="fGrow" select="$fGrow" />
688
- </xsl:call-template>
689
- </xsl:when>
690
- <xsl:when test="$fSubHide=1">
691
- <xsl:choose>
692
- <xsl:when test="$fLimLocSubSup=1">
693
- <mml:msup>
694
- <xsl:call-template name="OutputNaryMo">
695
- <xsl:with-param name="ndCur" select="." />
696
- <xsl:with-param name="fGrow" select="$fGrow" />
697
- </xsl:call-template>
698
- <mml:mrow>
699
- <xsl:apply-templates select="m:sup[1]" />
700
- </mml:mrow>
701
- </mml:msup>
702
- </xsl:when>
703
- <xsl:otherwise>
704
- <mml:mover>
705
- <xsl:call-template name="OutputNaryMo">
706
- <xsl:with-param name="ndCur" select="." />
707
- <xsl:with-param name="fGrow" select="$fGrow" />
708
- </xsl:call-template>
709
- <mml:mrow>
710
- <xsl:apply-templates select="m:sup[1]" />
711
- </mml:mrow>
712
- </mml:mover>
713
- </xsl:otherwise>
714
- </xsl:choose>
715
- </xsl:when>
716
- <xsl:when test="$fSupHide=1">
717
- <xsl:choose>
718
- <xsl:when test="$fLimLocSubSup=1">
719
- <mml:msub>
720
- <xsl:call-template name="OutputNaryMo">
721
- <xsl:with-param name="ndCur" select="." />
722
- <xsl:with-param name="fGrow" select="$fGrow" />
723
- </xsl:call-template>
724
- <mml:mrow>
725
- <xsl:apply-templates select="m:sub[1]" />
726
- </mml:mrow>
727
- </mml:msub>
728
- </xsl:when>
729
- <xsl:otherwise>
730
- <mml:munder>
731
- <xsl:call-template name="OutputNaryMo">
732
- <xsl:with-param name="ndCur" select="." />
733
- <xsl:with-param name="fGrow" select="$fGrow" />
734
- </xsl:call-template>
735
- <mml:mrow>
736
- <xsl:apply-templates select="m:sub[1]" />
737
- </mml:mrow>
738
- </mml:munder>
739
- </xsl:otherwise>
740
- </xsl:choose>
741
- </xsl:when>
742
- <xsl:otherwise>
743
- <xsl:choose>
744
- <xsl:when test="$fLimLocSubSup=1">
745
- <mml:msubsup>
746
- <xsl:call-template name="OutputNaryMo">
747
- <xsl:with-param name="ndCur" select="." />
748
- <xsl:with-param name="fGrow" select="$fGrow" />
749
- </xsl:call-template>
750
- <mml:mrow>
751
- <xsl:apply-templates select="m:sub[1]" />
752
- </mml:mrow>
753
- <mml:mrow>
754
- <xsl:apply-templates select="m:sup[1]" />
755
- </mml:mrow>
756
- </mml:msubsup>
757
- </xsl:when>
758
- <xsl:otherwise>
759
- <mml:munderover>
760
- <xsl:call-template name="OutputNaryMo">
761
- <xsl:with-param name="ndCur" select="." />
762
- <xsl:with-param name="fGrow" select="$fGrow" />
763
- </xsl:call-template>
764
- <mml:mrow>
765
- <xsl:apply-templates select="m:sub[1]" />
766
- </mml:mrow>
767
- <mml:mrow>
768
- <xsl:apply-templates select="m:sup[1]" />
769
- </mml:mrow>
770
- </mml:munderover>
771
- </xsl:otherwise>
772
- </xsl:choose>
773
- </xsl:otherwise>
774
- </xsl:choose>
775
- <mml:mrow>
776
- <xsl:apply-templates select="m:e[1]" />
777
- </mml:mrow>
778
- </mml:mrow>
779
- </xsl:template>
780
-
781
- <xsl:template match="m:limLow">
782
- <mml:munder>
783
- <mml:mrow>
784
- <xsl:apply-templates select="m:e[1]" />
785
- </mml:mrow>
786
- <mml:mrow>
787
- <xsl:apply-templates select="m:lim[1]" />
788
- </mml:mrow>
789
- </mml:munder>
790
- </xsl:template>
791
-
792
- <xsl:template match="m:limUpp">
793
- <mml:mover>
794
- <mml:mrow>
795
- <xsl:apply-templates select="m:e[1]" />
796
- </mml:mrow>
797
- <mml:mrow>
798
- <xsl:apply-templates select="m:lim[1]" />
799
- </mml:mrow>
800
- </mml:mover>
801
- </xsl:template>
802
-
803
- <xsl:template match="m:sSub">
804
- <mml:msub>
805
- <mml:mrow>
806
- <xsl:apply-templates select="m:e[1]" />
807
- </mml:mrow>
808
- <mml:mrow>
809
- <xsl:apply-templates select="m:sub[1]" />
810
- </mml:mrow>
811
- </mml:msub>
812
- </xsl:template>
813
-
814
- <xsl:template match="m:sSup">
815
- <mml:msup>
816
- <mml:mrow>
817
- <xsl:apply-templates select="m:e[1]" />
818
- </mml:mrow>
819
- <mml:mrow>
820
- <xsl:apply-templates select="m:sup[1]" />
821
- </mml:mrow>
822
- </mml:msup>
823
- </xsl:template>
824
-
825
- <xsl:template match="m:sSubSup">
826
- <mml:msubsup>
827
- <mml:mrow>
828
- <xsl:apply-templates select="m:e[1]" />
829
- </mml:mrow>
830
- <mml:mrow>
831
- <xsl:apply-templates select="m:sub[1]" />
832
- </mml:mrow>
833
- <mml:mrow>
834
- <xsl:apply-templates select="m:sup[1]" />
835
- </mml:mrow>
836
- </mml:msubsup>
837
- </xsl:template>
838
-
839
- <xsl:template match="m:groupChr">
840
- <xsl:variable name="ndLastGroupChrPr" select="m:groupChrPr[last()]" />
841
- <xsl:variable name="sLowerCasePos" select="translate($ndLastGroupChrPr/m:pos/@m:val,
842
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
843
- 'abcdefghijklmnopqrstuvwxyz')" />
844
-
845
- <xsl:variable name="sLowerCaseVertJc" select="translate($ndLastGroupChrPr/m:vertJc/@m:val,
846
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
847
- 'abcdefghijklmnopqrstuvwxyz')" />
848
- <xsl:variable name="ndLastChr" select="$ndLastGroupChrPr/m:chr" />
849
-
850
- <xsl:variable name="chr">
851
- <xsl:choose>
852
- <xsl:when test="$ndLastChr and (not($ndLastChr/@m:val) or string-length($ndLastChr/@m:val) = 0)"></xsl:when>
853
- <xsl:when test="string-length($ndLastChr/@m:val) &gt;= 1">
854
- <xsl:value-of select="substring($ndLastChr/@m:val,1,1)" />
855
- </xsl:when>
856
- <xsl:otherwise>
857
- <xsl:text>&#x023DF;</xsl:text>
858
- </xsl:otherwise>
859
- </xsl:choose>
860
- </xsl:variable>
861
- <xsl:choose>
862
- <xsl:when test="$sLowerCasePos = 'top'">
863
- <xsl:choose>
864
- <xsl:when test="$sLowerCaseVertJc = 'bot'">
865
- <mml:mover accent="false">
866
- <mml:mrow>
867
- <xsl:apply-templates select="m:e[1]" />
868
- </mml:mrow>
869
- <mml:mo>
870
- <xsl:value-of select="$chr" />
871
- </mml:mo>
872
- </mml:mover>
873
- </xsl:when>
874
- <xsl:otherwise>
875
- <mml:munder accentunder="false">
876
- <mml:mo>
877
- <xsl:value-of select="$chr" />
878
- </mml:mo>
879
- <mml:mrow>
880
- <xsl:apply-templates select="m:e[1]" />
881
- </mml:mrow>
882
- </mml:munder>
883
- </xsl:otherwise>
884
- </xsl:choose>
885
- </xsl:when>
886
- <xsl:otherwise>
887
- <xsl:choose>
888
- <xsl:when test="$sLowerCaseVertJc = 'bot'">
889
- <mml:mover accent="false">
890
- <mml:mo>
891
- <xsl:value-of select="$chr" />
892
- </mml:mo>
893
- <mml:mrow>
894
- <xsl:apply-templates select="m:e[1]" />
895
- </mml:mrow>
896
- </mml:mover>
897
- </xsl:when>
898
- <xsl:otherwise>
899
- <mml:munder accentunder="false">
900
- <mml:mrow>
901
- <xsl:apply-templates select="m:e[1]" />
902
- </mml:mrow>
903
- <mml:mo>
904
- <xsl:value-of select="$chr" />
905
- </mml:mo>
906
- </mml:munder>
907
- </xsl:otherwise>
908
- </xsl:choose>
909
- </xsl:otherwise>
910
- </xsl:choose>
911
- </xsl:template>
912
-
913
- <xsl:template name="fName">
914
- <xsl:for-each select="m:fName/*">
915
- <xsl:apply-templates select="." />
916
- </xsl:for-each>
917
- </xsl:template>
918
-
919
- <xsl:template match="m:func">
920
- <mml:mrow>
921
- <mml:mrow>
922
- <xsl:call-template name="fName" />
923
- </mml:mrow>
924
- <mml:mo>&#x02061;</mml:mo>
925
- <mml:mrow>
926
- <xsl:apply-templates select="m:e" />
927
- </mml:mrow>
928
- </mml:mrow>
929
- </xsl:template>
930
-
931
- <!-- %%Template: match m:f
932
-
933
- m:f maps directly to mfrac.
934
- -->
935
- <xsl:template match="m:f">
936
- <xsl:variable name="sLowerCaseType" select="translate(m:fPr[last()]/m:type/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
937
- <xsl:choose>
938
- <xsl:when test="$sLowerCaseType='lin'">
939
- <mml:mrow>
940
- <mml:mrow>
941
- <xsl:apply-templates select="m:num[1]" />
942
- </mml:mrow>
943
- <mml:mo>/</mml:mo>
944
- <mml:mrow>
945
- <xsl:apply-templates select="m:den[1]" />
946
- </mml:mrow>
947
- </mml:mrow>
948
- </xsl:when>
949
- <xsl:otherwise>
950
- <mml:mfrac>
951
- <xsl:call-template name="CreateMathMLFracProp">
952
- <xsl:with-param name="type" select="$sLowerCaseType" />
953
- </xsl:call-template>
954
- <mml:mrow>
955
- <xsl:apply-templates select="m:num[1]" />
956
- </mml:mrow>
957
- <mml:mrow>
958
- <xsl:apply-templates select="m:den[1]" />
959
- </mml:mrow>
960
- </mml:mfrac>
961
- </xsl:otherwise>
962
- </xsl:choose>
963
-
964
- </xsl:template>
965
-
966
-
967
- <!-- %%Template: CreateMathMLFracProp
968
-
969
- Make fraction properties based on supplied parameters.
970
- OMML differentiates between a linear fraction and a skewed
971
- one. For MathML, we write both as bevelled.
972
- -->
973
- <xsl:template name="CreateMathMLFracProp">
974
- <xsl:param name="type" />
975
- <xsl:variable name="sLowerCaseType" select="translate($type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
976
-
977
- <xsl:if test="$sLowerCaseType='skw' or $sLowerCaseType='lin'">
978
- <xsl:attribute name="bevelled">true</xsl:attribute>
979
- </xsl:if>
980
- <xsl:if test="$sLowerCaseType='nobar'">
981
- <xsl:attribute name="linethickness">0pt</xsl:attribute>
982
- </xsl:if>
983
- <xsl:choose>
984
- <xsl:when test="sLowerCaseNumJc='right'">
985
- <xsl:attribute name="numalign">right</xsl:attribute>
986
- </xsl:when>
987
- <xsl:when test="sLowerCaseNumJc='left'">
988
- <xsl:attribute name="numalign">left</xsl:attribute>
989
- </xsl:when>
990
- </xsl:choose>
991
- <xsl:choose>
992
- <xsl:when test="sLowerCaseDenJc='right'">
993
- <xsl:attribute name="numalign">right</xsl:attribute>
994
- </xsl:when>
995
- <xsl:when test="sLowerCaseDenJc='left'">
996
- <xsl:attribute name="numalign">left</xsl:attribute>
997
- </xsl:when>
998
- </xsl:choose>
999
- </xsl:template>
1000
-
1001
- <!-- %%Template: match m:e | m:den | m:num | m:lim | m:sup | m:sub
1002
-
1003
- These element delinate parts of an expression (like the numerator). -->
1004
- <xsl:template match="m:e | m:den | m:num | m:lim | m:sup | m:sub">
1005
- <xsl:choose>
1006
-
1007
- <!-- If there is no scriptLevel specified, just call through -->
1008
- <xsl:when test="not(m:argPr[last()]/m:scrLvl/@m:val)">
1009
- <xsl:apply-templates select="*" />
1010
- </xsl:when>
1011
-
1012
- <!-- Otherwise, create an mstyle and set the script level -->
1013
- <xsl:otherwise>
1014
- <mml:mstyle>
1015
- <xsl:attribute name="scriptlevel">
1016
- <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val" />
1017
- </xsl:attribute>
1018
- <xsl:apply-templates select="*" />
1019
- </mml:mstyle>
1020
- </xsl:otherwise>
1021
- </xsl:choose>
1022
- </xsl:template>
1023
-
1024
- <xsl:template match="m:bar">
1025
- <xsl:variable name="sLowerCasePos" select="translate(m:barPr/m:pos/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1026
- 'abcdefghijklmnopqrstuvwxyz')" />
1027
-
1028
- <xsl:variable name="fTop">
1029
-
1030
- <xsl:choose>
1031
- <xsl:when test="$sLowerCasePos='top'">1</xsl:when>
1032
- <xsl:otherwise>0</xsl:otherwise>
1033
- </xsl:choose>
1034
- </xsl:variable>
1035
- <xsl:choose>
1036
- <xsl:when test="$fTop=1">
1037
- <mml:mover accent="false">
1038
- <mml:mrow>
1039
- <xsl:apply-templates select="m:e[1]" />
1040
- </mml:mrow>
1041
- <mml:mo>
1042
- <xsl:text>&#x00AF;</xsl:text>
1043
- </mml:mo>
1044
- </mml:mover>
1045
- </xsl:when>
1046
- <xsl:otherwise>
1047
- <mml:munder underaccent="false">
1048
- <mml:mrow>
1049
- <xsl:apply-templates select="m:e[1]" />
1050
- </mml:mrow>
1051
- <mml:mo>
1052
- <xsl:text>&#x005F;</xsl:text>
1053
- </mml:mo>
1054
- </mml:munder>
1055
- </xsl:otherwise>
1056
- </xsl:choose>
1057
- </xsl:template>
1058
-
1059
- <!-- %%Template match m:d
1060
-
1061
- Process a delimiter.
1062
- -->
1063
- <xsl:template match="m:d">
1064
- <mml:mfenced>
1065
- <!-- open: default is '(' for both OMML and MathML -->
1066
- <xsl:if test="m:dPr[1]/m:begChr/@m:val and not(m:dPr[1]/m:begChr/@m:val ='(')">
1067
- <xsl:attribute name="open">
1068
- <xsl:value-of select="m:dPr[1]/m:begChr/@m:val" />
1069
- </xsl:attribute>
1070
- </xsl:if>
1071
-
1072
- <!-- close: default is ')' for both OMML and MathML -->
1073
- <xsl:if test="m:dPr[1]/m:endChr/@m:val and not(m:dPr[1]/m:endChr/@m:val =')')">
1074
- <xsl:attribute name="close">
1075
- <xsl:value-of select="m:dPr[1]/m:endChr/@m:val" />
1076
- </xsl:attribute>
1077
- </xsl:if>
1078
-
1079
- <!-- separator: the default is ',' for MathML, and '|' for OMML -->
1080
- <xsl:choose>
1081
- <!-- Matches MathML default. Write nothing -->
1082
- <xsl:when test="m:dPr[1]/m:sepChr/@m:val = ','" />
1083
-
1084
- <!-- OMML default: | -->
1085
- <xsl:when test="not(m:dPr[1]/m:sepChr/@m:val)">
1086
- <xsl:attribute name="separators">
1087
- <xsl:value-of select="'|'" />
1088
- </xsl:attribute>
1089
- </xsl:when>
1090
-
1091
- <xsl:otherwise>
1092
- <xsl:attribute name="separators">
1093
- <xsl:value-of select="m:dPr[1]/m:sepChr/@m:val" />
1094
- </xsl:attribute>
1095
- </xsl:otherwise>
1096
- </xsl:choose>
1097
-
1098
- <!-- now write all the children. Put each one into an mrow
1099
- just in case it produces multiple runs, etc -->
1100
- <xsl:for-each select="m:e">
1101
- <mml:mrow>
1102
- <xsl:apply-templates select="." />
1103
- </mml:mrow>
1104
- </xsl:for-each>
1105
- </mml:mfenced>
1106
- </xsl:template>
1107
-
1108
- <xsl:template match="m:r">
1109
- <xsl:variable name="fNor">
1110
- <xsl:choose>
1111
- <xsl:when test="count(child::m:rPr[last()]/m:nor) = 0">0</xsl:when>
1112
- <xsl:otherwise>
1113
- <xsl:call-template name="ForceFalseStrVal">
1114
- <xsl:with-param name="str" select="translate(child::m:rPr[last()]/m:nor/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1115
- 'abcdefghijklmnopqrstuvwxyz')" />
1116
- </xsl:call-template>
1117
- </xsl:otherwise>
1118
- </xsl:choose>
1119
- </xsl:variable>
1120
-
1121
- <xsl:choose>
1122
- <xsl:when test="$fNor=1">
1123
- <mml:mtext>
1124
- <xsl:variable name="sOutput" select="translate(.//m:t, ' ', '&#xa0;')" />
1125
- <xsl:value-of select="$sOutput" />
1126
- </mml:mtext>
1127
- </xsl:when>
1128
- <xsl:otherwise>
1129
- <xsl:for-each select=".//m:t">
1130
- <xsl:call-template name="ParseMt">
1131
- <xsl:with-param name="sToParse" select="text()" />
1132
- <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val" />
1133
- <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val" />
1134
- <xsl:with-param name="nor">0</xsl:with-param>
1135
- </xsl:call-template>
1136
- </xsl:for-each>
1137
- </xsl:otherwise>
1138
- </xsl:choose>
1139
- </xsl:template>
1140
-
1141
-
1142
- <xsl:template name="CreateTokenAttributes">
1143
- <xsl:param name="scr" />
1144
- <xsl:param name="sty" />
1145
- <xsl:param name="nor" />
1146
- <xsl:param name="nCharToPrint" />
1147
- <xsl:param name="sTokenType" />
1148
-
1149
- <xsl:choose>
1150
- <xsl:when test="$nor=1">
1151
- <xsl:attribute name="mathvariant">normal</xsl:attribute>
1152
- </xsl:when>
1153
- <xsl:otherwise>
1154
- <xsl:variable name="mathvariant">
1155
- <xsl:choose>
1156
- <!-- numbers don't care -->
1157
- <xsl:when test="$sTokenType='mn'" />
1158
-
1159
- <xsl:when test="$scr='monospace'">monospace</xsl:when>
1160
- <xsl:when test="$scr='sans-serif' and $sty='i'">sans-serif-italic</xsl:when>
1161
- <xsl:when test="$scr='sans-serif' and $sty='b'">bold-sans-serif</xsl:when>
1162
- <xsl:when test="$scr='sans-serif' and $sty='bi'">sans-serif-bold-italic</xsl:when>
1163
- <xsl:when test="$scr='sans-serif'">sans-serif</xsl:when>
1164
- <xsl:when test="$scr='fraktur' and ($sty='b' or $sty='bi')">bold-fraktur</xsl:when>
1165
- <xsl:when test="$scr='fraktur'">fraktur</xsl:when>
1166
- <xsl:when test="$scr='double-struck'">double-struck</xsl:when>
1167
- <xsl:when test="$scr='script' and ($sty='b' or $sty='bi')">bold-script</xsl:when>
1168
- <xsl:when test="$scr='script'">script</xsl:when>
1169
- <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='b'">bold</xsl:when>
1170
- <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='i'">italic</xsl:when>
1171
- <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='p'">normal</xsl:when>
1172
- <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='bi'">bold-italic</xsl:when>
1173
- <xsl:otherwise />
1174
- </xsl:choose>
1175
- </xsl:variable>
1176
- <xsl:variable name="fontweight">
1177
- <xsl:choose>
1178
- <xsl:when test="$sty='b' or $sty='bi'">bold</xsl:when>
1179
- <xsl:otherwise>normal</xsl:otherwise>
1180
- </xsl:choose>
1181
- </xsl:variable>
1182
- <xsl:variable name="fontstyle">
1183
- <xsl:choose>
1184
- <xsl:when test="$sty='p' or $sty='b'">normal</xsl:when>
1185
- <xsl:otherwise>italic</xsl:otherwise>
1186
- </xsl:choose>
1187
- </xsl:variable>
1188
-
1189
- <!-- Writing of attributes begins here -->
1190
- <xsl:choose>
1191
- <!-- Don't write mathvariant for operators unless they want to be normal -->
1192
- <xsl:when test="$sTokenType='mo' and $mathvariant!='normal'" />
1193
-
1194
- <!-- A single character within an mi is already italics, don't write -->
1195
- <xsl:when test="$sTokenType='mi' and $nCharToPrint=1 and ($mathvariant='' or $mathvariant='italic')" />
1196
-
1197
- <xsl:when test="$sTokenType='mi' and $nCharToPrint &gt; 1 and ($mathvariant='' or $mathvariant='italic')">
1198
- <xsl:attribute name="mathvariant">
1199
- <xsl:value-of select="'italic'" />
1200
- </xsl:attribute>
1201
- </xsl:when>
1202
- <xsl:when test="$mathvariant!='italic' and $mathvariant!=''">
1203
- <xsl:attribute name="mathvariant">
1204
- <xsl:value-of select="$mathvariant" />
1205
- </xsl:attribute>
1206
- </xsl:when>
1207
- <xsl:otherwise>
1208
- <xsl:if test="not($sTokenType='mi' and $nCharToPrint=1) and $fontstyle='italic'">
1209
- <xsl:attribute name="fontstyle">italic</xsl:attribute>
1210
- </xsl:if>
1211
- <xsl:if test="$fontweight='bold'">
1212
- <xsl:attribute name="fontweight">bold</xsl:attribute>
1213
- </xsl:if>
1214
- </xsl:otherwise>
1215
- </xsl:choose>
1216
- </xsl:otherwise>
1217
- </xsl:choose>
1218
- </xsl:template>
1219
-
1220
- <xsl:template match="m:eqArr">
1221
- <mml:mtable>
1222
- <xsl:for-each select="m:e">
1223
- <mml:mtr>
1224
- <mml:mtd>
1225
- <xsl:choose>
1226
- <xsl:when test="m:argPr[last()]/m:scrLvl/@m:val!='0' or
1227
- not(m:argPr[last()]/m:scrLvl/@m:val) or
1228
- m:argPr[last()]/m:scrLvl/@m:val=''">
1229
- <mml:mrow>
1230
- <mml:maligngroup />
1231
- <xsl:call-template name="CreateEqArrRow">
1232
- <xsl:with-param name="align" select="1" />
1233
- <xsl:with-param name="ndCur" select="*[1]" />
1234
- </xsl:call-template>
1235
- </mml:mrow>
1236
- </xsl:when>
1237
- <xsl:otherwise>
1238
- <mml:mstyle>
1239
- <xsl:attribute name="scriptlevel">
1240
- <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val" />
1241
- </xsl:attribute>
1242
- <mml:maligngroup />
1243
- <xsl:call-template name="CreateEqArrRow">
1244
- <xsl:with-param name="align" select="1" />
1245
- <xsl:with-param name="ndCur" select="*[1]" />
1246
- </xsl:call-template>
1247
- </mml:mstyle>
1248
- </xsl:otherwise>
1249
- </xsl:choose>
1250
- </mml:mtd>
1251
- </mml:mtr>
1252
- </xsl:for-each>
1253
- </mml:mtable>
1254
- </xsl:template>
1255
-
1256
- <xsl:template name="CreateEqArrRow">
1257
- <xsl:param name="align" />
1258
- <xsl:param name="ndCur" />
1259
- <xsl:variable name="sAllMt">
1260
- <xsl:for-each select="$ndCur/m:t">
1261
- <xsl:value-of select="." />
1262
- </xsl:for-each>
1263
- </xsl:variable>
1264
- <xsl:choose>
1265
- <xsl:when test="$ndCur/self::m:r">
1266
- <xsl:call-template name="ParseEqArrMr">
1267
- <xsl:with-param name="sToParse" select="$sAllMt" />
1268
- <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val" />
1269
- <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val" />
1270
- <xsl:with-param name="nor">
1271
- <xsl:choose>
1272
- <xsl:when test="count($ndCur/m:rPr[last()]/m:nor) = 0">0</xsl:when>
1273
- <xsl:otherwise>
1274
- <xsl:call-template name="ForceFalseStrVal">
1275
- <xsl:with-param name="str" select="translate($ndCur/m:rPr[last()]/m:nor/@m:val,
1276
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1277
- 'abcdefghijklmnopqrstuvwxyz')" />
1278
- </xsl:call-template>
1279
- </xsl:otherwise>
1280
- </xsl:choose>
1281
- </xsl:with-param>
1282
- <xsl:with-param name="align" select="$align" />
1283
- </xsl:call-template>
1284
- </xsl:when>
1285
- <xsl:otherwise>
1286
- <xsl:apply-templates select="$ndCur" />
1287
- </xsl:otherwise>
1288
- </xsl:choose>
1289
- <xsl:if test="count($ndCur/following-sibling::*) &gt; 0">
1290
- <xsl:variable name="cAmp">
1291
- <xsl:call-template name="CountAmp">
1292
- <xsl:with-param name="sAllMt" select="$sAllMt" />
1293
- <xsl:with-param name="cAmp" select="0" />
1294
- </xsl:call-template>
1295
- </xsl:variable>
1296
- <xsl:call-template name="CreateEqArrRow">
1297
- <xsl:with-param name="align" select="($align+($cAmp mod 2)) mod 2" />
1298
- <xsl:with-param name="ndCur" select="$ndCur/following-sibling::*[1]" />
1299
- </xsl:call-template>
1300
- </xsl:if>
1301
- </xsl:template>
1302
-
1303
- <xsl:template name="CountAmp">
1304
- <xsl:param name="sAllMt" />
1305
- <xsl:param name="cAmp" />
1306
- <xsl:choose>
1307
- <xsl:when test="string-length(substring-after($sAllMt, '&amp;')) &gt; 0 or
1308
- substring($sAllMt, string-length($sAllMt))='&#x0026;'">
1309
- <xsl:call-template name="CountAmp">
1310
- <xsl:with-param name="sAllMt" select="substring-after($sAllMt, '&#x0026;')" />
1311
- <xsl:with-param name="cAmp" select="$cAmp+1" />
1312
- </xsl:call-template>
1313
- </xsl:when>
1314
- <xsl:otherwise>
1315
- <xsl:value-of select="$cAmp" />
1316
- </xsl:otherwise>
1317
- </xsl:choose>
1318
- </xsl:template>
1319
-
1320
- <!-- %%Template: ParseEqArrMr
1321
-
1322
- Similar to ParseMt, but this one has to do more for an equation array.
1323
- In equation arrays &amp; is a special character which denotes alignment.
1324
-
1325
- The &amp; in an equation works by alternating between meaning insert alignment spacing
1326
- and insert alignment mark. For each equation in the equation array
1327
- there is an implied align space at the beginning of the equation. Within each equation,
1328
- the first &amp; means alignmark, the second, align space, the third, alignmark, etc.
1329
-
1330
- For this reason when parsing m:r's in equation arrays it is important to keep track of what
1331
- the next ampersand will mean.
1332
-
1333
- $align=0 => Omml's align space, which is similar to MathML's maligngroup.
1334
- $align=1 => Omml's alignment mark, which is similar to MathML's malignmark.
1335
- -->
1336
- <xsl:template name="ParseEqArrMr">
1337
- <xsl:param name="sToParse" />
1338
- <xsl:param name="sty" />
1339
- <xsl:param name="scr" />
1340
- <xsl:param name="nor" />
1341
- <xsl:param name="align" />
1342
-
1343
- <xsl:if test="string-length($sToParse) &gt; 0">
1344
- <xsl:choose>
1345
- <xsl:when test="substring($sToParse,1,1) = '&amp;'">
1346
- <xsl:choose>
1347
- <xsl:when test="$align='0'">
1348
- <mml:maligngroup />
1349
- </xsl:when>
1350
- <xsl:when test="$align='1'">
1351
- <mml:malignmark />
1352
- </xsl:when>
1353
- </xsl:choose>
1354
- <xsl:call-template name="ParseEqArrMr">
1355
- <xsl:with-param name="sToParse" select="substring($sToParse,2)" />
1356
- <xsl:with-param name="scr" select="$scr" />
1357
- <xsl:with-param name="sty" select="$sty" />
1358
- <xsl:with-param name="nor" select="$nor" />
1359
- <xsl:with-param name="align">
1360
- <xsl:choose>
1361
- <xsl:when test="$align='1'">0</xsl:when>
1362
- <xsl:otherwise>1</xsl:otherwise>
1363
- </xsl:choose>
1364
- </xsl:with-param>
1365
- </xsl:call-template>
1366
- </xsl:when>
1367
- <xsl:otherwise>
1368
- <xsl:variable name="sRepNumWith0">
1369
- <xsl:call-template name="SReplaceNumWithZero">
1370
- <xsl:with-param name="sToParse" select="$sToParse" />
1371
- </xsl:call-template>
1372
- </xsl:variable>
1373
- <xsl:variable name="sRepOperWith-">
1374
- <xsl:call-template name="SReplaceOperWithMinus">
1375
- <xsl:with-param name="sToParse" select="$sRepNumWith0" />
1376
- </xsl:call-template>
1377
- </xsl:variable>
1378
-
1379
- <xsl:variable name="iFirstOper" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))" />
1380
- <xsl:variable name="iFirstNum" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))" />
1381
- <xsl:variable name="iFirstAmp" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '&#x0026;'))" />
1382
- <xsl:variable name="fNumAtPos1">
1383
- <xsl:choose>
1384
- <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1385
- <xsl:otherwise>0</xsl:otherwise>
1386
- </xsl:choose>
1387
- </xsl:variable>
1388
- <xsl:variable name="fOperAtPos1">
1389
- <xsl:choose>
1390
- <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1391
- <xsl:otherwise>0</xsl:otherwise>
1392
- </xsl:choose>
1393
- </xsl:variable>
1394
- <xsl:choose>
1395
-
1396
- <!-- Case I: The string begins with neither a number, nor an operator -->
1397
- <xsl:when test="$fNumAtPos1='0' and $fOperAtPos1='0'">
1398
- <xsl:choose>
1399
- <xsl:when test="$nor = 0">
1400
- <mml:mi>
1401
- <xsl:call-template name="CreateTokenAttributes">
1402
- <xsl:with-param name="scr" select="$scr" />
1403
- <xsl:with-param name="sty" select="$sty" />
1404
- <xsl:with-param name="nor" select="$nor" />
1405
- <xsl:with-param name="nCharToPrint" select="1" />
1406
- <xsl:with-param name="sTokenType" select="'mi'" />
1407
- </xsl:call-template>
1408
- <xsl:variable name="sOutput" select="translate(substring($sToParse, 1, 1), ' ', '&#xa0;')" />
1409
- <xsl:value-of select="$sOutput" />
1410
- </mml:mi>
1411
- </xsl:when>
1412
- <xsl:otherwise>
1413
- <mml:mtext>
1414
- <xsl:variable name="sOutput" select="translate(substring($sToParse, 1, 1), ' ', '&#xa0;')" />
1415
- <xsl:value-of select="$sOutput" />
1416
- </mml:mtext>
1417
- </xsl:otherwise>
1418
- </xsl:choose>
1419
- <xsl:call-template name="ParseEqArrMr">
1420
- <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1421
- <xsl:with-param name="scr" select="$scr" />
1422
- <xsl:with-param name="sty" select="$sty" />
1423
- <xsl:with-param name="nor" select="$nor" />
1424
- <xsl:with-param name="align" select="$align" />
1425
- </xsl:call-template>
1426
- </xsl:when>
1427
-
1428
- <!-- Case II: There is an operator at position 1 -->
1429
- <xsl:when test="$fOperAtPos1='1'">
1430
- <xsl:choose>
1431
- <xsl:when test="$nor = 0">
1432
- <mml:mo>
1433
- <xsl:call-template name="CreateTokenAttributes">
1434
- <xsl:with-param name="scr" />
1435
- <xsl:with-param name="sty" />
1436
- <xsl:with-param name="nor" select="$nor" />
1437
- <xsl:with-param name="sTokenType" select="'mo'" />
1438
- </xsl:call-template>
1439
- <xsl:value-of select="substring($sToParse,1,1)" />
1440
- </mml:mo>
1441
- </xsl:when>
1442
- <xsl:otherwise>
1443
- <mml:mtext>
1444
- <xsl:value-of select="substring($sToParse,1,1)" />
1445
- </mml:mtext>
1446
- </xsl:otherwise>
1447
- </xsl:choose>
1448
- <xsl:call-template name="ParseEqArrMr">
1449
- <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1450
- <xsl:with-param name="scr" select="$scr" />
1451
- <xsl:with-param name="sty" select="$sty" />
1452
- <xsl:with-param name="nor" select="$nor" />
1453
- <xsl:with-param name="align" select="$align" />
1454
- </xsl:call-template>
1455
- </xsl:when>
1456
-
1457
- <!-- Case III: There is a number at position 1 -->
1458
- <xsl:otherwise>
1459
- <xsl:variable name="sConsecNum">
1460
- <xsl:call-template name="SNumStart">
1461
- <xsl:with-param name="sToParse" select="$sToParse" />
1462
- <xsl:with-param name="sPattern" select="$sRepNumWith0" />
1463
- </xsl:call-template>
1464
- </xsl:variable>
1465
- <xsl:choose>
1466
- <xsl:when test="$nor = 0">
1467
- <mml:mn>
1468
- <xsl:call-template name="CreateTokenAttributes">
1469
- <xsl:with-param name="scr" />
1470
- <xsl:with-param name="sty" select="'p'"/>
1471
- <xsl:with-param name="nor" select="$nor" />
1472
- <xsl:with-param name="sTokenType" select="'mn'" />
1473
- </xsl:call-template>
1474
- <xsl:value-of select="$sConsecNum" />
1475
- </mml:mn>
1476
- </xsl:when>
1477
- <xsl:otherwise>
1478
- <mml:mtext>
1479
- <xsl:value-of select="$sConsecNum" />
1480
- </mml:mtext>
1481
- </xsl:otherwise>
1482
- </xsl:choose>
1483
- <xsl:call-template name="ParseEqArrMr">
1484
- <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)" />
1485
- <xsl:with-param name="scr" select="$scr" />
1486
- <xsl:with-param name="sty" select="$sty" />
1487
- <xsl:with-param name="nor" select="$nor" />
1488
- <xsl:with-param name="align" select="$align" />
1489
- </xsl:call-template>
1490
- </xsl:otherwise>
1491
- </xsl:choose>
1492
- </xsl:otherwise>
1493
- </xsl:choose>
1494
- </xsl:if>
1495
- </xsl:template>
1496
-
1497
- <!-- %%Template: ParseMt
1498
-
1499
- Produce a run of text. Technically, OMML makes no distinction
1500
- between numbers, operators, and other characters in a run. For
1501
- MathML we need to break these into mi, mn, or mo elements.
1502
-
1503
- See also ParseEqArrMr
1504
- -->
1505
- <xsl:template name="ParseMt">
1506
- <xsl:param name="sToParse" />
1507
- <xsl:param name="sty" />
1508
- <xsl:param name="scr" />
1509
- <xsl:param name="nor" />
1510
- <xsl:if test="string-length($sToParse) &gt; 0">
1511
- <xsl:variable name="sRepNumWith0">
1512
- <xsl:call-template name="SReplaceNumWithZero">
1513
- <xsl:with-param name="sToParse" select="$sToParse" />
1514
- </xsl:call-template>
1515
- </xsl:variable>
1516
- <xsl:variable name="sRepOperWith-">
1517
- <xsl:call-template name="SReplaceOperWithMinus">
1518
- <xsl:with-param name="sToParse" select="$sRepNumWith0" />
1519
- </xsl:call-template>
1520
- </xsl:variable>
1521
-
1522
- <xsl:variable name="iFirstOper" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))" />
1523
- <xsl:variable name="iFirstNum" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))" />
1524
- <xsl:variable name="fNumAtPos1">
1525
- <xsl:choose>
1526
- <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1527
- <xsl:otherwise>0</xsl:otherwise>
1528
- </xsl:choose>
1529
- </xsl:variable>
1530
- <xsl:variable name="fOperAtPos1">
1531
- <xsl:choose>
1532
- <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1533
- <xsl:otherwise>0</xsl:otherwise>
1534
- </xsl:choose>
1535
- </xsl:variable>
1536
-
1537
- <xsl:choose>
1538
-
1539
- <!-- Case I: The string begins with neither a number, nor an operator -->
1540
- <xsl:when test="$fOperAtPos1='0' and $fNumAtPos1='0'">
1541
- <xsl:variable name="nCharToPrint">
1542
- <xsl:choose>
1543
- <xsl:when test="ancestor::m:fName">
1544
- <xsl:choose>
1545
- <xsl:when test="($iFirstOper=$iFirstNum) and
1546
- ($iFirstOper=string-length($sToParse)) and
1547
- (substring($sRepOperWith-, string-length($sRepOperWith-))!='0') and
1548
- (substring($sRepOperWith-, string-length($sRepOperWith-))!='-')">
1549
- <xsl:value-of select="string-length($sToParse)" />
1550
- </xsl:when>
1551
- <xsl:when test="$iFirstOper &lt; $iFirstNum">
1552
- <xsl:value-of select="$iFirstOper - 1" />
1553
- </xsl:when>
1554
- <xsl:otherwise>
1555
- <xsl:value-of select="$iFirstNum - 1" />
1556
- </xsl:otherwise>
1557
- </xsl:choose>
1558
- </xsl:when>
1559
- <xsl:otherwise>1</xsl:otherwise>
1560
- </xsl:choose>
1561
- </xsl:variable>
1562
-
1563
- <mml:mi>
1564
- <xsl:call-template name="CreateTokenAttributes">
1565
- <xsl:with-param name="scr" select="$scr" />
1566
- <xsl:with-param name="sty" select="$sty" />
1567
- <xsl:with-param name="nor" select="$nor" />
1568
- <xsl:with-param name="nCharToPrint" select="$nCharToPrint" />
1569
- <xsl:with-param name="sTokenType" select="'mi'" />
1570
- </xsl:call-template>
1571
- <xsl:variable name="sWrite" select="translate(substring($sToParse, 1, $nCharToPrint), ' ', '&#xa0;')" />
1572
- <xsl:value-of select="$sWrite" />
1573
- </mml:mi>
1574
- <xsl:call-template name="ParseMt">
1575
- <xsl:with-param name="sToParse" select="substring($sToParse, $nCharToPrint+1)" />
1576
- <xsl:with-param name="scr" select="$scr" />
1577
- <xsl:with-param name="sty" select="$sty" />
1578
- <xsl:with-param name="nor" select="$nor" />
1579
- </xsl:call-template>
1580
- </xsl:when>
1581
-
1582
- <!-- Case II: There is an operator at position 1 -->
1583
- <xsl:when test="$fOperAtPos1='1'">
1584
- <mml:mo>
1585
- <xsl:call-template name="CreateTokenAttributes">
1586
- <xsl:with-param name="scr" />
1587
- <xsl:with-param name="sty" />
1588
- <xsl:with-param name="nor" select="$nor" />
1589
- <xsl:with-param name="sTokenType" select="'mo'" />
1590
- </xsl:call-template>
1591
- <xsl:value-of select="substring($sToParse,1,1)" />
1592
- </mml:mo>
1593
- <xsl:call-template name="ParseMt">
1594
- <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1595
- <xsl:with-param name="scr" select="$scr" />
1596
- <xsl:with-param name="sty" select="$sty" />
1597
- <xsl:with-param name="nor" select="$nor" />
1598
- </xsl:call-template>
1599
- </xsl:when>
1600
-
1601
- <!-- Case III: There is a number at position 1 -->
1602
- <xsl:otherwise>
1603
- <xsl:variable name="sConsecNum">
1604
- <xsl:call-template name="SNumStart">
1605
- <xsl:with-param name="sToParse" select="$sToParse" />
1606
- <xsl:with-param name="sPattern" select="$sRepNumWith0" />
1607
- </xsl:call-template>
1608
- </xsl:variable>
1609
- <mml:mn>
1610
- <xsl:call-template name="CreateTokenAttributes">
1611
- <xsl:with-param name="scr" select="$scr" />
1612
- <xsl:with-param name="sty" select="'p'" />
1613
- <xsl:with-param name="nor" select="$nor" />
1614
- <xsl:with-param name="sTokenType" select="'mn'" />
1615
- </xsl:call-template>
1616
- <xsl:value-of select="$sConsecNum" />
1617
- </mml:mn>
1618
- <xsl:call-template name="ParseMt">
1619
- <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)" />
1620
- <xsl:with-param name="scr" select="$scr" />
1621
- <xsl:with-param name="sty" select="$sty" />
1622
- <xsl:with-param name="nor" select="$nor" />
1623
- </xsl:call-template>
1624
- </xsl:otherwise>
1625
- </xsl:choose>
1626
- </xsl:if>
1627
- </xsl:template>
1628
-
1629
- <!-- %%Template: SNumStart
1630
-
1631
- Return the longest substring of sToParse starting from the
1632
- start of sToParse that is a number. In addition, it takes the
1633
- pattern string, which is sToParse with all of its numbers
1634
- replaced with a 0. sPattern should be the same length
1635
- as sToParse
1636
- -->
1637
- <xsl:template name="SNumStart">
1638
- <xsl:param name="sToParse" select="''" />
1639
- <!-- if we don't get anything, take the string itself -->
1640
- <xsl:param name="sPattern" select="'$sToParse'" />
1641
-
1642
-
1643
- <xsl:choose>
1644
- <!-- the pattern says this is a number, recurse with the rest -->
1645
- <xsl:when test="substring($sPattern, 1, 1) = '0'">
1646
- <xsl:call-template name="SNumStart">
1647
- <xsl:with-param name="sToParse" select="$sToParse" />
1648
- <xsl:with-param name="sPattern" select="substring($sPattern, 2)" />
1649
- </xsl:call-template>
1650
- </xsl:when>
1651
-
1652
- <!-- the pattern says we've run out of numbers. Take as many
1653
- characters from sToParse as we shaved off sPattern -->
1654
- <xsl:otherwise>
1655
- <xsl:value-of select="substring($sToParse, 1, string-length($sToParse) - string-length($sPattern))" />
1656
- </xsl:otherwise>
1657
- </xsl:choose>
1658
- </xsl:template>
1659
-
1660
- <!-- %%Template SRepeatCharAcc
1661
-
1662
- The core of SRepeatChar with an accumulator. The current
1663
- string is in param $acc, and we will double and recurse,
1664
- if we're less than half of the required length or else just
1665
- add the right amount of characters to the accumulator and
1666
- return
1667
- -->
1668
- <xsl:template name="SRepeatCharAcc">
1669
- <xsl:param name="cchRequired" select="1" />
1670
- <xsl:param name="ch" select="'-'" />
1671
- <xsl:param name="acc" select="$ch" />
1672
-
1673
- <xsl:variable name="cchAcc" select="string-length($acc)" />
1674
- <xsl:choose>
1675
- <xsl:when test="(2 * $cchAcc) &lt; $cchRequired">
1676
- <xsl:call-template name="SRepeatCharAcc">
1677
- <xsl:with-param name="cchRequired" select="$cchRequired" />
1678
- <xsl:with-param name="ch" select="$ch" />
1679
- <xsl:with-param name="acc" select="concat($acc, $acc)" />
1680
- </xsl:call-template>
1681
- </xsl:when>
1682
-
1683
- <xsl:otherwise>
1684
- <xsl:value-of select="concat($acc, substring($acc, 1, $cchRequired - $cchAcc))" />
1685
- </xsl:otherwise>
1686
- </xsl:choose>
1687
- </xsl:template>
1688
-
1689
-
1690
- <!-- %%Template SRepeatChar
1691
-
1692
- Generates a string nchRequired long by repeating the given character ch
1693
- -->
1694
- <xsl:template name="SRepeatChar">
1695
- <xsl:param name="cchRequired" select="1" />
1696
- <xsl:param name="ch" select="'-'" />
1697
-
1698
- <xsl:call-template name="SRepeatCharAcc">
1699
- <xsl:with-param name="cchRequired" select="$cchRequired" />
1700
- <xsl:with-param name="ch" select="$ch" />
1701
- <xsl:with-param name="acc" select="$ch" />
1702
- </xsl:call-template>
1703
- </xsl:template>
1704
-
1705
- <!-- %%Template SReplaceOperWithMinus
1706
-
1707
- Go through the given string and replace every instance
1708
- of an operator with a minus '-'. This helps quickly identify
1709
- the first instance of an operator.
1710
- -->
1711
- <xsl:template name="SReplaceOperWithMinus">
1712
- <xsl:param name="sToParse" select="''" />
1713
-
1714
- <xsl:value-of select="translate($sToParse, $sOperators, $sMinuses)" />
1715
- </xsl:template>
1716
-
1717
- <!-- %%Template SReplaceNumWithZero
1718
-
1719
- Go through the given string and replace every instance
1720
- of an number with a zero '0'. This helps quickly identify
1721
- the first occurence of a number.
1722
-
1723
- Considers the '.' and ',' part of a number iff they are sandwiched
1724
- between two other numbers. 0.3 will be recognized as a number,
1725
- x.3 will not be. Since these characters can also be an operator, this
1726
- should be called before SReplaceOperWithMinus.
1727
- -->
1728
- <xsl:template name="SReplaceNumWithZero">
1729
- <xsl:param name="sToParse" select="''" />
1730
-
1731
- <!-- First do a simple replace. Numbers will all be come 0's.
1732
- After this point, the pattern involving the . or , that
1733
- we are looking for will become 0.0 or 0,0 -->
1734
- <xsl:variable name="sSimpleReplace" select="translate($sToParse, $sNumbers, $sZeros)" />
1735
-
1736
- <!-- And then, replace 0.0 with just 000. This means that the . will
1737
- become part of the number -->
1738
- <xsl:variable name="sReplacePeriod">
1739
- <xsl:call-template name="SReplace">
1740
- <xsl:with-param name="sInput" select="$sSimpleReplace" />
1741
- <xsl:with-param name="sOrig" select="'0.0'" />
1742
- <xsl:with-param name="sReplacement" select="'000'" />
1743
- </xsl:call-template>
1744
- </xsl:variable>
1745
-
1746
- <!-- And then, replace 0,0 with just 000. This means that the , will
1747
- become part of the number -->
1748
- <xsl:call-template name="SReplace">
1749
- <xsl:with-param name="sInput" select="$sReplacePeriod" />
1750
- <xsl:with-param name="sOrig" select="'0,0'" />
1751
- <xsl:with-param name="sReplacement" select="'000'" />
1752
- </xsl:call-template>
1753
- </xsl:template>
1754
-
1755
- <!-- Template to translate Word's borderBox properties into the menclose notation attribute
1756
- The initial call to this SHOULD NOT pass an sAttribute. Subsequent calls to
1757
- CreateMencloseNotationAttrFromBorderBoxAttr by CreateMencloseNotationAttrFromBorderBoxAttr will
1758
- update the sAttribute as appropriate.
1759
-
1760
- CreateMencloseNotationAttrFromBorderBoxAttr looks at each attribute (fHideTop, fHideBot, etc.) one at a time
1761
- in the order they are listed and passes a modified sAttribute to CreateMencloseNotationAttrFromBorderBoxAttr.
1762
- Each successive call to CreateMencloseNotationAttrFromBorderBoxAttr knows which attribute to look at because
1763
- the previous call should have omitted passing the attribute it just analyzed. This is why as you read lower
1764
- and lower in the template that each call to CreateMencloseNotationAttrFromBorderBoxAttr has fewer and fewer attributes.
1765
- -->
1766
- <xsl:template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1767
- <xsl:param name="fHideTop" />
1768
- <xsl:param name="fHideBot" />
1769
- <xsl:param name="fHideLeft" />
1770
- <xsl:param name="fHideRight" />
1771
- <xsl:param name="fStrikeH" />
1772
- <xsl:param name="fStrikeV" />
1773
- <xsl:param name="fStrikeBLTR" />
1774
- <xsl:param name="fStrikeTLBR" />
1775
- <xsl:param name="sAttribute" />
1776
-
1777
- <xsl:choose>
1778
- <xsl:when test="string-length($sAttribute) = 0">
1779
- <xsl:choose>
1780
- <xsl:when test="string-length($fHideTop) &gt; 0
1781
- and string-length($fHideBot) &gt; 0
1782
- and string-length($fHideLeft) &gt; 0
1783
- and string-length($fHideRight) &gt; 0">
1784
-
1785
- <xsl:choose>
1786
- <xsl:when test="$fHideTop = 0
1787
- and $fHideBot = 0
1788
- and $fHideLeft = 0
1789
- and $fHideRight = 0">
1790
- <!-- We can use 'box' instead of top, bot, left, and right. Therefore,
1791
- replace sAttribute with 'box' and begin analyzing params fStrikeH
1792
- and below. -->
1793
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1794
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1795
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1796
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1797
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1798
- <xsl:with-param name="sAttribute">
1799
- <xsl:text>box</xsl:text>
1800
- </xsl:with-param>
1801
- </xsl:call-template>
1802
- </xsl:when>
1803
- <xsl:otherwise>
1804
- <!-- Can't use 'box', theremore, must analyze all attributes -->
1805
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1806
- <xsl:with-param name="fHideTop" select="$fHideTop" />
1807
- <xsl:with-param name="fHideBot" select="$fHideBot" />
1808
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1809
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1810
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1811
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1812
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1813
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1814
- <xsl:with-param name="sAttribute">
1815
- <!-- Assume using all four (left right top bottom). Subsequent calls
1816
- will remove the sides which aren't to be includes. -->
1817
- <xsl:text>left right top bottom</xsl:text>
1818
- </xsl:with-param>
1819
- </xsl:call-template>
1820
- </xsl:otherwise>
1821
- </xsl:choose>
1822
- </xsl:when>
1823
- </xsl:choose>
1824
- </xsl:when>
1825
- <xsl:otherwise>
1826
- <xsl:choose>
1827
- <xsl:when test="string-length($fHideTop) &gt; 0">
1828
- <xsl:choose>
1829
- <xsl:when test="$fHideTop=1">
1830
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1831
- <xsl:with-param name="fHideBot" select="$fHideBot" />
1832
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1833
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1834
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1835
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1836
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1837
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1838
- <xsl:with-param name="sAttribute">
1839
- <xsl:call-template name="SReplace">
1840
- <xsl:with-param name="sInput" select="$sAttribute" />
1841
- <xsl:with-param name="sOrig" select="'top'" />
1842
- <xsl:with-param name="sReplacement" select="''" />
1843
- </xsl:call-template>
1844
- </xsl:with-param>
1845
- </xsl:call-template>
1846
- </xsl:when>
1847
- <xsl:otherwise>
1848
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1849
- <xsl:with-param name="fHideBot" select="$fHideBot" />
1850
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1851
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1852
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1853
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1854
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1855
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1856
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1857
- </xsl:call-template>
1858
- </xsl:otherwise>
1859
- </xsl:choose>
1860
- </xsl:when>
1861
- <xsl:when test="string-length($fHideBot) &gt; 0">
1862
- <xsl:choose>
1863
- <xsl:when test="$fHideBot=1">
1864
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1865
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1866
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1867
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1868
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1869
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1870
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1871
- <xsl:with-param name="sAttribute">
1872
- <xsl:call-template name="SReplace">
1873
- <xsl:with-param name="sInput" select="$sAttribute" />
1874
- <xsl:with-param name="sOrig" select="'bottom'" />
1875
- <xsl:with-param name="sReplacement" select="''" />
1876
- </xsl:call-template>
1877
- </xsl:with-param>
1878
- </xsl:call-template>
1879
- </xsl:when>
1880
- <xsl:otherwise>
1881
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1882
- <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1883
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1884
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1885
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1886
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1887
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1888
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1889
- </xsl:call-template>
1890
- </xsl:otherwise>
1891
- </xsl:choose>
1892
- </xsl:when>
1893
- <xsl:when test="string-length($fHideLeft) &gt; 0">
1894
- <xsl:choose>
1895
- <xsl:when test="$fHideLeft=1">
1896
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1897
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1898
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1899
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1900
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1901
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1902
- <xsl:with-param name="sAttribute">
1903
- <xsl:call-template name="SReplace">
1904
- <xsl:with-param name="sInput" select="$sAttribute" />
1905
- <xsl:with-param name="sOrig" select="'left'" />
1906
- <xsl:with-param name="sReplacement" select="''" />
1907
- </xsl:call-template>
1908
- </xsl:with-param>
1909
- </xsl:call-template>
1910
- </xsl:when>
1911
- <xsl:otherwise>
1912
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1913
- <xsl:with-param name="fHideRight" select="$fHideRight" />
1914
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1915
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1916
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1917
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1918
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1919
- </xsl:call-template>
1920
- </xsl:otherwise>
1921
- </xsl:choose>
1922
- </xsl:when>
1923
- <xsl:when test="string-length($fHideRight) &gt; 0">
1924
- <xsl:choose>
1925
- <xsl:when test="$fHideRight=1">
1926
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1927
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1928
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1929
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1930
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1931
- <xsl:with-param name="sAttribute">
1932
- <xsl:call-template name="SReplace">
1933
- <xsl:with-param name="sInput" select="$sAttribute" />
1934
- <xsl:with-param name="sOrig" select="'right'" />
1935
- <xsl:with-param name="sReplacement" select="''" />
1936
- </xsl:call-template>
1937
- </xsl:with-param>
1938
- </xsl:call-template>
1939
- </xsl:when>
1940
- <xsl:otherwise>
1941
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1942
- <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1943
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1944
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1945
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1946
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1947
- </xsl:call-template>
1948
- </xsl:otherwise>
1949
- </xsl:choose>
1950
- </xsl:when>
1951
- <xsl:when test="string-length($fStrikeH) &gt; 0">
1952
- <xsl:choose>
1953
- <xsl:when test="$fStrikeH=1">
1954
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1955
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1956
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1957
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1958
- <xsl:with-param name="sAttribute" select="concat($sAttribute, ' horizontalstrike')" />
1959
- </xsl:call-template>
1960
- </xsl:when>
1961
- <xsl:otherwise>
1962
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1963
- <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1964
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1965
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1966
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1967
- </xsl:call-template>
1968
- </xsl:otherwise>
1969
- </xsl:choose>
1970
- </xsl:when>
1971
- <xsl:when test="string-length($fStrikeV) &gt; 0">
1972
- <xsl:choose>
1973
- <xsl:when test="$fStrikeV=1">
1974
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1975
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1976
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1977
- <xsl:with-param name="sAttribute" select="concat($sAttribute, ' verticalstrike')" />
1978
- </xsl:call-template>
1979
- </xsl:when>
1980
- <xsl:otherwise>
1981
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1982
- <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1983
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1984
- <xsl:with-param name="sAttribute" select="$sAttribute" />
1985
- </xsl:call-template>
1986
- </xsl:otherwise>
1987
- </xsl:choose>
1988
- </xsl:when>
1989
- <xsl:when test="string-length($fStrikeBLTR) &gt; 0">
1990
- <xsl:choose>
1991
- <xsl:when test="$fStrikeBLTR=1">
1992
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1993
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1994
- <xsl:with-param name="sAttribute" select="concat($sAttribute, ' updiagonalstrike')" />
1995
- </xsl:call-template>
1996
- </xsl:when>
1997
- <xsl:otherwise>
1998
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1999
- <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
2000
- <xsl:with-param name="sAttribute" select="$sAttribute" />
2001
- </xsl:call-template>
2002
- </xsl:otherwise>
2003
- </xsl:choose>
2004
- </xsl:when>
2005
- <xsl:when test="string-length($fStrikeTLBR) &gt; 0">
2006
- <xsl:choose>
2007
- <xsl:when test="$fStrikeTLBR=1">
2008
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
2009
- <xsl:with-param name="sAttribute" select="concat($sAttribute, ' downdiagonalstrike')" />
2010
- </xsl:call-template>
2011
- </xsl:when>
2012
- <xsl:otherwise>
2013
- <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
2014
- <xsl:with-param name="sAttribute" select="$sAttribute" />
2015
- </xsl:call-template>
2016
- </xsl:otherwise>
2017
- </xsl:choose>
2018
- </xsl:when>
2019
- <xsl:otherwise>
2020
- <xsl:attribute name="notation">
2021
- <xsl:value-of select="normalize-space($sAttribute)" />
2022
- </xsl:attribute>
2023
- </xsl:otherwise>
2024
- </xsl:choose>
2025
- </xsl:otherwise>
2026
- </xsl:choose>
2027
- </xsl:template>
2028
-
2029
- <!-- Tristate (true, false, neither) from string value -->
2030
- <xsl:template name="TFromStrVal">
2031
- <xsl:param name="str" />
2032
- <xsl:choose>
2033
- <xsl:when test="$str = 'on' or $str = '1' or $str = 'true'">1</xsl:when>
2034
- <xsl:when test="$str = 'off' or $str = '0' or $str = 'false'">0</xsl:when>
2035
- <xsl:otherwise>-1</xsl:otherwise>
2036
- </xsl:choose>
2037
- </xsl:template>
2038
-
2039
- <!-- Return 0 iff $str is explicitly set to a false value.
2040
- Return true otherwise -->
2041
- <xsl:template name="ForceFalseStrVal">
2042
- <xsl:param name="str" />
2043
- <xsl:variable name="tValue">
2044
- <xsl:call-template name="TFromStrVal">
2045
- <xsl:with-param name="str" select="$str"/>
2046
- </xsl:call-template>
2047
- </xsl:variable>
2048
- <xsl:choose>
2049
- <xsl:when test="$tValue = '0'">0</xsl:when>
2050
- <xsl:otherwise>1</xsl:otherwise>
2051
- </xsl:choose>
2052
- </xsl:template>
2053
-
2054
- <!-- Return 1 iff $str is explicitly set to a true value.
2055
- Return false otherwise -->
2056
- <xsl:template name="ForceTrueStrVal">
2057
- <xsl:param name="str" />
2058
- <xsl:variable name="tValue">
2059
- <xsl:call-template name="TFromStrVal">
2060
- <xsl:with-param name="str" select="$str"/>
2061
- </xsl:call-template>
2062
- </xsl:variable>
2063
- <xsl:choose>
2064
- <xsl:when test="$tValue = '1'">1</xsl:when>
2065
- <xsl:otherwise>0</xsl:otherwise>
2066
- </xsl:choose>
2067
- </xsl:template>
2068
- </xsl:stylesheet>
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mml="http://www.w3.org/1998/Math/MathML"
3
+ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
4
+ <xsl:output method="xml" encoding="UTF-8" />
5
+
6
+ <!-- %% Global Definitions -->
7
+
8
+ <!-- Every single unicode character that is recognized by OMML as an operator -->
9
+ <xsl:variable name="sOperators"
10
+ select="concat(
11
+ '&#x00A8;&#x0021;&#x0022;&#x0023;&#x0026;&#x0028;&#x0029;&#x002B;&#x002C;&#x002D;&#x002E;&#x002F;&#x003A;',
12
+ '&#x003B;&#x003C;&#x003D;&#x003E;&#x003F;&#x0040;&#x005B;&#x005C;&#x005D;&#x005E;&#x005F;&#x0060;&#x007B;',
13
+ '&#x007C;&#x007D;&#x007E;&#x00A1;&#x00A6;&#x00AC;&#x00AF;&#x00B0;&#x00B1;&#x00B2;&#x00B3;&#x00B4;&#x00B7;&#x00B9;&#x00BF;',
14
+ '&#x00D7;&#x007E;&#x00F7;&#x02C7;&#x02D8;&#x02D9;&#x02DC;&#x02DD;&#x0300;&#x0301;&#x0302;&#x0303;&#x0304;&#x0305;&#x0306;&#x0307;&#x0308;&#x0309;',
15
+ '&#x030A;&#x030B;&#x030C;&#x030D;&#x030E;&#x030F;&#x0310;&#x0311;&#x0312;&#x0313;&#x0314;&#x0315;',
16
+ '&#x0316;&#x0317;&#x0318;&#x0319;&#x031A;&#x031B;&#x031C;&#x031D;&#x031E;&#x031F;&#x0320;&#x0321;',
17
+ '&#x0322;&#x0323;&#x0324;&#x0325;&#x0326;&#x0327;&#x0328;&#x0329;&#x032A;&#x032B;&#x032C;&#x032D;',
18
+ '&#x032E;&#x032F;&#x0330;&#x0331;&#x0332;&#x0333;&#x0334;&#x0335;&#x0336;&#x0337;&#x0338;&#x033F;',
19
+ '&#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;&#x2006;&#x2009;&#x200A;&#x2010;&#x2012;&#x2013;',
20
+ '&#x2014;&#x2016;&#x2020;&#x2021;&#x2022;&#x2024;&#x2025;&#x2026;&#x2032;&#x2033;&#x2034;&#x203C;',
21
+ '&#x2040;&#x2044;&#x204E;&#x204F;&#x2050;&#x2057;&#x2061;&#x2062;&#x2063;&#x2070;&#x2074;&#x2075;',
22
+ '&#x2076;&#x2077;&#x2078;&#x2079;&#x207A;&#x207B;&#x207C;&#x207D;&#x207E;&#x2080;&#x2081;&#x2082;',
23
+ '&#x2083;&#x2084;&#x2085;&#x2086;&#x2087;&#x2088;&#x2089;&#x208A;&#x208B;&#x208C;&#x208D;&#x208E;',
24
+ '&#x20D0;&#x20D1;&#x20D2;&#x20D3;&#x20D4;&#x20D5;&#x20D6;&#x20D7;&#x20D8;&#x20D9;&#x20DA;&#x20DB;',
25
+ '&#x20DC;&#x20DD;&#x20DE;&#x20DF;&#x20E0;&#x20E1;&#x20E4;&#x20E5;&#x20E6;&#x20E7;&#x20E8;&#x20E9;',
26
+ '&#x20EA;&#x2140;&#x2146;&#x2190;&#x2191;&#x2192;&#x2193;&#x2194;&#x2195;&#x2196;&#x2197;&#x2198;&#x2199;',
27
+ '&#x219A;&#x219B;&#x219C;&#x219D;&#x219E;&#x219F;&#x21A0;&#x21A1;&#x21A2;&#x21A3;&#x21A4;&#x21A5;',
28
+ '&#x21A6;&#x21A7;&#x21A8;&#x21A9;&#x21AA;&#x21AB;&#x21AC;&#x21AD;&#x21AE;&#x21AF;&#x21B0;&#x21B1;',
29
+ '&#x21B2;&#x21B3;&#x21B6;&#x21B7;&#x21BA;&#x21BB;&#x21BC;&#x21BD;&#x21BE;&#x21BF;&#x21C0;&#x21C1;',
30
+ '&#x21C2;&#x21C3;&#x21C4;&#x21C5;&#x21C6;&#x21C7;&#x21C8;&#x21C9;&#x21CA;&#x21CB;&#x21CC;&#x21CD;',
31
+ '&#x21CE;&#x21CF;&#x21D0;&#x21D1;&#x21D2;&#x21D3;&#x21D4;&#x21D5;&#x21D6;&#x21D7;&#x21D8;&#x21D9;',
32
+ '&#x21DA;&#x21DB;&#x21DC;&#x21DD;&#x21DE;&#x21DF;&#x21E0;&#x21E1;&#x21E2;&#x21E3;&#x21E4;&#x21E5;',
33
+ '&#x21E6;&#x21E7;&#x21E8;&#x21E9;&#x21F3;&#x21F4;&#x21F5;&#x21F6;&#x21F7;&#x21F8;&#x21F9;&#x21FA;',
34
+ '&#x21FB;&#x21FC;&#x21FD;&#x21FE;&#x21FF;&#x2200;&#x2201;&#x2202;&#x2203;&#x2204;&#x2206;&#x2207;',
35
+ '&#x2208;&#x2209;&#x220A;&#x220B;&#x220C;&#x220D;&#x220F;&#x2210;&#x2211;&#x2212;&#x2213;&#x2214;',
36
+ '&#x2215;&#x2216;&#x2217;&#x2218;&#x2219;&#x221A;&#x221B;&#x221C;&#x221D;&#x2223;&#x2224;&#x2225;',
37
+ '&#x2226;&#x2227;&#x2228;&#x2229;&#x222A;&#x222B;&#x222C;&#x222D;&#x222E;&#x222F;&#x2230;&#x2231;',
38
+ '&#x2232;&#x2233;&#x2234;&#x2235;&#x2236;&#x2237;&#x2238;&#x2239;&#x223A;&#x223B;&#x223C;&#x223D;',
39
+ '&#x223E;&#x2240;&#x2241;&#x2242;&#x2243;&#x2244;&#x2245;&#x2246;&#x2247;&#x2248;&#x2249;&#x224A;',
40
+ '&#x224B;&#x224C;&#x224D;&#x224E;&#x224F;&#x2250;&#x2251;&#x2252;&#x2253;&#x2254;&#x2255;&#x2256;',
41
+ '&#x2257;&#x2258;&#x2259;&#x225A;&#x225B;&#x225C;&#x225D;&#x225E;&#x225F;&#x2260;&#x2261;&#x2262;',
42
+ '&#x2263;&#x2264;&#x2265;&#x2266;&#x2267;&#x2268;&#x2269;&#x226A;&#x226B;&#x226C;&#x226D;&#x226E;',
43
+ '&#x226F;&#x2270;&#x2271;&#x2272;&#x2273;&#x2274;&#x2275;&#x2276;&#x2277;&#x2278;&#x2279;&#x227A;',
44
+ '&#x227B;&#x227C;&#x227D;&#x227E;&#x227F;&#x2280;&#x2281;&#x2282;&#x2283;&#x2284;&#x2285;&#x2286;',
45
+ '&#x2287;&#x2288;&#x2289;&#x228A;&#x228B;&#x228C;&#x228D;&#x228E;&#x228F;&#x2290;&#x2291;&#x2292;',
46
+ '&#x2293;&#x2294;&#x2295;&#x2296;&#x2297;&#x2298;&#x2299;&#x229A;&#x229B;&#x229C;&#x229D;&#x229E;',
47
+ '&#x229F;&#x22A0;&#x22A1;&#x22A2;&#x22A3;&#x22A5;&#x22A6;&#x22A7;&#x22A8;&#x22A9;&#x22AA;&#x22AB;',
48
+ '&#x22AC;&#x22AD;&#x22AE;&#x22AF;&#x22B0;&#x22B1;&#x22B2;&#x22B3;&#x22B4;&#x22B5;&#x22B6;&#x22B7;',
49
+ '&#x22B8;&#x22B9;&#x22BA;&#x22BB;&#x22BC;&#x22BD;&#x22C0;&#x22C1;&#x22C2;&#x22C3;&#x22C4;&#x22C5;',
50
+ '&#x22C6;&#x22C7;&#x22C8;&#x22C9;&#x22CA;&#x22CB;&#x22CC;&#x22CD;&#x22CE;&#x22CF;&#x22D0;&#x22D1;',
51
+ '&#x22D2;&#x22D3;&#x22D4;&#x22D5;&#x22D6;&#x22D7;&#x22D8;&#x22D9;&#x22DA;&#x22DB;&#x22DC;&#x22DD;',
52
+ '&#x22DE;&#x22DF;&#x22E0;&#x22E1;&#x22E2;&#x22E3;&#x22E4;&#x22E5;&#x22E6;&#x22E7;&#x22E8;&#x22E9;',
53
+ '&#x22EA;&#x22EB;&#x22EC;&#x22ED;&#x22EE;&#x22EF;&#x22F0;&#x22F1;&#x22F2;&#x22F3;&#x22F4;&#x22F5;',
54
+ '&#x22F6;&#x22F7;&#x22F8;&#x22F9;&#x22FA;&#x22FB;&#x22FC;&#x22FD;&#x22FE;&#x22FF;&#x2305;&#x2306;',
55
+ '&#x2308;&#x2309;&#x230A;&#x230B;&#x231C;&#x231D;&#x231E;&#x231F;&#x2322;&#x2323;&#x2329;&#x232A;',
56
+ '&#x233D;&#x233F;&#x23B0;&#x23B1;&#x23DC;&#x23DD;&#x23DE;&#x23DF;&#x23E0;&#x2502;&#x251C;&#x2524;',
57
+ '&#x252C;&#x2534;&#x2581;&#x2588;&#x2592;&#x25A0;&#x25A1;&#x25AD;&#x25B2;&#x25B3;&#x25B4;&#x25B5;',
58
+ '&#x25B6;&#x25B7;&#x25B8;&#x25B9;&#x25BC;&#x25BD;&#x25BE;&#x25BF;&#x25C0;&#x25C1;&#x25C2;&#x25C3;',
59
+ '&#x25C4;&#x25C5;&#x25CA;&#x25CB;&#x25E6;&#x25EB;&#x25EC;&#x25F8;&#x25F9;&#x25FA;&#x25FB;&#x25FC;',
60
+ '&#x25FD;&#x25FE;&#x25FF;&#x2605;&#x2606;&#x2772;&#x2773;&#x27D1;&#x27D2;&#x27D3;&#x27D4;&#x27D5;',
61
+ '&#x27D6;&#x27D7;&#x27D8;&#x27D9;&#x27DA;&#x27DB;&#x27DC;&#x27DD;&#x27DE;&#x27DF;&#x27E0;&#x27E1;',
62
+ '&#x27E2;&#x27E3;&#x27E4;&#x27E5;&#x27E6;&#x27E7;&#x27E8;&#x27E9;&#x27EA;&#x27EB;&#x27F0;&#x27F1;',
63
+ '&#x27F2;&#x27F3;&#x27F4;&#x27F5;&#x27F6;&#x27F7;&#x27F8;&#x27F9;&#x27FA;&#x27FB;&#x27FC;&#x27FD;',
64
+ '&#x27FE;&#x27FF;&#x2900;&#x2901;&#x2902;&#x2903;&#x2904;&#x2905;&#x2906;&#x2907;&#x2908;&#x2909;',
65
+ '&#x290A;&#x290B;&#x290C;&#x290D;&#x290E;&#x290F;&#x2910;&#x2911;&#x2912;&#x2913;&#x2914;&#x2915;',
66
+ '&#x2916;&#x2917;&#x2918;&#x2919;&#x291A;&#x291B;&#x291C;&#x291D;&#x291E;&#x291F;&#x2920;&#x2921;',
67
+ '&#x2922;&#x2923;&#x2924;&#x2925;&#x2926;&#x2927;&#x2928;&#x2929;&#x292A;&#x292B;&#x292C;&#x292D;',
68
+ '&#x292E;&#x292F;&#x2930;&#x2931;&#x2932;&#x2933;&#x2934;&#x2935;&#x2936;&#x2937;&#x2938;&#x2939;',
69
+ '&#x293A;&#x293B;&#x293C;&#x293D;&#x293E;&#x293F;&#x2940;&#x2941;&#x2942;&#x2943;&#x2944;&#x2945;',
70
+ '&#x2946;&#x2947;&#x2948;&#x2949;&#x294A;&#x294B;&#x294C;&#x294D;&#x294E;&#x294F;&#x2950;&#x2951;',
71
+ '&#x2952;&#x2953;&#x2954;&#x2955;&#x2956;&#x2957;&#x2958;&#x2959;&#x295A;&#x295B;&#x295C;&#x295D;',
72
+ '&#x295E;&#x295F;&#x2960;&#x2961;&#x2962;&#x2963;&#x2964;&#x2965;&#x2966;&#x2967;&#x2968;&#x2969;',
73
+ '&#x296A;&#x296B;&#x296C;&#x296D;&#x296E;&#x296F;&#x2970;&#x2971;&#x2972;&#x2973;&#x2974;&#x2975;',
74
+ '&#x2976;&#x2977;&#x2978;&#x2979;&#x297A;&#x297B;&#x297C;&#x297D;&#x297E;&#x297F;&#x2980;&#x2982;',
75
+ '&#x2983;&#x2984;&#x2985;&#x2986;&#x2987;&#x2988;&#x2989;&#x298A;&#x298B;&#x298C;&#x298D;&#x298E;',
76
+ '&#x298F;&#x2990;&#x2991;&#x2992;&#x2993;&#x2994;&#x2995;&#x2996;&#x2997;&#x2998;&#x2999;&#x299A;',
77
+ '&#x29B6;&#x29B7;&#x29B8;&#x29B9;&#x29C0;&#x29C1;&#x29C4;&#x29C5;&#x29C6;&#x29C7;&#x29C8;&#x29CE;',
78
+ '&#x29CF;&#x29D0;&#x29D1;&#x29D2;&#x29D3;&#x29D4;&#x29D5;&#x29D6;&#x29D7;&#x29D8;&#x29D9;&#x29DA;',
79
+ '&#x29DB;&#x29DF;&#x29E1;&#x29E2;&#x29E3;&#x29E4;&#x29E5;&#x29E6;&#x29EB;&#x29F4;&#x29F5;&#x29F6;',
80
+ '&#x29F7;&#x29F8;&#x29F9;&#x29FA;&#x29FB;&#x29FC;&#x29FD;&#x29FE;&#x29FF;&#x2A00;&#x2A01;&#x2A02;',
81
+ '&#x2A03;&#x2A04;&#x2A05;&#x2A06;&#x2A07;&#x2A08;&#x2A09;&#x2A0A;&#x2A0B;&#x2A0C;&#x2A0D;&#x2A0E;',
82
+ '&#x2A0F;&#x2A10;&#x2A11;&#x2A12;&#x2A13;&#x2A14;&#x2A15;&#x2A16;&#x2A17;&#x2A18;&#x2A19;&#x2A1A;',
83
+ '&#x2A1B;&#x2A1C;&#x2A1D;&#x2A1E;&#x2A1F;&#x2A20;&#x2A21;&#x2A22;&#x2A23;&#x2A24;&#x2A25;&#x2A26;',
84
+ '&#x2A27;&#x2A28;&#x2A29;&#x2A2A;&#x2A2B;&#x2A2C;&#x2A2D;&#x2A2E;&#x2A2F;&#x2A30;&#x2A31;&#x2A32;',
85
+ '&#x2A33;&#x2A34;&#x2A35;&#x2A36;&#x2A37;&#x2A38;&#x2A39;&#x2A3A;&#x2A3B;&#x2A3C;&#x2A3D;&#x2A3E;',
86
+ '&#x2A3F;&#x2A40;&#x2A41;&#x2A42;&#x2A43;&#x2A44;&#x2A45;&#x2A46;&#x2A47;&#x2A48;&#x2A49;&#x2A4A;',
87
+ '&#x2A4B;&#x2A4C;&#x2A4D;&#x2A4E;&#x2A4F;&#x2A50;&#x2A51;&#x2A52;&#x2A53;&#x2A54;&#x2A55;&#x2A56;',
88
+ '&#x2A57;&#x2A58;&#x2A59;&#x2A5A;&#x2A5B;&#x2A5C;&#x2A5D;&#x2A5E;&#x2A5F;&#x2A60;&#x2A61;&#x2A62;',
89
+ '&#x2A63;&#x2A64;&#x2A65;&#x2A66;&#x2A67;&#x2A68;&#x2A69;&#x2A6A;&#x2A6B;&#x2A6C;&#x2A6D;&#x2A6E;',
90
+ '&#x2A6F;&#x2A70;&#x2A71;&#x2A72;&#x2A73;&#x2A74;&#x2A75;&#x2A76;&#x2A77;&#x2A78;&#x2A79;&#x2A7A;',
91
+ '&#x2A7B;&#x2A7C;&#x2A7D;&#x2A7E;&#x2A7F;&#x2A80;&#x2A81;&#x2A82;&#x2A83;&#x2A84;&#x2A85;&#x2A86;',
92
+ '&#x2A87;&#x2A88;&#x2A89;&#x2A8A;&#x2A8B;&#x2A8C;&#x2A8D;&#x2A8E;&#x2A8F;&#x2A90;&#x2A91;&#x2A92;',
93
+ '&#x2A93;&#x2A94;&#x2A95;&#x2A96;&#x2A97;&#x2A98;&#x2A99;&#x2A9A;&#x2A9B;&#x2A9C;&#x2A9D;&#x2A9E;',
94
+ '&#x2A9F;&#x2AA0;&#x2AA1;&#x2AA2;&#x2AA3;&#x2AA4;&#x2AA5;&#x2AA6;&#x2AA7;&#x2AA8;&#x2AA9;&#x2AAA;',
95
+ '&#x2AAB;&#x2AAC;&#x2AAD;&#x2AAE;&#x2AAF;&#x2AB0;&#x2AB1;&#x2AB2;&#x2AB3;&#x2AB4;&#x2AB5;&#x2AB6;',
96
+ '&#x2AB7;&#x2AB8;&#x2AB9;&#x2ABA;&#x2ABB;&#x2ABC;&#x2ABD;&#x2ABE;&#x2ABF;&#x2AC0;&#x2AC1;&#x2AC2;',
97
+ '&#x2AC3;&#x2AC4;&#x2AC5;&#x2AC6;&#x2AC7;&#x2AC8;&#x2AC9;&#x2ACA;&#x2ACB;&#x2ACC;&#x2ACD;&#x2ACE;',
98
+ '&#x2ACF;&#x2AD0;&#x2AD1;&#x2AD2;&#x2AD3;&#x2AD4;&#x2AD5;&#x2AD6;&#x2AD7;&#x2AD8;&#x2AD9;&#x2ADA;',
99
+ '&#x2ADB;&#x2ADC;&#x2ADD;&#x2ADE;&#x2ADF;&#x2AE0;&#x2AE2;&#x2AE3;&#x2AE4;&#x2AE5;&#x2AE6;&#x2AE7;',
100
+ '&#x2AE8;&#x2AE9;&#x2AEA;&#x2AEB;&#x2AEC;&#x2AED;&#x2AEE;&#x2AEF;&#x2AF0;&#x2AF2;&#x2AF3;&#x2AF4;',
101
+ '&#x2AF5;&#x2AF6;&#x2AF7;&#x2AF8;&#x2AF9;&#x2AFA;&#x2AFB;&#x2AFC;&#x2AFD;&#x2AFE;&#x2AFF;&#x2B04;',
102
+ '&#x2B06;&#x2B07;&#x2B0C;&#x2B0D;&#x3014;&#x3015;&#x3016;&#x3017;&#x3018;&#x3019;&#xFF01;&#xFF06;',
103
+ '&#xFF08;&#xFF09;&#xFF0B;&#xFF0C;&#xFF0D;&#xFF0E;&#xFF0F;&#xFF1A;&#xFF1B;&#xFF1C;&#xFF1D;&#xFF1E;',
104
+ '&#xFF1F;&#xFF20;&#xFF3B;&#xFF3C;&#xFF3D;&#xFF3E;&#xFF3F;&#xFF5B;&#xFF5C;&#xFF5D;')" />
105
+
106
+ <!-- A string of '-'s repeated exactly as many times as the operators above -->
107
+ <xsl:variable name="sMinuses">
108
+ <xsl:call-template name="SRepeatChar">
109
+ <xsl:with-param name="cchRequired" select="string-length($sOperators)" />
110
+ <xsl:with-param name="ch" select="'-'" />
111
+ </xsl:call-template>
112
+ </xsl:variable>
113
+
114
+ <!-- Every single unicode character that is recognized by OMML as a number -->
115
+ <xsl:variable name="sNumbers" select="'0123456789'" />
116
+
117
+ <!-- A string of '0's repeated exactly as many times as the list of numbers above -->
118
+ <xsl:variable name="sZeros">
119
+ <xsl:call-template name="SRepeatChar">
120
+ <xsl:with-param name="cchRequired" select="string-length($sNumbers)" />
121
+ <xsl:with-param name="ch" select="'0'" />
122
+ </xsl:call-template>
123
+ </xsl:variable>
124
+
125
+ <!-- %%Template: SReplace
126
+
127
+ Replace all occurences of sOrig in sInput with sReplacement
128
+ and return the resulting string. -->
129
+ <xsl:template name="SReplace">
130
+ <xsl:param name="sInput" />
131
+ <xsl:param name="sOrig" />
132
+ <xsl:param name="sReplacement" />
133
+
134
+ <xsl:choose>
135
+ <xsl:when test="not(contains($sInput, $sOrig))">
136
+ <xsl:value-of select="$sInput" />
137
+ </xsl:when>
138
+ <xsl:otherwise>
139
+ <xsl:variable name="sBefore" select="substring-before($sInput, $sOrig)" />
140
+ <xsl:variable name="sAfter" select="substring-after($sInput, $sOrig)" />
141
+ <xsl:variable name="sAfterProcessed">
142
+ <xsl:call-template name="SReplace">
143
+ <xsl:with-param name="sInput" select="$sAfter" />
144
+ <xsl:with-param name="sOrig" select="$sOrig" />
145
+ <xsl:with-param name="sReplacement" select="$sReplacement" />
146
+ </xsl:call-template>
147
+ </xsl:variable>
148
+
149
+ <xsl:value-of select="concat($sBefore, concat($sReplacement, $sAfterProcessed))" />
150
+ </xsl:otherwise>
151
+ </xsl:choose>
152
+ </xsl:template>
153
+
154
+ <!-- Templates -->
155
+ <xsl:template match="/">
156
+ <mml:math>
157
+ <xsl:apply-templates select="*" />
158
+ </mml:math>
159
+ </xsl:template>
160
+
161
+ <xsl:template match="m:borderBox">
162
+
163
+ <!-- Get Lowercase versions of properties -->
164
+ <xsl:variable name="sLowerCaseHideTop" select="translate(m:borderBoxPr[last()]/m:hideTop[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
165
+ 'abcdefghijklmnopqrstuvwxyz')" />
166
+ <xsl:variable name="sLowerCaseHideBot" select="translate(m:borderBoxPr[last()]/m:hideBot[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
167
+ 'abcdefghijklmnopqrstuvwxyz')" />
168
+ <xsl:variable name="sLowerCaseHideLeft" select="translate(m:borderBoxPr[last()]/m:hideLeft[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
169
+ 'abcdefghijklmnopqrstuvwxyz')" />
170
+ <xsl:variable name="sLowerCaseHideRight" select="translate(m:borderBoxPr[last()]/m:hideRight[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
171
+ 'abcdefghijklmnopqrstuvwxyz')" />
172
+ <xsl:variable name="sLowerCaseStrikeH" select="translate(m:borderBoxPr[last()]/m:strikeH[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
173
+ 'abcdefghijklmnopqrstuvwxyz')" />
174
+ <xsl:variable name="sLowerCaseStrikeV" select="translate(m:borderBoxPr[last()]/m:strikeV[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
175
+ 'abcdefghijklmnopqrstuvwxyz')" />
176
+ <xsl:variable name="sLowerCaseStrikeBLTR" select="translate(m:borderBoxPr[last()]/m:strikeBLTR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
177
+ 'abcdefghijklmnopqrstuvwxyz')" />
178
+ <xsl:variable name="sLowerCaseStrikeTLBR" select="translate(m:borderBoxPr[last()]/m:strikeTLBR[last()]/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
179
+ 'abcdefghijklmnopqrstuvwxyz')" />
180
+ <xsl:variable name="fHideTop">
181
+ <xsl:call-template name="ForceTrueStrVal">
182
+ <xsl:with-param name="str" select="$sLowerCaseHideTop" />
183
+ </xsl:call-template>
184
+ </xsl:variable>
185
+ <xsl:variable name="fHideBot">
186
+ <xsl:call-template name="ForceTrueStrVal">
187
+ <xsl:with-param name="str" select="$sLowerCaseHideBot" />
188
+ </xsl:call-template>
189
+ </xsl:variable>
190
+ <xsl:variable name="fHideLeft">
191
+ <xsl:call-template name="ForceTrueStrVal">
192
+ <xsl:with-param name="str" select="$sLowerCaseHideLeft" />
193
+ </xsl:call-template>
194
+ </xsl:variable>
195
+ <xsl:variable name="fHideRight">
196
+ <xsl:call-template name="ForceTrueStrVal">
197
+ <xsl:with-param name="str" select="$sLowerCaseHideRight" />
198
+ </xsl:call-template>
199
+ </xsl:variable>
200
+ <xsl:variable name="fStrikeH">
201
+ <xsl:call-template name="ForceTrueStrVal">
202
+ <xsl:with-param name="str" select="$sLowerCaseStrikeH" />
203
+ </xsl:call-template>
204
+ </xsl:variable>
205
+ <xsl:variable name="fStrikeV">
206
+ <xsl:call-template name="ForceTrueStrVal">
207
+ <xsl:with-param name="str" select="$sLowerCaseStrikeV" />
208
+ </xsl:call-template>
209
+ </xsl:variable>
210
+ <xsl:variable name="fStrikeBLTR">
211
+ <xsl:call-template name="ForceTrueStrVal">
212
+ <xsl:with-param name="str" select="$sLowerCaseStrikeBLTR" />
213
+ </xsl:call-template>
214
+ </xsl:variable>
215
+ <xsl:variable name="fStrikeTLBR">
216
+ <xsl:call-template name="ForceTrueStrVal">
217
+ <xsl:with-param name="str" select="$sLowerCaseStrikeTLBR" />
218
+ </xsl:call-template>
219
+ </xsl:variable>
220
+
221
+ <xsl:choose>
222
+ <xsl:when test="$fHideTop=1
223
+ and $fHideBot=1
224
+ and $fHideLeft=1
225
+ and $fHideRight=1
226
+ and $fStrikeH=0
227
+ and $fStrikeV=0
228
+ and $fStrikeBLTR=0
229
+ and $fStrikeTLBR=0">
230
+ <mml:mrow>
231
+ <xsl:apply-templates select="m:e[1]" />
232
+ </mml:mrow>
233
+ </xsl:when>
234
+ <xsl:otherwise>
235
+ <mml:menclose>
236
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
237
+ <xsl:with-param name="fHideTop" select="$fHideTop" />
238
+ <xsl:with-param name="fHideBot" select="$fHideBot" />
239
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
240
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
241
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
242
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
243
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
244
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
245
+ </xsl:call-template>
246
+ <xsl:apply-templates select="m:e[1]" />
247
+ </mml:menclose>
248
+ </xsl:otherwise>
249
+ </xsl:choose>
250
+ </xsl:template>
251
+
252
+ <xsl:template match="*">
253
+ <xsl:apply-templates select="*" />
254
+ </xsl:template>
255
+
256
+ <!--
257
+ { Non-combining, Upper-combining, Lower-combining }
258
+ {U+02D8, U+0306, U+032E}, // BREVE
259
+ {U+00B8, U+0312, U+0327}, // CEDILLA
260
+ {U+0060, U+0300, U+0316}, // GRAVE ACCENT
261
+ {U+002D, U+0305, U+0332}, // HYPHEN-MINUS/OVERLINE
262
+ {U+2212, U+0305, U+0332}, // MINUS SIGN/OVERLINE
263
+ {U+002E, U+0305, U+0323}, // FULL STOP/DOT ABOVE
264
+ {U+02D9, U+0307, U+0323}, // DOT ABOVE
265
+ {U+02DD, U+030B, U+02DD}, // DOUBLE ACUTE ACCENT
266
+ {U+00B4, U+0301, U+0317}, // ACUTE ACCENT
267
+ {U+007E, U+0303, U+0330}, // TILDE
268
+ {U+02DC, U+0303, U+0330}, // SMALL TILDE
269
+ {U+00A8, U+0308, U+0324}, // DIAERESIS
270
+ {U+02C7, U+030C, U+032C}, // CARON
271
+ {U+005E, U+0302, U+032D}, // CIRCUMFLEX ACCENT
272
+ {U+00AF, U+0305, ::::::}, // MACRON
273
+ {U+005F, ::::::, U+0332}, // LOW LINE
274
+ {U+2192, U+20D7, U+20EF}, // RIGHTWARDS ARROW
275
+ {U+27F6, U+20D7, U+20EF}, // LONG RIGHTWARDS ARROW
276
+ {U+2190, U+20D6, U+20EE}, // LEFT ARROW
277
+ -->
278
+ <xsl:template name="ToNonCombining">
279
+ <xsl:param name="ch" />
280
+ <xsl:choose>
281
+ <!-- BREVE -->
282
+ <xsl:when test="$ch='&#x0306;' or $ch='&#x032e;'">&#x02D8;</xsl:when>
283
+ <!-- CEDILLA -->
284
+ <xsl:when test="$ch='&#x0312;' or $ch='&#x0327;'">&#x00B8;</xsl:when>
285
+ <!-- GRAVE ACCENT -->
286
+ <xsl:when test="$ch='&#x0300;' or $ch='&#x0316;'">&#x0060;</xsl:when>
287
+ <!-- HYPHEN-MINUS/OVERLINE -->
288
+ <xsl:when test="$ch='&#x0305;' or $ch='&#x0332;'">&#x002D;</xsl:when>
289
+ <!-- MINUS SIGN/OVERLINE -->
290
+ <xsl:when test="$ch='&#x0305;' or $ch='&#x0332;'">&#x2212;</xsl:when>
291
+ <!-- FULL STOP/DOT ABOVE -->
292
+ <xsl:when test="$ch='&#x0305;' or $ch='&#x0323;'">&#x002E;</xsl:when>
293
+ <!-- DOT ABOVE -->
294
+ <xsl:when test="$ch='&#x0307;' or $ch='&#x0323;'">&#x02D9;</xsl:when>
295
+ <!-- DOUBLE ACUTE ACCENT -->
296
+ <xsl:when test="$ch='&#x030B;' or $ch='&#x02DD;'">&#x02DD;</xsl:when>
297
+ <!-- ACUTE ACCENT -->
298
+ <xsl:when test="$ch='&#x0301;' or $ch='&#x0317;'">&#x00B4;</xsl:when>
299
+ <!-- TILDE -->
300
+ <xsl:when test="$ch='&#x0303;' or $ch='&#x0330;'">&#x007E;</xsl:when>
301
+ <!-- SMALL TILDE -->
302
+ <xsl:when test="$ch='&#x0303;' or $ch='&#x0330;'">&#x02DC;</xsl:when>
303
+ <!-- DIAERESIS -->
304
+ <xsl:when test="$ch='&#x0308;' or $ch='&#x0324;'">&#x00A8;</xsl:when>
305
+ <!-- CARON -->
306
+ <xsl:when test="$ch='&#x030C;' or $ch='&#x032C;'">&#x02C7;</xsl:when>
307
+ <!-- CIRCUMFLEX ACCENT -->
308
+ <xsl:when test="$ch='&#x0302;' or $ch='&#x032D;'">&#x005E;</xsl:when>
309
+ <!-- MACRON -->
310
+ <xsl:when test="$ch='&#x0305;' ">&#x00AF;</xsl:when>
311
+ <!-- LOW LINE -->
312
+ <xsl:when test=" $ch='&#x0332;'">&#x005F;</xsl:when>
313
+ <!-- RIGHTWARDS ARROW -->
314
+ <xsl:when test="$ch='&#x20D7;' or $ch='&#x20EF;'">&#x2192;</xsl:when>
315
+ <!-- LONG RIGHTWARDS ARROW -->
316
+ <xsl:when test="$ch='&#x20D7;' or $ch='&#x20EF;'">&#x27F6;</xsl:when>
317
+ <!-- LEFT ARROW -->
318
+ <xsl:when test="$ch='&#x20D6;' or $ch='&#x20EE;'">&#x2190;</xsl:when>
319
+ <xsl:otherwise>
320
+ <xsl:value-of select="$ch"/>
321
+ </xsl:otherwise>
322
+ </xsl:choose>
323
+ </xsl:template>
324
+
325
+ <xsl:template match="m:acc">
326
+ <mml:mover>
327
+ <xsl:attribute name="accent">true</xsl:attribute>
328
+ <mml:mrow>
329
+ <xsl:apply-templates select="m:e[1]" />
330
+ </mml:mrow>
331
+ <xsl:variable name="chAcc">
332
+ <xsl:choose>
333
+ <xsl:when test="not(m:accPr[last()]/m:chr)">
334
+ <xsl:value-of select="'&#x0302;'" />
335
+ </xsl:when>
336
+ <xsl:otherwise>
337
+ <xsl:value-of select="substring(m:accPr/m:chr/@m:val,1,1)" />
338
+ </xsl:otherwise>
339
+ </xsl:choose>
340
+ </xsl:variable>
341
+ <xsl:variable name="chNonComb">
342
+ <xsl:call-template name="ToNonCombining">
343
+ <xsl:with-param name="ch" select="$chAcc" />
344
+ </xsl:call-template>
345
+ </xsl:variable>
346
+ <xsl:choose>
347
+ <xsl:when test="string-length($chAcc)=0">
348
+ <mml:mo/>
349
+ </xsl:when>
350
+ <xsl:otherwise>
351
+ <xsl:call-template name="ParseMt">
352
+ <xsl:with-param name="sToParse" select="$chNonComb" />
353
+ <xsl:with-param name="scr" select="m:e[1]/*/m:rPr[last()]/m:scr/@m:val" />
354
+ <xsl:with-param name="sty" select="m:e[1]/*/m:rPr[last()]/m:sty/@m:val" />
355
+ <xsl:with-param name="nor">
356
+ <xsl:choose>
357
+ <xsl:when test="count(m:e[1]/*/m:rPr[last()]/m:nor) = 0">0</xsl:when>
358
+ <xsl:otherwise>
359
+ <xsl:call-template name="ForceFalseStrVal">
360
+ <xsl:with-param name="str" select="translate(m:e[1]/*/m:rPr[last()]/m:nor/@m:val,
361
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
362
+ 'abcdefghijklmnopqrstuvwxyz')" />
363
+ </xsl:call-template>
364
+ </xsl:otherwise>
365
+ </xsl:choose>
366
+ </xsl:with-param>
367
+ </xsl:call-template>
368
+ </xsl:otherwise>
369
+ </xsl:choose>
370
+ </mml:mover>
371
+ </xsl:template>
372
+
373
+ <xsl:template name="OutputScript">
374
+ <xsl:param name="ndCur" select="." />
375
+ <xsl:choose>
376
+ <!-- Only output contents of $ndCur if $ndCur exists
377
+ and $ndCur has children -->
378
+ <xsl:when test="count($ndCur/*) &gt; 0">
379
+ <mml:mrow>
380
+ <xsl:apply-templates select="$ndCur" />
381
+ </mml:mrow>
382
+ </xsl:when>
383
+ <xsl:otherwise>
384
+ <mml:none />
385
+ </xsl:otherwise>
386
+ </xsl:choose>
387
+ </xsl:template>
388
+
389
+ <xsl:template match="m:sPre">
390
+ <mml:mmultiscripts>
391
+ <mml:mrow>
392
+ <xsl:apply-templates select="m:e[1]" />
393
+ </mml:mrow>
394
+ <mml:mprescripts />
395
+ <xsl:call-template name="OutputScript">
396
+ <xsl:with-param name="ndCur" select="m:sub[1]"/>
397
+ </xsl:call-template>
398
+ <xsl:call-template name="OutputScript">
399
+ <xsl:with-param name="ndCur" select="m:sup[1]" />
400
+ </xsl:call-template>
401
+ </mml:mmultiscripts>
402
+ </xsl:template>
403
+
404
+ <xsl:template match="m:m">
405
+ <mml:mtable>
406
+ <xsl:call-template name="CreateMathMLMatrixAttr">
407
+ <xsl:with-param name="mcJc" select="m:mPr[last()]/m:mcs/m:mc/m:mcPr[last()]/m:mcJc/@m:val" />
408
+ </xsl:call-template>
409
+ <xsl:for-each select="m:mr">
410
+ <mml:mtr>
411
+ <xsl:for-each select="m:e">
412
+ <mml:mtd>
413
+ <xsl:apply-templates select="." />
414
+ </mml:mtd>
415
+ </xsl:for-each>
416
+ </mml:mtr>
417
+ </xsl:for-each>
418
+ </mml:mtable>
419
+ </xsl:template>
420
+
421
+ <xsl:template name="CreateMathMLMatrixAttr">
422
+ <xsl:param name="mcJc" />
423
+ <xsl:variable name="sLowerCaseMcjc" select="translate($mcJc, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
424
+ 'abcdefghijklmnopqrstuvwxyz')" />
425
+ <xsl:choose>
426
+ <xsl:when test="$sLowerCaseMcjc='left'">
427
+ <xsl:attribute name="columnalign">left</xsl:attribute>
428
+ </xsl:when>
429
+ <xsl:when test="$sLowerCaseMcjc='right'">
430
+ <xsl:attribute name="columnalign">right</xsl:attribute>
431
+ </xsl:when>
432
+ </xsl:choose>
433
+ </xsl:template>
434
+
435
+ <xsl:template match="m:phant">
436
+ <xsl:variable name="sLowerCaseZeroWidVal" select="translate(m:phantPr[last()]/m:zeroWid[last()]/@m:val,
437
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
438
+ 'abcdefghijklmnopqrstuvwxyz')" />
439
+ <xsl:variable name="sLowerCaseZeroAscVal" select="translate(m:phantPr[last()]/m:zeroAsc[last()]/@m:val,
440
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
441
+ 'abcdefghijklmnopqrstuvwxyz')" />
442
+ <xsl:variable name="sLowerCaseZeroDescVal" select="translate(m:phantPr[last()]/m:zeroDesc[last()]/@m:val,
443
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
444
+ 'abcdefghijklmnopqrstuvwxyz')" />
445
+ <xsl:variable name="sLowerCaseShowVal" select="translate(m:phantPr[last()]/m:show[last()]/@m:val,
446
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
447
+ 'abcdefghijklmnopqrstuvwxyz')" />
448
+
449
+
450
+ <!-- The following properties default to 'yes' unless the last value equals 'no' or there isn't any node for
451
+ the property -->
452
+
453
+ <xsl:variable name="fZeroWid">
454
+ <xsl:choose>
455
+ <xsl:when test="count(m:phantPr[last()]/m:zeroWid[last()]) = 0">0</xsl:when>
456
+ <xsl:otherwise>
457
+ <xsl:call-template name="ForceFalseStrVal">
458
+ <xsl:with-param name="str" select="$sLowerCaseZeroWidVal" />
459
+ </xsl:call-template>
460
+ </xsl:otherwise>
461
+ </xsl:choose>
462
+ </xsl:variable>
463
+ <xsl:variable name="fZeroAsc">
464
+ <xsl:choose>
465
+ <xsl:when test="count(m:phantPr[last()]/m:zeroAsc[last()]) = 0">0</xsl:when>
466
+ <xsl:otherwise>
467
+ <xsl:call-template name="ForceFalseStrVal">
468
+ <xsl:with-param name="str" select="$sLowerCaseZeroAscVal" />
469
+ </xsl:call-template>
470
+ </xsl:otherwise>
471
+ </xsl:choose>
472
+ </xsl:variable>
473
+ <xsl:variable name="fZeroDesc">
474
+ <xsl:choose>
475
+ <xsl:when test="count(m:phantPr[last()]/m:zeroDesc[last()]) = 0">0</xsl:when>
476
+ <xsl:otherwise>
477
+ <xsl:call-template name="ForceFalseStrVal">
478
+ <xsl:with-param name="str" select="$sLowerCaseZeroDescVal" />
479
+ </xsl:call-template>
480
+ </xsl:otherwise>
481
+ </xsl:choose>
482
+ </xsl:variable>
483
+
484
+ <!-- The show property defaults to 'on' unless there exists a show property and its value is 'off' -->
485
+
486
+ <xsl:variable name="fShow">
487
+ <xsl:call-template name="ForceFalseStrVal">
488
+ <xsl:with-param name="str" select="$sLowerCaseShowVal" />
489
+ </xsl:call-template>
490
+ </xsl:variable>
491
+
492
+ <xsl:choose>
493
+ <!-- Show the phantom contents, therefore, just use mpadded. -->
494
+ <xsl:when test="$fShow = 1">
495
+ <xsl:element name="mml:mpadded">
496
+ <xsl:call-template name="CreateMpaddedAttributes">
497
+ <xsl:with-param name="fZeroWid" select="$fZeroWid" />
498
+ <xsl:with-param name="fZeroAsc" select="$fZeroAsc" />
499
+ <xsl:with-param name="fZeroDesc" select="$fZeroDesc" />
500
+ </xsl:call-template>
501
+ <mml:mrow>
502
+ <xsl:apply-templates select="m:e" />
503
+ </mml:mrow>
504
+ </xsl:element>
505
+ </xsl:when>
506
+ <!-- Don't show phantom contents, but don't smash anything, therefore, just
507
+ use mphantom -->
508
+ <xsl:when test="$fZeroWid=0 and $fZeroAsc=0 and $fZeroDesc=0">
509
+ <xsl:element name="mml:mphantom">
510
+ <mml:mrow>
511
+ <xsl:apply-templates select="m:e" />
512
+ </mml:mrow>
513
+ </xsl:element>
514
+ </xsl:when>
515
+ <!-- Combination -->
516
+ <xsl:otherwise>
517
+ <xsl:element name="mml:mphantom">
518
+ <xsl:element name="mml:mpadded">
519
+ <xsl:call-template name="CreateMpaddedAttributes">
520
+ <xsl:with-param name="fZeroWid" select="$fZeroWid" />
521
+ <xsl:with-param name="fZeroAsc" select="$fZeroAsc" />
522
+ <xsl:with-param name="fZeroDesc" select="$fZeroDesc" />
523
+ </xsl:call-template>
524
+ <mml:mrow>
525
+ <xsl:apply-templates select="m:e" />
526
+ </mml:mrow>
527
+ </xsl:element>
528
+ </xsl:element>
529
+ </xsl:otherwise>
530
+ </xsl:choose>
531
+ </xsl:template>
532
+
533
+ <xsl:template name="CreateMpaddedAttributes">
534
+ <xsl:param name="fZeroWid" />
535
+ <xsl:param name="fZeroAsc" />
536
+ <xsl:param name="fZeroDesc" />
537
+
538
+ <xsl:if test="$fZeroWid=1">
539
+ <xsl:attribute name="width">0in</xsl:attribute>
540
+ </xsl:if>
541
+ <xsl:if test="$fZeroAsc=1">
542
+ <xsl:attribute name="height">0in</xsl:attribute>
543
+ </xsl:if>
544
+ <xsl:if test="$fZeroDesc=1">
545
+ <xsl:attribute name="depth">0in</xsl:attribute>
546
+ </xsl:if>
547
+ </xsl:template>
548
+
549
+
550
+
551
+ <xsl:template match="m:rad">
552
+ <xsl:variable name="fDegHide">
553
+ <xsl:choose>
554
+ <xsl:when test="count(m:radPr[last()]/m:degHide)=0">0</xsl:when>
555
+ <xsl:otherwise>
556
+ <xsl:call-template name="ForceFalseStrVal">
557
+ <xsl:with-param name="str" select="translate(m:radPr[last()]/m:degHide/@m:val,
558
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
559
+ 'abcdefghijklmnopqrstuvwxyz')" />
560
+ </xsl:call-template>
561
+ </xsl:otherwise>
562
+ </xsl:choose>
563
+ </xsl:variable>
564
+ <xsl:choose>
565
+ <xsl:when test="$fDegHide=1">
566
+ <mml:msqrt>
567
+ <xsl:apply-templates select="m:e[1]" />
568
+ </mml:msqrt>
569
+ </xsl:when>
570
+ <xsl:otherwise>
571
+ <mml:mroot>
572
+ <mml:mrow>
573
+ <xsl:apply-templates select="m:e[1]" />
574
+ </mml:mrow>
575
+ <mml:mrow>
576
+ <xsl:apply-templates select="m:deg[1]" />
577
+ </mml:mrow>
578
+ </mml:mroot>
579
+ </xsl:otherwise>
580
+ </xsl:choose>
581
+ </xsl:template>
582
+
583
+ <xsl:template name="OutputNaryMo">
584
+ <xsl:param name="ndCur" select="." />
585
+ <xsl:param name="fGrow" select="0" />
586
+ <mml:mo>
587
+ <xsl:choose>
588
+ <xsl:when test="$fGrow=1">
589
+ <xsl:attribute name="stretchy">true</xsl:attribute>
590
+ </xsl:when>
591
+ <xsl:otherwise>
592
+ <xsl:attribute name="stretchy">false</xsl:attribute>
593
+ </xsl:otherwise>
594
+ </xsl:choose>
595
+ <xsl:choose>
596
+ <xsl:when test="not($ndCur/m:naryPr[last()]/m:chr/@m:val) or
597
+ $ndCur/m:naryPr[last()]/m:chr/@m:val=''">
598
+ <xsl:text>&#x222b;</xsl:text>
599
+ </xsl:when>
600
+ <xsl:otherwise>
601
+ <xsl:value-of select="$ndCur/m:naryPr[last()]/m:chr/@m:val" />
602
+ </xsl:otherwise>
603
+ </xsl:choose>
604
+ </mml:mo>
605
+ </xsl:template>
606
+
607
+ <!-- %%Template match m:nary
608
+ Process an n-ary.
609
+
610
+ Decides, based on which arguments are supplied, between
611
+ using an mo, msup, msub, or msubsup for the n-ary operator
612
+ -->
613
+ <xsl:template match="m:nary">
614
+ <xsl:variable name="sLowerCaseSubHide">
615
+ <xsl:choose>
616
+ <xsl:when test="count(m:naryPr[last()]/m:subHide) = 0">
617
+ <xsl:text>off</xsl:text>
618
+ </xsl:when>
619
+ <xsl:otherwise>
620
+ <xsl:value-of select="translate(m:naryPr[last()]/m:subHide/@m:val,
621
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
622
+ 'abcdefghijklmnopqrstuvwxyz')" />
623
+ </xsl:otherwise>
624
+ </xsl:choose>
625
+ </xsl:variable>
626
+
627
+ <xsl:variable name="sLowerCaseSupHide">
628
+ <xsl:choose>
629
+ <xsl:when test="count(m:naryPr[last()]/m:supHide) = 0">
630
+ <xsl:text>off</xsl:text>
631
+ </xsl:when>
632
+ <xsl:otherwise>
633
+ <xsl:value-of select="translate(m:naryPr[last()]/m:supHide/@m:val,
634
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
635
+ 'abcdefghijklmnopqrstuvwxyz')" />
636
+ </xsl:otherwise>
637
+ </xsl:choose>
638
+ </xsl:variable>
639
+
640
+ <xsl:variable name="sLowerCaseLimLoc">
641
+ <xsl:value-of select="translate(m:naryPr[last()]/m:limLoc/@m:val,
642
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
643
+ 'abcdefghijklmnopqrstuvwxyz')" />
644
+ </xsl:variable>
645
+
646
+ <xsl:variable name="sLowerGrow">
647
+ <xsl:choose>
648
+ <xsl:when test="count(m:naryPr[last()]/m:grow)=0">off</xsl:when>
649
+ <xsl:otherwise>
650
+ <xsl:value-of select="translate(m:naryPr[last()]/m:grow/@m:val,
651
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
652
+ 'abcdefghijklmnopqrstuvwxyz')" />
653
+ </xsl:otherwise>
654
+ </xsl:choose>
655
+ </xsl:variable>
656
+
657
+ <xsl:variable name="fLimLocSubSup">
658
+ <xsl:choose>
659
+ <xsl:when test="count(m:naryPr[last()]/m:limLoc)=0 or $sLowerCaseLimLoc='subsup'">1</xsl:when>
660
+ <xsl:otherwise>0</xsl:otherwise>
661
+ </xsl:choose>
662
+ </xsl:variable>
663
+
664
+ <xsl:variable name="fGrow">
665
+ <xsl:call-template name="ForceFalseStrVal">
666
+ <xsl:with-param name="str" select="$sLowerGrow" />
667
+ </xsl:call-template>
668
+ </xsl:variable>
669
+
670
+ <xsl:variable name="fSupHide">
671
+ <xsl:call-template name="ForceFalseStrVal">
672
+ <xsl:with-param name="str" select="$sLowerCaseSupHide" />
673
+ </xsl:call-template>
674
+ </xsl:variable>
675
+
676
+ <xsl:variable name="fSubHide">
677
+ <xsl:call-template name="ForceFalseStrVal">
678
+ <xsl:with-param name="str" select="$sLowerCaseSubHide" />
679
+ </xsl:call-template>
680
+ </xsl:variable>
681
+
682
+ <mml:mrow>
683
+ <xsl:choose>
684
+ <xsl:when test="$fSupHide=1 and $fSubHide=1">
685
+ <xsl:call-template name="OutputNaryMo">
686
+ <xsl:with-param name="ndCur" select="." />
687
+ <xsl:with-param name="fGrow" select="$fGrow" />
688
+ </xsl:call-template>
689
+ </xsl:when>
690
+ <xsl:when test="$fSubHide=1">
691
+ <xsl:choose>
692
+ <xsl:when test="$fLimLocSubSup=1">
693
+ <mml:msup>
694
+ <xsl:call-template name="OutputNaryMo">
695
+ <xsl:with-param name="ndCur" select="." />
696
+ <xsl:with-param name="fGrow" select="$fGrow" />
697
+ </xsl:call-template>
698
+ <mml:mrow>
699
+ <xsl:apply-templates select="m:sup[1]" />
700
+ </mml:mrow>
701
+ </mml:msup>
702
+ </xsl:when>
703
+ <xsl:otherwise>
704
+ <mml:mover>
705
+ <xsl:call-template name="OutputNaryMo">
706
+ <xsl:with-param name="ndCur" select="." />
707
+ <xsl:with-param name="fGrow" select="$fGrow" />
708
+ </xsl:call-template>
709
+ <mml:mrow>
710
+ <xsl:apply-templates select="m:sup[1]" />
711
+ </mml:mrow>
712
+ </mml:mover>
713
+ </xsl:otherwise>
714
+ </xsl:choose>
715
+ </xsl:when>
716
+ <xsl:when test="$fSupHide=1">
717
+ <xsl:choose>
718
+ <xsl:when test="$fLimLocSubSup=1">
719
+ <mml:msub>
720
+ <xsl:call-template name="OutputNaryMo">
721
+ <xsl:with-param name="ndCur" select="." />
722
+ <xsl:with-param name="fGrow" select="$fGrow" />
723
+ </xsl:call-template>
724
+ <mml:mrow>
725
+ <xsl:apply-templates select="m:sub[1]" />
726
+ </mml:mrow>
727
+ </mml:msub>
728
+ </xsl:when>
729
+ <xsl:otherwise>
730
+ <mml:munder>
731
+ <xsl:call-template name="OutputNaryMo">
732
+ <xsl:with-param name="ndCur" select="." />
733
+ <xsl:with-param name="fGrow" select="$fGrow" />
734
+ </xsl:call-template>
735
+ <mml:mrow>
736
+ <xsl:apply-templates select="m:sub[1]" />
737
+ </mml:mrow>
738
+ </mml:munder>
739
+ </xsl:otherwise>
740
+ </xsl:choose>
741
+ </xsl:when>
742
+ <xsl:otherwise>
743
+ <xsl:choose>
744
+ <xsl:when test="$fLimLocSubSup=1">
745
+ <mml:msubsup>
746
+ <xsl:call-template name="OutputNaryMo">
747
+ <xsl:with-param name="ndCur" select="." />
748
+ <xsl:with-param name="fGrow" select="$fGrow" />
749
+ </xsl:call-template>
750
+ <mml:mrow>
751
+ <xsl:apply-templates select="m:sub[1]" />
752
+ </mml:mrow>
753
+ <mml:mrow>
754
+ <xsl:apply-templates select="m:sup[1]" />
755
+ </mml:mrow>
756
+ </mml:msubsup>
757
+ </xsl:when>
758
+ <xsl:otherwise>
759
+ <mml:munderover>
760
+ <xsl:call-template name="OutputNaryMo">
761
+ <xsl:with-param name="ndCur" select="." />
762
+ <xsl:with-param name="fGrow" select="$fGrow" />
763
+ </xsl:call-template>
764
+ <mml:mrow>
765
+ <xsl:apply-templates select="m:sub[1]" />
766
+ </mml:mrow>
767
+ <mml:mrow>
768
+ <xsl:apply-templates select="m:sup[1]" />
769
+ </mml:mrow>
770
+ </mml:munderover>
771
+ </xsl:otherwise>
772
+ </xsl:choose>
773
+ </xsl:otherwise>
774
+ </xsl:choose>
775
+ <mml:mrow>
776
+ <xsl:apply-templates select="m:e[1]" />
777
+ </mml:mrow>
778
+ </mml:mrow>
779
+ </xsl:template>
780
+
781
+ <xsl:template match="m:limLow">
782
+ <mml:munder>
783
+ <mml:mrow>
784
+ <xsl:apply-templates select="m:e[1]" />
785
+ </mml:mrow>
786
+ <mml:mrow>
787
+ <xsl:apply-templates select="m:lim[1]" />
788
+ </mml:mrow>
789
+ </mml:munder>
790
+ </xsl:template>
791
+
792
+ <xsl:template match="m:limUpp">
793
+ <mml:mover>
794
+ <mml:mrow>
795
+ <xsl:apply-templates select="m:e[1]" />
796
+ </mml:mrow>
797
+ <mml:mrow>
798
+ <xsl:apply-templates select="m:lim[1]" />
799
+ </mml:mrow>
800
+ </mml:mover>
801
+ </xsl:template>
802
+
803
+ <xsl:template match="m:sSub">
804
+ <mml:msub>
805
+ <mml:mrow>
806
+ <xsl:apply-templates select="m:e[1]" />
807
+ </mml:mrow>
808
+ <mml:mrow>
809
+ <xsl:apply-templates select="m:sub[1]" />
810
+ </mml:mrow>
811
+ </mml:msub>
812
+ </xsl:template>
813
+
814
+ <xsl:template match="m:sSup">
815
+ <mml:msup>
816
+ <mml:mrow>
817
+ <xsl:apply-templates select="m:e[1]" />
818
+ </mml:mrow>
819
+ <mml:mrow>
820
+ <xsl:apply-templates select="m:sup[1]" />
821
+ </mml:mrow>
822
+ </mml:msup>
823
+ </xsl:template>
824
+
825
+ <xsl:template match="m:sSubSup">
826
+ <mml:msubsup>
827
+ <mml:mrow>
828
+ <xsl:apply-templates select="m:e[1]" />
829
+ </mml:mrow>
830
+ <mml:mrow>
831
+ <xsl:apply-templates select="m:sub[1]" />
832
+ </mml:mrow>
833
+ <mml:mrow>
834
+ <xsl:apply-templates select="m:sup[1]" />
835
+ </mml:mrow>
836
+ </mml:msubsup>
837
+ </xsl:template>
838
+
839
+ <xsl:template match="m:groupChr">
840
+ <xsl:variable name="ndLastGroupChrPr" select="m:groupChrPr[last()]" />
841
+ <xsl:variable name="sLowerCasePos" select="translate($ndLastGroupChrPr/m:pos/@m:val,
842
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
843
+ 'abcdefghijklmnopqrstuvwxyz')" />
844
+
845
+ <xsl:variable name="sLowerCaseVertJc" select="translate($ndLastGroupChrPr/m:vertJc/@m:val,
846
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
847
+ 'abcdefghijklmnopqrstuvwxyz')" />
848
+ <xsl:variable name="ndLastChr" select="$ndLastGroupChrPr/m:chr" />
849
+
850
+ <xsl:variable name="chr">
851
+ <xsl:choose>
852
+ <xsl:when test="$ndLastChr and (not($ndLastChr/@m:val) or string-length($ndLastChr/@m:val) = 0)"></xsl:when>
853
+ <xsl:when test="string-length($ndLastChr/@m:val) &gt;= 1">
854
+ <xsl:value-of select="substring($ndLastChr/@m:val,1,1)" />
855
+ </xsl:when>
856
+ <xsl:otherwise>
857
+ <xsl:text>&#x023DF;</xsl:text>
858
+ </xsl:otherwise>
859
+ </xsl:choose>
860
+ </xsl:variable>
861
+ <xsl:choose>
862
+ <xsl:when test="$sLowerCasePos = 'top'">
863
+ <xsl:choose>
864
+ <xsl:when test="$sLowerCaseVertJc = 'bot'">
865
+ <mml:mover accent="false">
866
+ <mml:mrow>
867
+ <xsl:apply-templates select="m:e[1]" />
868
+ </mml:mrow>
869
+ <mml:mo>
870
+ <xsl:value-of select="$chr" />
871
+ </mml:mo>
872
+ </mml:mover>
873
+ </xsl:when>
874
+ <xsl:otherwise>
875
+ <mml:munder accentunder="false">
876
+ <mml:mo>
877
+ <xsl:value-of select="$chr" />
878
+ </mml:mo>
879
+ <mml:mrow>
880
+ <xsl:apply-templates select="m:e[1]" />
881
+ </mml:mrow>
882
+ </mml:munder>
883
+ </xsl:otherwise>
884
+ </xsl:choose>
885
+ </xsl:when>
886
+ <xsl:otherwise>
887
+ <xsl:choose>
888
+ <xsl:when test="$sLowerCaseVertJc = 'bot'">
889
+ <mml:mover accent="false">
890
+ <mml:mo>
891
+ <xsl:value-of select="$chr" />
892
+ </mml:mo>
893
+ <mml:mrow>
894
+ <xsl:apply-templates select="m:e[1]" />
895
+ </mml:mrow>
896
+ </mml:mover>
897
+ </xsl:when>
898
+ <xsl:otherwise>
899
+ <mml:munder accentunder="false">
900
+ <mml:mrow>
901
+ <xsl:apply-templates select="m:e[1]" />
902
+ </mml:mrow>
903
+ <mml:mo>
904
+ <xsl:value-of select="$chr" />
905
+ </mml:mo>
906
+ </mml:munder>
907
+ </xsl:otherwise>
908
+ </xsl:choose>
909
+ </xsl:otherwise>
910
+ </xsl:choose>
911
+ </xsl:template>
912
+
913
+ <xsl:template name="fName">
914
+ <xsl:for-each select="m:fName/*">
915
+ <xsl:apply-templates select="." />
916
+ </xsl:for-each>
917
+ </xsl:template>
918
+
919
+ <xsl:template match="m:func">
920
+ <mml:mrow>
921
+ <mml:mrow>
922
+ <xsl:call-template name="fName" />
923
+ </mml:mrow>
924
+ <mml:mo>&#x02061;</mml:mo>
925
+ <mml:mrow>
926
+ <xsl:apply-templates select="m:e" />
927
+ </mml:mrow>
928
+ </mml:mrow>
929
+ </xsl:template>
930
+
931
+ <!-- %%Template: match m:f
932
+
933
+ m:f maps directly to mfrac.
934
+ -->
935
+ <xsl:template match="m:f">
936
+ <xsl:variable name="sLowerCaseType" select="translate(m:fPr[last()]/m:type/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
937
+ <xsl:choose>
938
+ <xsl:when test="$sLowerCaseType='lin'">
939
+ <mml:mrow>
940
+ <mml:mrow>
941
+ <xsl:apply-templates select="m:num[1]" />
942
+ </mml:mrow>
943
+ <mml:mo>/</mml:mo>
944
+ <mml:mrow>
945
+ <xsl:apply-templates select="m:den[1]" />
946
+ </mml:mrow>
947
+ </mml:mrow>
948
+ </xsl:when>
949
+ <xsl:otherwise>
950
+ <mml:mfrac>
951
+ <xsl:call-template name="CreateMathMLFracProp">
952
+ <xsl:with-param name="type" select="$sLowerCaseType" />
953
+ </xsl:call-template>
954
+ <mml:mrow>
955
+ <xsl:apply-templates select="m:num[1]" />
956
+ </mml:mrow>
957
+ <mml:mrow>
958
+ <xsl:apply-templates select="m:den[1]" />
959
+ </mml:mrow>
960
+ </mml:mfrac>
961
+ </xsl:otherwise>
962
+ </xsl:choose>
963
+
964
+ </xsl:template>
965
+
966
+
967
+ <!-- %%Template: CreateMathMLFracProp
968
+
969
+ Make fraction properties based on supplied parameters.
970
+ OMML differentiates between a linear fraction and a skewed
971
+ one. For MathML, we write both as bevelled.
972
+ -->
973
+ <xsl:template name="CreateMathMLFracProp">
974
+ <xsl:param name="type" />
975
+ <xsl:variable name="sLowerCaseType" select="translate($type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')" />
976
+
977
+ <xsl:if test="$sLowerCaseType='skw' or $sLowerCaseType='lin'">
978
+ <xsl:attribute name="bevelled">true</xsl:attribute>
979
+ </xsl:if>
980
+ <xsl:if test="$sLowerCaseType='nobar'">
981
+ <xsl:attribute name="linethickness">0pt</xsl:attribute>
982
+ </xsl:if>
983
+ <xsl:choose>
984
+ <xsl:when test="sLowerCaseNumJc='right'">
985
+ <xsl:attribute name="numalign">right</xsl:attribute>
986
+ </xsl:when>
987
+ <xsl:when test="sLowerCaseNumJc='left'">
988
+ <xsl:attribute name="numalign">left</xsl:attribute>
989
+ </xsl:when>
990
+ </xsl:choose>
991
+ <xsl:choose>
992
+ <xsl:when test="sLowerCaseDenJc='right'">
993
+ <xsl:attribute name="numalign">right</xsl:attribute>
994
+ </xsl:when>
995
+ <xsl:when test="sLowerCaseDenJc='left'">
996
+ <xsl:attribute name="numalign">left</xsl:attribute>
997
+ </xsl:when>
998
+ </xsl:choose>
999
+ </xsl:template>
1000
+
1001
+ <!-- %%Template: match m:e | m:den | m:num | m:lim | m:sup | m:sub
1002
+
1003
+ These element delinate parts of an expression (like the numerator). -->
1004
+ <xsl:template match="m:e | m:den | m:num | m:lim | m:sup | m:sub">
1005
+ <xsl:choose>
1006
+
1007
+ <!-- If there is no scriptLevel specified, just call through -->
1008
+ <xsl:when test="not(m:argPr[last()]/m:scrLvl/@m:val)">
1009
+ <xsl:apply-templates select="*" />
1010
+ </xsl:when>
1011
+
1012
+ <!-- Otherwise, create an mstyle and set the script level -->
1013
+ <xsl:otherwise>
1014
+ <mml:mstyle>
1015
+ <xsl:attribute name="scriptlevel">
1016
+ <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val" />
1017
+ </xsl:attribute>
1018
+ <xsl:apply-templates select="*" />
1019
+ </mml:mstyle>
1020
+ </xsl:otherwise>
1021
+ </xsl:choose>
1022
+ </xsl:template>
1023
+
1024
+ <xsl:template match="m:bar">
1025
+ <xsl:variable name="sLowerCasePos" select="translate(m:barPr/m:pos/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1026
+ 'abcdefghijklmnopqrstuvwxyz')" />
1027
+
1028
+ <xsl:variable name="fTop">
1029
+
1030
+ <xsl:choose>
1031
+ <xsl:when test="$sLowerCasePos='top'">1</xsl:when>
1032
+ <xsl:otherwise>0</xsl:otherwise>
1033
+ </xsl:choose>
1034
+ </xsl:variable>
1035
+ <xsl:choose>
1036
+ <xsl:when test="$fTop=1">
1037
+ <mml:mover accent="false">
1038
+ <mml:mrow>
1039
+ <xsl:apply-templates select="m:e[1]" />
1040
+ </mml:mrow>
1041
+ <mml:mo>
1042
+ <xsl:text>&#x00AF;</xsl:text>
1043
+ </mml:mo>
1044
+ </mml:mover>
1045
+ </xsl:when>
1046
+ <xsl:otherwise>
1047
+ <mml:munder underaccent="false">
1048
+ <mml:mrow>
1049
+ <xsl:apply-templates select="m:e[1]" />
1050
+ </mml:mrow>
1051
+ <mml:mo>
1052
+ <xsl:text>&#x005F;</xsl:text>
1053
+ </mml:mo>
1054
+ </mml:munder>
1055
+ </xsl:otherwise>
1056
+ </xsl:choose>
1057
+ </xsl:template>
1058
+
1059
+ <!-- %%Template match m:d
1060
+
1061
+ Process a delimiter.
1062
+ -->
1063
+ <xsl:template match="m:d">
1064
+ <mml:mfenced>
1065
+ <!-- open: default is '(' for both OMML and MathML -->
1066
+ <xsl:if test="m:dPr[1]/m:begChr/@m:val and not(m:dPr[1]/m:begChr/@m:val ='(')">
1067
+ <xsl:attribute name="open">
1068
+ <xsl:value-of select="m:dPr[1]/m:begChr/@m:val" />
1069
+ </xsl:attribute>
1070
+ </xsl:if>
1071
+
1072
+ <!-- close: default is ')' for both OMML and MathML -->
1073
+ <xsl:if test="m:dPr[1]/m:endChr/@m:val and not(m:dPr[1]/m:endChr/@m:val =')')">
1074
+ <xsl:attribute name="close">
1075
+ <xsl:value-of select="m:dPr[1]/m:endChr/@m:val" />
1076
+ </xsl:attribute>
1077
+ </xsl:if>
1078
+
1079
+ <!-- separator: the default is ',' for MathML, and '|' for OMML -->
1080
+ <xsl:choose>
1081
+ <!-- Matches MathML default. Write nothing -->
1082
+ <xsl:when test="m:dPr[1]/m:sepChr/@m:val = ','" />
1083
+
1084
+ <!-- OMML default: | -->
1085
+ <xsl:when test="not(m:dPr[1]/m:sepChr/@m:val)">
1086
+ <xsl:attribute name="separators">
1087
+ <xsl:value-of select="'|'" />
1088
+ </xsl:attribute>
1089
+ </xsl:when>
1090
+
1091
+ <xsl:otherwise>
1092
+ <xsl:attribute name="separators">
1093
+ <xsl:value-of select="m:dPr[1]/m:sepChr/@m:val" />
1094
+ </xsl:attribute>
1095
+ </xsl:otherwise>
1096
+ </xsl:choose>
1097
+
1098
+ <!-- now write all the children. Put each one into an mrow
1099
+ just in case it produces multiple runs, etc -->
1100
+ <xsl:for-each select="m:e">
1101
+ <mml:mrow>
1102
+ <xsl:apply-templates select="." />
1103
+ </mml:mrow>
1104
+ </xsl:for-each>
1105
+ </mml:mfenced>
1106
+ </xsl:template>
1107
+
1108
+ <xsl:template match="m:r">
1109
+ <xsl:variable name="fNor">
1110
+ <xsl:choose>
1111
+ <xsl:when test="count(child::m:rPr[last()]/m:nor) = 0">0</xsl:when>
1112
+ <xsl:otherwise>
1113
+ <xsl:call-template name="ForceFalseStrVal">
1114
+ <xsl:with-param name="str" select="translate(child::m:rPr[last()]/m:nor/@m:val, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1115
+ 'abcdefghijklmnopqrstuvwxyz')" />
1116
+ </xsl:call-template>
1117
+ </xsl:otherwise>
1118
+ </xsl:choose>
1119
+ </xsl:variable>
1120
+
1121
+ <xsl:choose>
1122
+ <xsl:when test="$fNor=1">
1123
+ <mml:mtext>
1124
+ <xsl:variable name="sOutput" select="translate(.//m:t, ' ', '&#xa0;')" />
1125
+ <xsl:value-of select="$sOutput" />
1126
+ </mml:mtext>
1127
+ </xsl:when>
1128
+ <xsl:otherwise>
1129
+ <xsl:for-each select=".//m:t">
1130
+ <xsl:call-template name="ParseMt">
1131
+ <xsl:with-param name="sToParse" select="text()" />
1132
+ <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val" />
1133
+ <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val" />
1134
+ <xsl:with-param name="nor">0</xsl:with-param>
1135
+ </xsl:call-template>
1136
+ </xsl:for-each>
1137
+ </xsl:otherwise>
1138
+ </xsl:choose>
1139
+ </xsl:template>
1140
+
1141
+
1142
+ <xsl:template name="CreateTokenAttributes">
1143
+ <xsl:param name="scr" />
1144
+ <xsl:param name="sty" />
1145
+ <xsl:param name="nor" />
1146
+ <xsl:param name="nCharToPrint" />
1147
+ <xsl:param name="sTokenType" />
1148
+
1149
+ <xsl:choose>
1150
+ <xsl:when test="$nor=1">
1151
+ <xsl:attribute name="mathvariant">normal</xsl:attribute>
1152
+ </xsl:when>
1153
+ <xsl:otherwise>
1154
+ <xsl:variable name="mathvariant">
1155
+ <xsl:choose>
1156
+ <!-- numbers don't care -->
1157
+ <xsl:when test="$sTokenType='mn'" />
1158
+
1159
+ <xsl:when test="$scr='monospace'">monospace</xsl:when>
1160
+ <xsl:when test="$scr='sans-serif' and $sty='i'">sans-serif-italic</xsl:when>
1161
+ <xsl:when test="$scr='sans-serif' and $sty='b'">bold-sans-serif</xsl:when>
1162
+ <xsl:when test="$scr='sans-serif' and $sty='bi'">sans-serif-bold-italic</xsl:when>
1163
+ <xsl:when test="$scr='sans-serif'">sans-serif</xsl:when>
1164
+ <xsl:when test="$scr='fraktur' and ($sty='b' or $sty='bi')">bold-fraktur</xsl:when>
1165
+ <xsl:when test="$scr='fraktur'">fraktur</xsl:when>
1166
+ <xsl:when test="$scr='double-struck'">double-struck</xsl:when>
1167
+ <xsl:when test="$scr='script' and ($sty='b' or $sty='bi')">bold-script</xsl:when>
1168
+ <xsl:when test="$scr='script'">script</xsl:when>
1169
+ <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='b'">bold</xsl:when>
1170
+ <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='i'">italic</xsl:when>
1171
+ <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='p'">normal</xsl:when>
1172
+ <xsl:when test="($scr='roman' or not($scr) or $scr='') and $sty='bi'">bold-italic</xsl:when>
1173
+ <xsl:otherwise />
1174
+ </xsl:choose>
1175
+ </xsl:variable>
1176
+ <xsl:variable name="fontweight">
1177
+ <xsl:choose>
1178
+ <xsl:when test="$sty='b' or $sty='bi'">bold</xsl:when>
1179
+ <xsl:otherwise>normal</xsl:otherwise>
1180
+ </xsl:choose>
1181
+ </xsl:variable>
1182
+ <xsl:variable name="fontstyle">
1183
+ <xsl:choose>
1184
+ <xsl:when test="$sty='p' or $sty='b'">normal</xsl:when>
1185
+ <xsl:otherwise>italic</xsl:otherwise>
1186
+ </xsl:choose>
1187
+ </xsl:variable>
1188
+
1189
+ <!-- Writing of attributes begins here -->
1190
+ <xsl:choose>
1191
+ <!-- Don't write mathvariant for operators unless they want to be normal -->
1192
+ <xsl:when test="$sTokenType='mo' and $mathvariant!='normal'" />
1193
+
1194
+ <!-- A single character within an mi is already italics, don't write -->
1195
+ <xsl:when test="$sTokenType='mi' and $nCharToPrint=1 and ($mathvariant='' or $mathvariant='italic')" />
1196
+
1197
+ <xsl:when test="$sTokenType='mi' and $nCharToPrint &gt; 1 and ($mathvariant='' or $mathvariant='italic')">
1198
+ <xsl:attribute name="mathvariant">
1199
+ <xsl:value-of select="'italic'" />
1200
+ </xsl:attribute>
1201
+ </xsl:when>
1202
+ <xsl:when test="$mathvariant!='italic' and $mathvariant!=''">
1203
+ <xsl:attribute name="mathvariant">
1204
+ <xsl:value-of select="$mathvariant" />
1205
+ </xsl:attribute>
1206
+ </xsl:when>
1207
+ <xsl:otherwise>
1208
+ <xsl:if test="not($sTokenType='mi' and $nCharToPrint=1) and $fontstyle='italic'">
1209
+ <xsl:attribute name="fontstyle">italic</xsl:attribute>
1210
+ </xsl:if>
1211
+ <xsl:if test="$fontweight='bold'">
1212
+ <xsl:attribute name="fontweight">bold</xsl:attribute>
1213
+ </xsl:if>
1214
+ </xsl:otherwise>
1215
+ </xsl:choose>
1216
+ </xsl:otherwise>
1217
+ </xsl:choose>
1218
+ </xsl:template>
1219
+
1220
+ <xsl:template match="m:eqArr">
1221
+ <mml:mtable>
1222
+ <xsl:for-each select="m:e">
1223
+ <mml:mtr>
1224
+ <mml:mtd>
1225
+ <xsl:choose>
1226
+ <xsl:when test="m:argPr[last()]/m:scrLvl/@m:val!='0' or
1227
+ not(m:argPr[last()]/m:scrLvl/@m:val) or
1228
+ m:argPr[last()]/m:scrLvl/@m:val=''">
1229
+ <mml:mrow>
1230
+ <mml:maligngroup />
1231
+ <xsl:call-template name="CreateEqArrRow">
1232
+ <xsl:with-param name="align" select="1" />
1233
+ <xsl:with-param name="ndCur" select="*[1]" />
1234
+ </xsl:call-template>
1235
+ </mml:mrow>
1236
+ </xsl:when>
1237
+ <xsl:otherwise>
1238
+ <mml:mstyle>
1239
+ <xsl:attribute name="scriptlevel">
1240
+ <xsl:value-of select="m:argPr[last()]/m:scrLvl/@m:val" />
1241
+ </xsl:attribute>
1242
+ <mml:maligngroup />
1243
+ <xsl:call-template name="CreateEqArrRow">
1244
+ <xsl:with-param name="align" select="1" />
1245
+ <xsl:with-param name="ndCur" select="*[1]" />
1246
+ </xsl:call-template>
1247
+ </mml:mstyle>
1248
+ </xsl:otherwise>
1249
+ </xsl:choose>
1250
+ </mml:mtd>
1251
+ </mml:mtr>
1252
+ </xsl:for-each>
1253
+ </mml:mtable>
1254
+ </xsl:template>
1255
+
1256
+ <xsl:template name="CreateEqArrRow">
1257
+ <xsl:param name="align" />
1258
+ <xsl:param name="ndCur" />
1259
+ <xsl:variable name="sAllMt">
1260
+ <xsl:for-each select="$ndCur/m:t">
1261
+ <xsl:value-of select="." />
1262
+ </xsl:for-each>
1263
+ </xsl:variable>
1264
+ <xsl:choose>
1265
+ <xsl:when test="$ndCur/self::m:r">
1266
+ <xsl:call-template name="ParseEqArrMr">
1267
+ <xsl:with-param name="sToParse" select="$sAllMt" />
1268
+ <xsl:with-param name="scr" select="../m:rPr[last()]/m:scr/@m:val" />
1269
+ <xsl:with-param name="sty" select="../m:rPr[last()]/m:sty/@m:val" />
1270
+ <xsl:with-param name="nor">
1271
+ <xsl:choose>
1272
+ <xsl:when test="count($ndCur/m:rPr[last()]/m:nor) = 0">0</xsl:when>
1273
+ <xsl:otherwise>
1274
+ <xsl:call-template name="ForceFalseStrVal">
1275
+ <xsl:with-param name="str" select="translate($ndCur/m:rPr[last()]/m:nor/@m:val,
1276
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1277
+ 'abcdefghijklmnopqrstuvwxyz')" />
1278
+ </xsl:call-template>
1279
+ </xsl:otherwise>
1280
+ </xsl:choose>
1281
+ </xsl:with-param>
1282
+ <xsl:with-param name="align" select="$align" />
1283
+ </xsl:call-template>
1284
+ </xsl:when>
1285
+ <xsl:otherwise>
1286
+ <xsl:apply-templates select="$ndCur" />
1287
+ </xsl:otherwise>
1288
+ </xsl:choose>
1289
+ <xsl:if test="count($ndCur/following-sibling::*) &gt; 0">
1290
+ <xsl:variable name="cAmp">
1291
+ <xsl:call-template name="CountAmp">
1292
+ <xsl:with-param name="sAllMt" select="$sAllMt" />
1293
+ <xsl:with-param name="cAmp" select="0" />
1294
+ </xsl:call-template>
1295
+ </xsl:variable>
1296
+ <xsl:call-template name="CreateEqArrRow">
1297
+ <xsl:with-param name="align" select="($align+($cAmp mod 2)) mod 2" />
1298
+ <xsl:with-param name="ndCur" select="$ndCur/following-sibling::*[1]" />
1299
+ </xsl:call-template>
1300
+ </xsl:if>
1301
+ </xsl:template>
1302
+
1303
+ <xsl:template name="CountAmp">
1304
+ <xsl:param name="sAllMt" />
1305
+ <xsl:param name="cAmp" />
1306
+ <xsl:choose>
1307
+ <xsl:when test="string-length(substring-after($sAllMt, '&amp;')) &gt; 0 or
1308
+ substring($sAllMt, string-length($sAllMt))='&#x0026;'">
1309
+ <xsl:call-template name="CountAmp">
1310
+ <xsl:with-param name="sAllMt" select="substring-after($sAllMt, '&#x0026;')" />
1311
+ <xsl:with-param name="cAmp" select="$cAmp+1" />
1312
+ </xsl:call-template>
1313
+ </xsl:when>
1314
+ <xsl:otherwise>
1315
+ <xsl:value-of select="$cAmp" />
1316
+ </xsl:otherwise>
1317
+ </xsl:choose>
1318
+ </xsl:template>
1319
+
1320
+ <!-- %%Template: ParseEqArrMr
1321
+
1322
+ Similar to ParseMt, but this one has to do more for an equation array.
1323
+ In equation arrays &amp; is a special character which denotes alignment.
1324
+
1325
+ The &amp; in an equation works by alternating between meaning insert alignment spacing
1326
+ and insert alignment mark. For each equation in the equation array
1327
+ there is an implied align space at the beginning of the equation. Within each equation,
1328
+ the first &amp; means alignmark, the second, align space, the third, alignmark, etc.
1329
+
1330
+ For this reason when parsing m:r's in equation arrays it is important to keep track of what
1331
+ the next ampersand will mean.
1332
+
1333
+ $align=0 => Omml's align space, which is similar to MathML's maligngroup.
1334
+ $align=1 => Omml's alignment mark, which is similar to MathML's malignmark.
1335
+ -->
1336
+ <xsl:template name="ParseEqArrMr">
1337
+ <xsl:param name="sToParse" />
1338
+ <xsl:param name="sty" />
1339
+ <xsl:param name="scr" />
1340
+ <xsl:param name="nor" />
1341
+ <xsl:param name="align" />
1342
+
1343
+ <xsl:if test="string-length($sToParse) &gt; 0">
1344
+ <xsl:choose>
1345
+ <xsl:when test="substring($sToParse,1,1) = '&amp;'">
1346
+ <xsl:choose>
1347
+ <xsl:when test="$align='0'">
1348
+ <mml:maligngroup />
1349
+ </xsl:when>
1350
+ <xsl:when test="$align='1'">
1351
+ <mml:malignmark />
1352
+ </xsl:when>
1353
+ </xsl:choose>
1354
+ <xsl:call-template name="ParseEqArrMr">
1355
+ <xsl:with-param name="sToParse" select="substring($sToParse,2)" />
1356
+ <xsl:with-param name="scr" select="$scr" />
1357
+ <xsl:with-param name="sty" select="$sty" />
1358
+ <xsl:with-param name="nor" select="$nor" />
1359
+ <xsl:with-param name="align">
1360
+ <xsl:choose>
1361
+ <xsl:when test="$align='1'">0</xsl:when>
1362
+ <xsl:otherwise>1</xsl:otherwise>
1363
+ </xsl:choose>
1364
+ </xsl:with-param>
1365
+ </xsl:call-template>
1366
+ </xsl:when>
1367
+ <xsl:otherwise>
1368
+ <xsl:variable name="sRepNumWith0">
1369
+ <xsl:call-template name="SReplaceNumWithZero">
1370
+ <xsl:with-param name="sToParse" select="$sToParse" />
1371
+ </xsl:call-template>
1372
+ </xsl:variable>
1373
+ <xsl:variable name="sRepOperWith-">
1374
+ <xsl:call-template name="SReplaceOperWithMinus">
1375
+ <xsl:with-param name="sToParse" select="$sRepNumWith0" />
1376
+ </xsl:call-template>
1377
+ </xsl:variable>
1378
+
1379
+ <xsl:variable name="iFirstOper" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))" />
1380
+ <xsl:variable name="iFirstNum" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))" />
1381
+ <xsl:variable name="iFirstAmp" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '&#x0026;'))" />
1382
+ <xsl:variable name="fNumAtPos1">
1383
+ <xsl:choose>
1384
+ <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1385
+ <xsl:otherwise>0</xsl:otherwise>
1386
+ </xsl:choose>
1387
+ </xsl:variable>
1388
+ <xsl:variable name="fOperAtPos1">
1389
+ <xsl:choose>
1390
+ <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1391
+ <xsl:otherwise>0</xsl:otherwise>
1392
+ </xsl:choose>
1393
+ </xsl:variable>
1394
+ <xsl:choose>
1395
+
1396
+ <!-- Case I: The string begins with neither a number, nor an operator -->
1397
+ <xsl:when test="$fNumAtPos1='0' and $fOperAtPos1='0'">
1398
+ <xsl:choose>
1399
+ <xsl:when test="$nor = 0">
1400
+ <mml:mi>
1401
+ <xsl:call-template name="CreateTokenAttributes">
1402
+ <xsl:with-param name="scr" select="$scr" />
1403
+ <xsl:with-param name="sty" select="$sty" />
1404
+ <xsl:with-param name="nor" select="$nor" />
1405
+ <xsl:with-param name="nCharToPrint" select="1" />
1406
+ <xsl:with-param name="sTokenType" select="'mi'" />
1407
+ </xsl:call-template>
1408
+ <xsl:variable name="sOutput" select="translate(substring($sToParse, 1, 1), ' ', '&#xa0;')" />
1409
+ <xsl:value-of select="$sOutput" />
1410
+ </mml:mi>
1411
+ </xsl:when>
1412
+ <xsl:otherwise>
1413
+ <mml:mtext>
1414
+ <xsl:variable name="sOutput" select="translate(substring($sToParse, 1, 1), ' ', '&#xa0;')" />
1415
+ <xsl:value-of select="$sOutput" />
1416
+ </mml:mtext>
1417
+ </xsl:otherwise>
1418
+ </xsl:choose>
1419
+ <xsl:call-template name="ParseEqArrMr">
1420
+ <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1421
+ <xsl:with-param name="scr" select="$scr" />
1422
+ <xsl:with-param name="sty" select="$sty" />
1423
+ <xsl:with-param name="nor" select="$nor" />
1424
+ <xsl:with-param name="align" select="$align" />
1425
+ </xsl:call-template>
1426
+ </xsl:when>
1427
+
1428
+ <!-- Case II: There is an operator at position 1 -->
1429
+ <xsl:when test="$fOperAtPos1='1'">
1430
+ <xsl:choose>
1431
+ <xsl:when test="$nor = 0">
1432
+ <mml:mo>
1433
+ <xsl:call-template name="CreateTokenAttributes">
1434
+ <xsl:with-param name="scr" />
1435
+ <xsl:with-param name="sty" />
1436
+ <xsl:with-param name="nor" select="$nor" />
1437
+ <xsl:with-param name="sTokenType" select="'mo'" />
1438
+ </xsl:call-template>
1439
+ <xsl:value-of select="substring($sToParse,1,1)" />
1440
+ </mml:mo>
1441
+ </xsl:when>
1442
+ <xsl:otherwise>
1443
+ <mml:mtext>
1444
+ <xsl:value-of select="substring($sToParse,1,1)" />
1445
+ </mml:mtext>
1446
+ </xsl:otherwise>
1447
+ </xsl:choose>
1448
+ <xsl:call-template name="ParseEqArrMr">
1449
+ <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1450
+ <xsl:with-param name="scr" select="$scr" />
1451
+ <xsl:with-param name="sty" select="$sty" />
1452
+ <xsl:with-param name="nor" select="$nor" />
1453
+ <xsl:with-param name="align" select="$align" />
1454
+ </xsl:call-template>
1455
+ </xsl:when>
1456
+
1457
+ <!-- Case III: There is a number at position 1 -->
1458
+ <xsl:otherwise>
1459
+ <xsl:variable name="sConsecNum">
1460
+ <xsl:call-template name="SNumStart">
1461
+ <xsl:with-param name="sToParse" select="$sToParse" />
1462
+ <xsl:with-param name="sPattern" select="$sRepNumWith0" />
1463
+ </xsl:call-template>
1464
+ </xsl:variable>
1465
+ <xsl:choose>
1466
+ <xsl:when test="$nor = 0">
1467
+ <mml:mn>
1468
+ <xsl:call-template name="CreateTokenAttributes">
1469
+ <xsl:with-param name="scr" />
1470
+ <xsl:with-param name="sty" select="'p'"/>
1471
+ <xsl:with-param name="nor" select="$nor" />
1472
+ <xsl:with-param name="sTokenType" select="'mn'" />
1473
+ </xsl:call-template>
1474
+ <xsl:value-of select="$sConsecNum" />
1475
+ </mml:mn>
1476
+ </xsl:when>
1477
+ <xsl:otherwise>
1478
+ <mml:mtext>
1479
+ <xsl:value-of select="$sConsecNum" />
1480
+ </mml:mtext>
1481
+ </xsl:otherwise>
1482
+ </xsl:choose>
1483
+ <xsl:call-template name="ParseEqArrMr">
1484
+ <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)" />
1485
+ <xsl:with-param name="scr" select="$scr" />
1486
+ <xsl:with-param name="sty" select="$sty" />
1487
+ <xsl:with-param name="nor" select="$nor" />
1488
+ <xsl:with-param name="align" select="$align" />
1489
+ </xsl:call-template>
1490
+ </xsl:otherwise>
1491
+ </xsl:choose>
1492
+ </xsl:otherwise>
1493
+ </xsl:choose>
1494
+ </xsl:if>
1495
+ </xsl:template>
1496
+
1497
+ <!-- %%Template: ParseMt
1498
+
1499
+ Produce a run of text. Technically, OMML makes no distinction
1500
+ between numbers, operators, and other characters in a run. For
1501
+ MathML we need to break these into mi, mn, or mo elements.
1502
+
1503
+ See also ParseEqArrMr
1504
+ -->
1505
+ <xsl:template name="ParseMt">
1506
+ <xsl:param name="sToParse" />
1507
+ <xsl:param name="sty" />
1508
+ <xsl:param name="scr" />
1509
+ <xsl:param name="nor" />
1510
+ <xsl:if test="string-length($sToParse) &gt; 0">
1511
+ <xsl:variable name="sRepNumWith0">
1512
+ <xsl:call-template name="SReplaceNumWithZero">
1513
+ <xsl:with-param name="sToParse" select="$sToParse" />
1514
+ </xsl:call-template>
1515
+ </xsl:variable>
1516
+ <xsl:variable name="sRepOperWith-">
1517
+ <xsl:call-template name="SReplaceOperWithMinus">
1518
+ <xsl:with-param name="sToParse" select="$sRepNumWith0" />
1519
+ </xsl:call-template>
1520
+ </xsl:variable>
1521
+
1522
+ <xsl:variable name="iFirstOper" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '-'))" />
1523
+ <xsl:variable name="iFirstNum" select="string-length($sRepOperWith-) - string-length(substring-after($sRepOperWith-, '0'))" />
1524
+ <xsl:variable name="fNumAtPos1">
1525
+ <xsl:choose>
1526
+ <xsl:when test="substring($sRepOperWith-,1,1)='0'">1</xsl:when>
1527
+ <xsl:otherwise>0</xsl:otherwise>
1528
+ </xsl:choose>
1529
+ </xsl:variable>
1530
+ <xsl:variable name="fOperAtPos1">
1531
+ <xsl:choose>
1532
+ <xsl:when test="substring($sRepOperWith-,1,1)='-'">1</xsl:when>
1533
+ <xsl:otherwise>0</xsl:otherwise>
1534
+ </xsl:choose>
1535
+ </xsl:variable>
1536
+
1537
+ <xsl:choose>
1538
+
1539
+ <!-- Case I: The string begins with neither a number, nor an operator -->
1540
+ <xsl:when test="$fOperAtPos1='0' and $fNumAtPos1='0'">
1541
+ <xsl:variable name="nCharToPrint">
1542
+ <xsl:choose>
1543
+ <xsl:when test="ancestor::m:fName">
1544
+ <xsl:choose>
1545
+ <xsl:when test="($iFirstOper=$iFirstNum) and
1546
+ ($iFirstOper=string-length($sToParse)) and
1547
+ (substring($sRepOperWith-, string-length($sRepOperWith-))!='0') and
1548
+ (substring($sRepOperWith-, string-length($sRepOperWith-))!='-')">
1549
+ <xsl:value-of select="string-length($sToParse)" />
1550
+ </xsl:when>
1551
+ <xsl:when test="$iFirstOper &lt; $iFirstNum">
1552
+ <xsl:value-of select="$iFirstOper - 1" />
1553
+ </xsl:when>
1554
+ <xsl:otherwise>
1555
+ <xsl:value-of select="$iFirstNum - 1" />
1556
+ </xsl:otherwise>
1557
+ </xsl:choose>
1558
+ </xsl:when>
1559
+ <xsl:otherwise>1</xsl:otherwise>
1560
+ </xsl:choose>
1561
+ </xsl:variable>
1562
+
1563
+ <mml:mi>
1564
+ <xsl:call-template name="CreateTokenAttributes">
1565
+ <xsl:with-param name="scr" select="$scr" />
1566
+ <xsl:with-param name="sty" select="$sty" />
1567
+ <xsl:with-param name="nor" select="$nor" />
1568
+ <xsl:with-param name="nCharToPrint" select="$nCharToPrint" />
1569
+ <xsl:with-param name="sTokenType" select="'mi'" />
1570
+ </xsl:call-template>
1571
+ <xsl:variable name="sWrite" select="translate(substring($sToParse, 1, $nCharToPrint), ' ', '&#xa0;')" />
1572
+ <xsl:value-of select="$sWrite" />
1573
+ </mml:mi>
1574
+ <xsl:call-template name="ParseMt">
1575
+ <xsl:with-param name="sToParse" select="substring($sToParse, $nCharToPrint+1)" />
1576
+ <xsl:with-param name="scr" select="$scr" />
1577
+ <xsl:with-param name="sty" select="$sty" />
1578
+ <xsl:with-param name="nor" select="$nor" />
1579
+ </xsl:call-template>
1580
+ </xsl:when>
1581
+
1582
+ <!-- Case II: There is an operator at position 1 -->
1583
+ <xsl:when test="$fOperAtPos1='1'">
1584
+ <mml:mo>
1585
+ <xsl:call-template name="CreateTokenAttributes">
1586
+ <xsl:with-param name="scr" />
1587
+ <xsl:with-param name="sty" />
1588
+ <xsl:with-param name="nor" select="$nor" />
1589
+ <xsl:with-param name="sTokenType" select="'mo'" />
1590
+ </xsl:call-template>
1591
+ <xsl:value-of select="substring($sToParse,1,1)" />
1592
+ </mml:mo>
1593
+ <xsl:call-template name="ParseMt">
1594
+ <xsl:with-param name="sToParse" select="substring($sToParse, 2)" />
1595
+ <xsl:with-param name="scr" select="$scr" />
1596
+ <xsl:with-param name="sty" select="$sty" />
1597
+ <xsl:with-param name="nor" select="$nor" />
1598
+ </xsl:call-template>
1599
+ </xsl:when>
1600
+
1601
+ <!-- Case III: There is a number at position 1 -->
1602
+ <xsl:otherwise>
1603
+ <xsl:variable name="sConsecNum">
1604
+ <xsl:call-template name="SNumStart">
1605
+ <xsl:with-param name="sToParse" select="$sToParse" />
1606
+ <xsl:with-param name="sPattern" select="$sRepNumWith0" />
1607
+ </xsl:call-template>
1608
+ </xsl:variable>
1609
+ <mml:mn>
1610
+ <xsl:call-template name="CreateTokenAttributes">
1611
+ <xsl:with-param name="scr" select="$scr" />
1612
+ <xsl:with-param name="sty" select="'p'" />
1613
+ <xsl:with-param name="nor" select="$nor" />
1614
+ <xsl:with-param name="sTokenType" select="'mn'" />
1615
+ </xsl:call-template>
1616
+ <xsl:value-of select="$sConsecNum" />
1617
+ </mml:mn>
1618
+ <xsl:call-template name="ParseMt">
1619
+ <xsl:with-param name="sToParse" select="substring-after($sToParse, $sConsecNum)" />
1620
+ <xsl:with-param name="scr" select="$scr" />
1621
+ <xsl:with-param name="sty" select="$sty" />
1622
+ <xsl:with-param name="nor" select="$nor" />
1623
+ </xsl:call-template>
1624
+ </xsl:otherwise>
1625
+ </xsl:choose>
1626
+ </xsl:if>
1627
+ </xsl:template>
1628
+
1629
+ <!-- %%Template: SNumStart
1630
+
1631
+ Return the longest substring of sToParse starting from the
1632
+ start of sToParse that is a number. In addition, it takes the
1633
+ pattern string, which is sToParse with all of its numbers
1634
+ replaced with a 0. sPattern should be the same length
1635
+ as sToParse
1636
+ -->
1637
+ <xsl:template name="SNumStart">
1638
+ <xsl:param name="sToParse" select="''" />
1639
+ <!-- if we don't get anything, take the string itself -->
1640
+ <xsl:param name="sPattern" select="'$sToParse'" />
1641
+
1642
+
1643
+ <xsl:choose>
1644
+ <!-- the pattern says this is a number, recurse with the rest -->
1645
+ <xsl:when test="substring($sPattern, 1, 1) = '0'">
1646
+ <xsl:call-template name="SNumStart">
1647
+ <xsl:with-param name="sToParse" select="$sToParse" />
1648
+ <xsl:with-param name="sPattern" select="substring($sPattern, 2)" />
1649
+ </xsl:call-template>
1650
+ </xsl:when>
1651
+
1652
+ <!-- the pattern says we've run out of numbers. Take as many
1653
+ characters from sToParse as we shaved off sPattern -->
1654
+ <xsl:otherwise>
1655
+ <xsl:value-of select="substring($sToParse, 1, string-length($sToParse) - string-length($sPattern))" />
1656
+ </xsl:otherwise>
1657
+ </xsl:choose>
1658
+ </xsl:template>
1659
+
1660
+ <!-- %%Template SRepeatCharAcc
1661
+
1662
+ The core of SRepeatChar with an accumulator. The current
1663
+ string is in param $acc, and we will double and recurse,
1664
+ if we're less than half of the required length or else just
1665
+ add the right amount of characters to the accumulator and
1666
+ return
1667
+ -->
1668
+ <xsl:template name="SRepeatCharAcc">
1669
+ <xsl:param name="cchRequired" select="1" />
1670
+ <xsl:param name="ch" select="'-'" />
1671
+ <xsl:param name="acc" select="$ch" />
1672
+
1673
+ <xsl:variable name="cchAcc" select="string-length($acc)" />
1674
+ <xsl:choose>
1675
+ <xsl:when test="(2 * $cchAcc) &lt; $cchRequired">
1676
+ <xsl:call-template name="SRepeatCharAcc">
1677
+ <xsl:with-param name="cchRequired" select="$cchRequired" />
1678
+ <xsl:with-param name="ch" select="$ch" />
1679
+ <xsl:with-param name="acc" select="concat($acc, $acc)" />
1680
+ </xsl:call-template>
1681
+ </xsl:when>
1682
+
1683
+ <xsl:otherwise>
1684
+ <xsl:value-of select="concat($acc, substring($acc, 1, $cchRequired - $cchAcc))" />
1685
+ </xsl:otherwise>
1686
+ </xsl:choose>
1687
+ </xsl:template>
1688
+
1689
+
1690
+ <!-- %%Template SRepeatChar
1691
+
1692
+ Generates a string nchRequired long by repeating the given character ch
1693
+ -->
1694
+ <xsl:template name="SRepeatChar">
1695
+ <xsl:param name="cchRequired" select="1" />
1696
+ <xsl:param name="ch" select="'-'" />
1697
+
1698
+ <xsl:call-template name="SRepeatCharAcc">
1699
+ <xsl:with-param name="cchRequired" select="$cchRequired" />
1700
+ <xsl:with-param name="ch" select="$ch" />
1701
+ <xsl:with-param name="acc" select="$ch" />
1702
+ </xsl:call-template>
1703
+ </xsl:template>
1704
+
1705
+ <!-- %%Template SReplaceOperWithMinus
1706
+
1707
+ Go through the given string and replace every instance
1708
+ of an operator with a minus '-'. This helps quickly identify
1709
+ the first instance of an operator.
1710
+ -->
1711
+ <xsl:template name="SReplaceOperWithMinus">
1712
+ <xsl:param name="sToParse" select="''" />
1713
+
1714
+ <xsl:value-of select="translate($sToParse, $sOperators, $sMinuses)" />
1715
+ </xsl:template>
1716
+
1717
+ <!-- %%Template SReplaceNumWithZero
1718
+
1719
+ Go through the given string and replace every instance
1720
+ of an number with a zero '0'. This helps quickly identify
1721
+ the first occurence of a number.
1722
+
1723
+ Considers the '.' and ',' part of a number iff they are sandwiched
1724
+ between two other numbers. 0.3 will be recognized as a number,
1725
+ x.3 will not be. Since these characters can also be an operator, this
1726
+ should be called before SReplaceOperWithMinus.
1727
+ -->
1728
+ <xsl:template name="SReplaceNumWithZero">
1729
+ <xsl:param name="sToParse" select="''" />
1730
+
1731
+ <!-- First do a simple replace. Numbers will all be come 0's.
1732
+ After this point, the pattern involving the . or , that
1733
+ we are looking for will become 0.0 or 0,0 -->
1734
+ <xsl:variable name="sSimpleReplace" select="translate($sToParse, $sNumbers, $sZeros)" />
1735
+
1736
+ <!-- And then, replace 0.0 with just 000. This means that the . will
1737
+ become part of the number -->
1738
+ <xsl:variable name="sReplacePeriod">
1739
+ <xsl:call-template name="SReplace">
1740
+ <xsl:with-param name="sInput" select="$sSimpleReplace" />
1741
+ <xsl:with-param name="sOrig" select="'0.0'" />
1742
+ <xsl:with-param name="sReplacement" select="'000'" />
1743
+ </xsl:call-template>
1744
+ </xsl:variable>
1745
+
1746
+ <!-- And then, replace 0,0 with just 000. This means that the , will
1747
+ become part of the number -->
1748
+ <xsl:call-template name="SReplace">
1749
+ <xsl:with-param name="sInput" select="$sReplacePeriod" />
1750
+ <xsl:with-param name="sOrig" select="'0,0'" />
1751
+ <xsl:with-param name="sReplacement" select="'000'" />
1752
+ </xsl:call-template>
1753
+ </xsl:template>
1754
+
1755
+ <!-- Template to translate Word's borderBox properties into the menclose notation attribute
1756
+ The initial call to this SHOULD NOT pass an sAttribute. Subsequent calls to
1757
+ CreateMencloseNotationAttrFromBorderBoxAttr by CreateMencloseNotationAttrFromBorderBoxAttr will
1758
+ update the sAttribute as appropriate.
1759
+
1760
+ CreateMencloseNotationAttrFromBorderBoxAttr looks at each attribute (fHideTop, fHideBot, etc.) one at a time
1761
+ in the order they are listed and passes a modified sAttribute to CreateMencloseNotationAttrFromBorderBoxAttr.
1762
+ Each successive call to CreateMencloseNotationAttrFromBorderBoxAttr knows which attribute to look at because
1763
+ the previous call should have omitted passing the attribute it just analyzed. This is why as you read lower
1764
+ and lower in the template that each call to CreateMencloseNotationAttrFromBorderBoxAttr has fewer and fewer attributes.
1765
+ -->
1766
+ <xsl:template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1767
+ <xsl:param name="fHideTop" />
1768
+ <xsl:param name="fHideBot" />
1769
+ <xsl:param name="fHideLeft" />
1770
+ <xsl:param name="fHideRight" />
1771
+ <xsl:param name="fStrikeH" />
1772
+ <xsl:param name="fStrikeV" />
1773
+ <xsl:param name="fStrikeBLTR" />
1774
+ <xsl:param name="fStrikeTLBR" />
1775
+ <xsl:param name="sAttribute" />
1776
+
1777
+ <xsl:choose>
1778
+ <xsl:when test="string-length($sAttribute) = 0">
1779
+ <xsl:choose>
1780
+ <xsl:when test="string-length($fHideTop) &gt; 0
1781
+ and string-length($fHideBot) &gt; 0
1782
+ and string-length($fHideLeft) &gt; 0
1783
+ and string-length($fHideRight) &gt; 0">
1784
+
1785
+ <xsl:choose>
1786
+ <xsl:when test="$fHideTop = 0
1787
+ and $fHideBot = 0
1788
+ and $fHideLeft = 0
1789
+ and $fHideRight = 0">
1790
+ <!-- We can use 'box' instead of top, bot, left, and right. Therefore,
1791
+ replace sAttribute with 'box' and begin analyzing params fStrikeH
1792
+ and below. -->
1793
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1794
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1795
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1796
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1797
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1798
+ <xsl:with-param name="sAttribute">
1799
+ <xsl:text>box</xsl:text>
1800
+ </xsl:with-param>
1801
+ </xsl:call-template>
1802
+ </xsl:when>
1803
+ <xsl:otherwise>
1804
+ <!-- Can't use 'box', theremore, must analyze all attributes -->
1805
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1806
+ <xsl:with-param name="fHideTop" select="$fHideTop" />
1807
+ <xsl:with-param name="fHideBot" select="$fHideBot" />
1808
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1809
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1810
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1811
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1812
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1813
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1814
+ <xsl:with-param name="sAttribute">
1815
+ <!-- Assume using all four (left right top bottom). Subsequent calls
1816
+ will remove the sides which aren't to be includes. -->
1817
+ <xsl:text>left right top bottom</xsl:text>
1818
+ </xsl:with-param>
1819
+ </xsl:call-template>
1820
+ </xsl:otherwise>
1821
+ </xsl:choose>
1822
+ </xsl:when>
1823
+ </xsl:choose>
1824
+ </xsl:when>
1825
+ <xsl:otherwise>
1826
+ <xsl:choose>
1827
+ <xsl:when test="string-length($fHideTop) &gt; 0">
1828
+ <xsl:choose>
1829
+ <xsl:when test="$fHideTop=1">
1830
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1831
+ <xsl:with-param name="fHideBot" select="$fHideBot" />
1832
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1833
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1834
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1835
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1836
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1837
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1838
+ <xsl:with-param name="sAttribute">
1839
+ <xsl:call-template name="SReplace">
1840
+ <xsl:with-param name="sInput" select="$sAttribute" />
1841
+ <xsl:with-param name="sOrig" select="'top'" />
1842
+ <xsl:with-param name="sReplacement" select="''" />
1843
+ </xsl:call-template>
1844
+ </xsl:with-param>
1845
+ </xsl:call-template>
1846
+ </xsl:when>
1847
+ <xsl:otherwise>
1848
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1849
+ <xsl:with-param name="fHideBot" select="$fHideBot" />
1850
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1851
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1852
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1853
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1854
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1855
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1856
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1857
+ </xsl:call-template>
1858
+ </xsl:otherwise>
1859
+ </xsl:choose>
1860
+ </xsl:when>
1861
+ <xsl:when test="string-length($fHideBot) &gt; 0">
1862
+ <xsl:choose>
1863
+ <xsl:when test="$fHideBot=1">
1864
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1865
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1866
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1867
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1868
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1869
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1870
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1871
+ <xsl:with-param name="sAttribute">
1872
+ <xsl:call-template name="SReplace">
1873
+ <xsl:with-param name="sInput" select="$sAttribute" />
1874
+ <xsl:with-param name="sOrig" select="'bottom'" />
1875
+ <xsl:with-param name="sReplacement" select="''" />
1876
+ </xsl:call-template>
1877
+ </xsl:with-param>
1878
+ </xsl:call-template>
1879
+ </xsl:when>
1880
+ <xsl:otherwise>
1881
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1882
+ <xsl:with-param name="fHideLeft" select="$fHideLeft" />
1883
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1884
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1885
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1886
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1887
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1888
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1889
+ </xsl:call-template>
1890
+ </xsl:otherwise>
1891
+ </xsl:choose>
1892
+ </xsl:when>
1893
+ <xsl:when test="string-length($fHideLeft) &gt; 0">
1894
+ <xsl:choose>
1895
+ <xsl:when test="$fHideLeft=1">
1896
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1897
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1898
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1899
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1900
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1901
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1902
+ <xsl:with-param name="sAttribute">
1903
+ <xsl:call-template name="SReplace">
1904
+ <xsl:with-param name="sInput" select="$sAttribute" />
1905
+ <xsl:with-param name="sOrig" select="'left'" />
1906
+ <xsl:with-param name="sReplacement" select="''" />
1907
+ </xsl:call-template>
1908
+ </xsl:with-param>
1909
+ </xsl:call-template>
1910
+ </xsl:when>
1911
+ <xsl:otherwise>
1912
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1913
+ <xsl:with-param name="fHideRight" select="$fHideRight" />
1914
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1915
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1916
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1917
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1918
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1919
+ </xsl:call-template>
1920
+ </xsl:otherwise>
1921
+ </xsl:choose>
1922
+ </xsl:when>
1923
+ <xsl:when test="string-length($fHideRight) &gt; 0">
1924
+ <xsl:choose>
1925
+ <xsl:when test="$fHideRight=1">
1926
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1927
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1928
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1929
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1930
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1931
+ <xsl:with-param name="sAttribute">
1932
+ <xsl:call-template name="SReplace">
1933
+ <xsl:with-param name="sInput" select="$sAttribute" />
1934
+ <xsl:with-param name="sOrig" select="'right'" />
1935
+ <xsl:with-param name="sReplacement" select="''" />
1936
+ </xsl:call-template>
1937
+ </xsl:with-param>
1938
+ </xsl:call-template>
1939
+ </xsl:when>
1940
+ <xsl:otherwise>
1941
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1942
+ <xsl:with-param name="fStrikeH" select="$fStrikeH" />
1943
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1944
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1945
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1946
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1947
+ </xsl:call-template>
1948
+ </xsl:otherwise>
1949
+ </xsl:choose>
1950
+ </xsl:when>
1951
+ <xsl:when test="string-length($fStrikeH) &gt; 0">
1952
+ <xsl:choose>
1953
+ <xsl:when test="$fStrikeH=1">
1954
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1955
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1956
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1957
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1958
+ <xsl:with-param name="sAttribute" select="concat($sAttribute, ' horizontalstrike')" />
1959
+ </xsl:call-template>
1960
+ </xsl:when>
1961
+ <xsl:otherwise>
1962
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1963
+ <xsl:with-param name="fStrikeV" select="$fStrikeV" />
1964
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1965
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1966
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1967
+ </xsl:call-template>
1968
+ </xsl:otherwise>
1969
+ </xsl:choose>
1970
+ </xsl:when>
1971
+ <xsl:when test="string-length($fStrikeV) &gt; 0">
1972
+ <xsl:choose>
1973
+ <xsl:when test="$fStrikeV=1">
1974
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1975
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1976
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1977
+ <xsl:with-param name="sAttribute" select="concat($sAttribute, ' verticalstrike')" />
1978
+ </xsl:call-template>
1979
+ </xsl:when>
1980
+ <xsl:otherwise>
1981
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1982
+ <xsl:with-param name="fStrikeBLTR" select="$fStrikeBLTR" />
1983
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1984
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
1985
+ </xsl:call-template>
1986
+ </xsl:otherwise>
1987
+ </xsl:choose>
1988
+ </xsl:when>
1989
+ <xsl:when test="string-length($fStrikeBLTR) &gt; 0">
1990
+ <xsl:choose>
1991
+ <xsl:when test="$fStrikeBLTR=1">
1992
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1993
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
1994
+ <xsl:with-param name="sAttribute" select="concat($sAttribute, ' updiagonalstrike')" />
1995
+ </xsl:call-template>
1996
+ </xsl:when>
1997
+ <xsl:otherwise>
1998
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
1999
+ <xsl:with-param name="fStrikeTLBR" select="$fStrikeTLBR" />
2000
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
2001
+ </xsl:call-template>
2002
+ </xsl:otherwise>
2003
+ </xsl:choose>
2004
+ </xsl:when>
2005
+ <xsl:when test="string-length($fStrikeTLBR) &gt; 0">
2006
+ <xsl:choose>
2007
+ <xsl:when test="$fStrikeTLBR=1">
2008
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
2009
+ <xsl:with-param name="sAttribute" select="concat($sAttribute, ' downdiagonalstrike')" />
2010
+ </xsl:call-template>
2011
+ </xsl:when>
2012
+ <xsl:otherwise>
2013
+ <xsl:call-template name="CreateMencloseNotationAttrFromBorderBoxAttr">
2014
+ <xsl:with-param name="sAttribute" select="$sAttribute" />
2015
+ </xsl:call-template>
2016
+ </xsl:otherwise>
2017
+ </xsl:choose>
2018
+ </xsl:when>
2019
+ <xsl:otherwise>
2020
+ <xsl:attribute name="notation">
2021
+ <xsl:value-of select="normalize-space($sAttribute)" />
2022
+ </xsl:attribute>
2023
+ </xsl:otherwise>
2024
+ </xsl:choose>
2025
+ </xsl:otherwise>
2026
+ </xsl:choose>
2027
+ </xsl:template>
2028
+
2029
+ <!-- Tristate (true, false, neither) from string value -->
2030
+ <xsl:template name="TFromStrVal">
2031
+ <xsl:param name="str" />
2032
+ <xsl:choose>
2033
+ <xsl:when test="$str = 'on' or $str = '1' or $str = 'true'">1</xsl:when>
2034
+ <xsl:when test="$str = 'off' or $str = '0' or $str = 'false'">0</xsl:when>
2035
+ <xsl:otherwise>-1</xsl:otherwise>
2036
+ </xsl:choose>
2037
+ </xsl:template>
2038
+
2039
+ <!-- Return 0 iff $str is explicitly set to a false value.
2040
+ Return true otherwise -->
2041
+ <xsl:template name="ForceFalseStrVal">
2042
+ <xsl:param name="str" />
2043
+ <xsl:variable name="tValue">
2044
+ <xsl:call-template name="TFromStrVal">
2045
+ <xsl:with-param name="str" select="$str"/>
2046
+ </xsl:call-template>
2047
+ </xsl:variable>
2048
+ <xsl:choose>
2049
+ <xsl:when test="$tValue = '0'">0</xsl:when>
2050
+ <xsl:otherwise>1</xsl:otherwise>
2051
+ </xsl:choose>
2052
+ </xsl:template>
2053
+
2054
+ <!-- Return 1 iff $str is explicitly set to a true value.
2055
+ Return false otherwise -->
2056
+ <xsl:template name="ForceTrueStrVal">
2057
+ <xsl:param name="str" />
2058
+ <xsl:variable name="tValue">
2059
+ <xsl:call-template name="TFromStrVal">
2060
+ <xsl:with-param name="str" select="$str"/>
2061
+ </xsl:call-template>
2062
+ </xsl:variable>
2063
+ <xsl:choose>
2064
+ <xsl:when test="$tValue = '1'">1</xsl:when>
2065
+ <xsl:otherwise>0</xsl:otherwise>
2066
+ </xsl:choose>
2067
+ </xsl:template>
2068
+ </xsl:stylesheet>