OMML2MML.XSL 91 KB

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