mmlctop.xsl 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165
  1. <?xml version="1.0"?>
  2. <!-- ******************************************************** -->
  3. <!-- XSL Transform of MathML content to MathML presentation -->
  4. <!-- Version 1.0 RC2 from 13-Jun-2003 -->
  5. <!-- -->
  6. <!-- Complies with the W3C MathML 2.0 Recommenation of -->
  7. <!-- 21 February 2001. -->
  8. <!-- -->
  9. <!-- Authors Igor Rodionov <igor@csd.uwo.ca>, -->
  10. <!-- Stephen Watt <watt@csd.uwo.ca>. -->
  11. <!-- -->
  12. <!-- (C) Copyright 2000-2003 Symbolic Computation Laboratory, -->
  13. <!-- University of Western Ontario, -->
  14. <!-- London, Canada N6A 5B7. -->
  15. <!-- -->
  16. <!-- Modified: Fabian Seoane <fabian@fseoane> 2007 for sympy -->
  17. <!-- ******************************************************** -->
  18. <xsl:stylesheet id="mmlctop2.xsl"
  19. version="1.0"
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. xmlns:mml="http://www.w3.org/1998/Math/MathML"
  22. xmlns="http://www.w3.org/1998/Math/MathML">
  23. <xsl:output method="xml" indent="yes"/>
  24. <xsl:strip-space elements="apply semantics annotation-xml
  25. csymbol fn cn ci interval matrix matrixrow vector
  26. lambda bvar condition logbase degree set list
  27. lowlimit uplimit math"/>
  28. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  29. <!-- Parameters, variables and constants -->
  30. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  31. <!-- ~~~~~~~~ Semantics related *constants*: ~~~~~~~~ -->
  32. <!-- Strip off semantics -->
  33. <xsl:variable name="SEM_STRIP" select="-1"/>
  34. <!-- Pass semantics "as is" -->
  35. <xsl:variable name="SEM_PASS" select="0"/>
  36. <!-- Add semantics at top level only -->
  37. <xsl:variable name="SEM_TOP" select="1"/>
  38. <!-- Add semantics at all levels -->
  39. <xsl:variable name="SEM_ALL" select="2"/>
  40. <!-- Semantics at top level only, with id refs -->
  41. <!-- NOTE: ids have to be already present in the
  42. input for this feature to work. -->
  43. <xsl:variable name="SEM_XREF" select="3"/>
  44. <!-- No semantics at top level, with id refs -->
  45. <!-- NOTE: ids have to be already present in the
  46. input for this feature to work. -->
  47. <xsl:variable name="SEM_XREF_EXT" select="4"/>
  48. <!-- ~~~~~~~~~~ Stylesheet *parameter*: SEM_SW ~~~~~~~~~~~~~~ -->
  49. <!-- Assumes one of the above values; SEM_PASS is the default -->
  50. <!-- The default can be overridden by specifying different -->
  51. <!-- value on the command line when the stylesheet is invoked -->
  52. <xsl:param name="SEM_SW" select="SEM_PASS"/>
  53. <!-- ~~~~~~ Operator precedence definitions ~~~~~~ -->
  54. <xsl:variable name="NO_PREC" select="0"/>
  55. <xsl:variable name="UNION_PREC" select="1"/>
  56. <xsl:variable name="SETDIFF_PREC" select="1"/>
  57. <xsl:variable name="INTERSECT_PREC" select="3"/>
  58. <xsl:variable name="CARTPROD_PREC" select="3"/>
  59. <xsl:variable name="OR_PREC" select="5"/>
  60. <xsl:variable name="XOR_PREC" select="7"/>
  61. <xsl:variable name="AND_PREC" select="9"/>
  62. <xsl:variable name="NOT_PREC" select="11"/>
  63. <xsl:variable name="PLUS_PREC" select="13"/>
  64. <xsl:variable name="MINUS_PREC" select="13"/>
  65. <xsl:variable name="NEG_PREC" select="15"/>
  66. <xsl:variable name="MUL_PREC" select="17"/>
  67. <xsl:variable name="DIV_PREC" select="17"/>
  68. <xsl:variable name="REM_PREC" select="17"/>
  69. <xsl:variable name="FUNCTN_PREC" select="97"/>
  70. <xsl:variable name="GEN_FUN_PREC" select="99"/>
  71. <!-- ~~~~~ Miscellaneous constant definitions ~~~~~ -->
  72. <xsl:variable name="YES" select="1"/>
  73. <xsl:variable name="NO" select="0"/>
  74. <xsl:variable name="NO_PARAM" select="-1"/>
  75. <xsl:variable name="PAR_SAME" select="-3"/>
  76. <xsl:variable name="PAR_YES" select="-5"/>
  77. <xsl:variable name="PAR_NO" select="-7"/>
  78. <!-- +++++++++++++++++ INDEX OF TEMPLATES +++++++++++++++++++ -->
  79. <!-- All templates are subdivided into the following categories
  80. (listed in the order of appearance in the stylesheet):
  81. THE TOPMOST ELEMENT: MATH
  82. math
  83. SEMANTICS HANDLING
  84. semantics
  85. BASIC CONTAINER ELEMENTS
  86. cn, ci; csymbol
  87. BASIC CONTENT ELEMENTS
  88. fn, interval, inverse, sep, condition, declare, lambda, compose,
  89. ident; domain, codomain, image, domainofapplication, piecewise
  90. ARITHMETIC, ALGEBRA & LOGIC
  91. quotient, exp, factorial, max, min, minus, plus, power, rem, divide,
  92. times, root, gcd, and, or, xor, not, forall, exists, abs, conjugate;
  93. arg, real, imaginary, lcm, floor, ceiling
  94. RELATIONS
  95. neq, approx, tendsto, implies, in, notin, notsubset, notprsubset,
  96. subset, prsubset, eq, gt, lt, geq, leq; equivalent, factorof
  97. CALCULUS
  98. ln, log, diff, partialdiff, lowlimit, uplimit, bvar, degree,
  99. logbase; divergence, grad, curl, laplacian
  100. SET THEORY
  101. set, list, union, intersect, setdiff; card, cartesianproduct
  102. SEQUENCES AND SERIES
  103. sum, product, limit
  104. TRIGONOMETRY
  105. sin, cos, tan, sec, csc, cot, sinh, cosh, tanh, sech, csch, coth,
  106. arcsin, arccos, arctan, arcsec, arccsc, arccot, arcsinh, arccosh,
  107. arctanh, arcsech, arccsch, arccoth
  108. STATISTICS
  109. mean, sdev, variance, median, mode, moment, momentabout
  110. LINEAR ALGEBRA
  111. vector, matrix, matrixrow, determinant, transpose, selector;
  112. vectorproduct, scalarproduct, outerproduct
  113. CONSTANT and SYMBOL ELEMENTS
  114. integers, reals, rationals, naturalnumbers, complexes, primes,
  115. exponentiale, imaginaryi, notanumber, true, false, emptyset,
  116. pi, eulergamma, infinity
  117. -->
  118. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  119. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~ TEMPLATES ~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  120. <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
  121. <!-- *********************** COPY THROUGH ************************ -->
  122. <xsl:template match = "*">
  123. <xsl:copy>
  124. <xsl:copy-of select="@*"/>
  125. <xsl:apply-templates/>
  126. </xsl:copy>
  127. </xsl:template>
  128. <!-- ***************** THE TOPMOST ELEMENT: MATH ***************** -->
  129. <xsl:template match = "math">
  130. <math>
  131. <xsl:copy-of select="@*"/>
  132. <xsl:choose>
  133. <xsl:when test="$SEM_SW=$SEM_TOP or $SEM_SW=$SEM_ALL and *[2] or
  134. $SEM_SW=$SEM_XREF">
  135. <semantics>
  136. <mrow>
  137. <xsl:apply-templates mode = "semantics"/>
  138. </mrow>
  139. <annotation-xml encoding="MathML">
  140. <xsl:copy-of select="*"/>
  141. </annotation-xml>
  142. </semantics>
  143. </xsl:when>
  144. <xsl:otherwise>
  145. <xsl:apply-templates mode = "semantics"/>
  146. </xsl:otherwise>
  147. </xsl:choose>
  148. </math>
  149. </xsl:template>
  150. <!-- ***************** SEMANTICS HANDLING ***************** -->
  151. <!-- This template is called recursively. At each level -->
  152. <!-- in the source tree it decides whether to strip off, -->
  153. <!-- pass or add semantics at that level (depending on the -->
  154. <!-- value of SEM_SW parameter). Then the actual template -->
  155. <!-- is applied to the node. -->
  156. <xsl:template match = "*" mode = "semantics">
  157. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  158. <xsl:param name="PARAM" select="$NO_PARAM"/>
  159. <xsl:param name="PAREN" select="$PAR_NO"/>
  160. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  161. <xsl:choose>
  162. <xsl:when test="$SEM_SW=$SEM_STRIP and self::semantics">
  163. <xsl:apply-templates select="annotation-xml[@encoding='MathML']">
  164. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  165. <xsl:with-param name="PARAM" select="$PARAM"/>
  166. <xsl:with-param name="PAREN" select="$PAREN"/>
  167. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  168. </xsl:apply-templates>
  169. </xsl:when>
  170. <xsl:when test="($SEM_SW=$SEM_PASS or $SEM_SW=$SEM_TOP) and self::semantics">
  171. <semantics>
  172. <xsl:apply-templates select="*[1]">
  173. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  174. <xsl:with-param name="PARAM" select="$PARAM"/>
  175. <xsl:with-param name="PAREN" select="$PAREN"/>
  176. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  177. </xsl:apply-templates>
  178. <xsl:copy-of select="annotation-xml"/>
  179. </semantics>
  180. </xsl:when>
  181. <xsl:when test="$SEM_SW=$SEM_ALL">
  182. <semantics>
  183. <xsl:choose>
  184. <xsl:when test="self::semantics">
  185. <xsl:apply-templates select="*[1]">
  186. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  187. <xsl:with-param name="PARAM" select="$PARAM"/>
  188. <xsl:with-param name="PAREN" select="$PAREN"/>
  189. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  190. </xsl:apply-templates>
  191. <xsl:copy-of select="annotation-xml"/>
  192. </xsl:when>
  193. <xsl:otherwise>
  194. <xsl:apply-templates select=".">
  195. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  196. <xsl:with-param name="PARAM" select="$PARAM"/>
  197. <xsl:with-param name="PAREN" select="$PAREN"/>
  198. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  199. </xsl:apply-templates>
  200. <annotation-xml encoding="MathML">
  201. <xsl:copy-of select="."/>
  202. </annotation-xml>
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. </semantics>
  206. </xsl:when>
  207. <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  208. <xsl:choose>
  209. <xsl:when test="self::semantics">
  210. <xsl:copy>
  211. <xsl:copy-of select="@*"/>
  212. <xsl:attribute name="xref">
  213. <xsl:value-of select="@id"/>
  214. </xsl:attribute>
  215. <xsl:copy-of select="*[1]"/>
  216. <xsl:copy-of select="annotation-xml"/>
  217. </xsl:copy>
  218. </xsl:when>
  219. <xsl:otherwise>
  220. <xsl:apply-templates select=".">
  221. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  222. <xsl:with-param name="PARAM" select="$PARAM"/>
  223. <xsl:with-param name="PAREN" select="$PAREN"/>
  224. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  225. </xsl:apply-templates>
  226. </xsl:otherwise>
  227. </xsl:choose>
  228. </xsl:when>
  229. <xsl:otherwise>
  230. <xsl:apply-templates select=".">
  231. <xsl:with-param name="IN_PREC" select="$IN_PREC"/>
  232. <xsl:with-param name="PARAM" select="$PARAM"/>
  233. <xsl:with-param name="PAREN" select="$PAREN"/>
  234. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  235. </xsl:apply-templates>
  236. </xsl:otherwise>
  237. </xsl:choose>
  238. </xsl:template>
  239. <xsl:template match = "semantics">
  240. <xsl:apply-templates select="*[1]" mode = "semantics"/>
  241. </xsl:template>
  242. <!-- ***************** BASIC CONTAINER ELEMENTS ***************** -->
  243. <xsl:template match = "cn">
  244. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  245. <xsl:param name="PAREN" select="$PAR_NO"/>
  246. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  247. <xsl:choose>
  248. <xsl:when test=". &lt; 0 and $IN_PREC &gt; $NO_PREC and $PAREN=$PAR_NO
  249. and $PAR_NO_IGNORE=$NO">
  250. <mfenced separators="">
  251. <xsl:apply-templates select="." mode="cn"/>
  252. </mfenced>
  253. </xsl:when>
  254. <xsl:otherwise>
  255. <xsl:apply-templates select="." mode="cn"/>
  256. </xsl:otherwise>
  257. </xsl:choose>
  258. </xsl:template>
  259. <xsl:template match = "cn" mode="cn">
  260. <xsl:choose>
  261. <xsl:when test="(not(@type) or @type='integer' or @type='real') and @base">
  262. <msub>
  263. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  264. <xsl:attribute name="xref">
  265. <xsl:value-of select="@id"/>
  266. </xsl:attribute>
  267. </xsl:if>
  268. <mn> <xsl:apply-templates mode = "semantics"/> </mn>
  269. <mn> <xsl:value-of select="@base"/> </mn>
  270. </msub>
  271. </xsl:when>
  272. <xsl:when test="not(@type) or @type='integer' or @type='real'">
  273. <mn>
  274. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  275. <xsl:attribute name="xref">
  276. <xsl:value-of select="@id"/>
  277. </xsl:attribute>
  278. </xsl:if>
  279. <xsl:apply-templates mode = "semantics"/>
  280. </mn>
  281. </xsl:when>
  282. <xsl:when test="@type='constant'">
  283. <mn>
  284. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  285. <xsl:attribute name="xref">
  286. <xsl:value-of select="@id"/>
  287. </xsl:attribute>
  288. </xsl:if>
  289. <xsl:apply-templates mode = "semantics"/>
  290. </mn>
  291. </xsl:when>
  292. <xsl:when test="@type='e-notation' and not(@base) and child::sep[1]">
  293. <mrow>
  294. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  295. <xsl:attribute name="xref">
  296. <xsl:value-of select="@id"/>
  297. </xsl:attribute>
  298. </xsl:if>
  299. <mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </mn>
  300. <mo> e </mo>
  301. <mn> <xsl:apply-templates select="text()[2]" mode = "semantics"/> </mn>
  302. </mrow>
  303. </xsl:when>
  304. <xsl:when test="@type='complex-cartesian' and not(@base) and child::sep[1]">
  305. <mfenced separators="">
  306. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  307. <xsl:attribute name="xref">
  308. <xsl:value-of select="@id"/>
  309. </xsl:attribute>
  310. </xsl:if>
  311. <mn> <xsl:apply-templates select="text()[1]" mode = "semantics"/> </mn>
  312. <xsl:if test="text()[2] &lt; 0">
  313. <mo> - </mo>
  314. <mn> <xsl:value-of select="-text()[2]"/> </mn>
  315. </xsl:if>
  316. <xsl:if test="not(text()[2] &lt; 0)">
  317. <mo> + </mo>
  318. <mn> <xsl:value-of select="text()[2]"/> </mn>
  319. </xsl:if>
  320. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2062;</xsl:text> </mo>
  321. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2148;</xsl:text> </mo>
  322. </mfenced>
  323. </xsl:when>
  324. <xsl:when test="@type='complex-cartesian' and @base and child::sep[1]">
  325. <msub>
  326. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  327. <xsl:attribute name="xref">
  328. <xsl:value-of select="@id"/>
  329. </xsl:attribute>
  330. </xsl:if>
  331. <mfenced separators="">
  332. <mn> <xsl:apply-templates select="text()[1]"/> </mn>
  333. <xsl:if test="text()[2] &lt; 0">
  334. <mo> - </mo>
  335. <mn> <xsl:value-of select="-text()[2]"/> </mn>
  336. </xsl:if>
  337. <xsl:if test="not(text()[2] &lt; 0)">
  338. <mo> + </mo>
  339. <mn> <xsl:apply-templates select="text()[2]"/> </mn>
  340. </xsl:if>
  341. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2062;</xsl:text> </mo>
  342. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2148;</xsl:text> </mo>
  343. </mfenced>
  344. <mn> <xsl:value-of select="@base"/> </mn>
  345. </msub>
  346. </xsl:when>
  347. <xsl:when test="@type='rational' and not(@base) and child::sep[1]">
  348. <mfrac>
  349. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  350. <xsl:attribute name="xref">
  351. <xsl:value-of select="@id"/>
  352. </xsl:attribute>
  353. </xsl:if>
  354. <mn> <xsl:apply-templates select="text()[1]"/> </mn>
  355. <mn> <xsl:apply-templates select="text()[2]"/> </mn>
  356. </mfrac>
  357. </xsl:when>
  358. <xsl:when test="@type='rational' and @base and child::sep[1]">
  359. <msub>
  360. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  361. <xsl:attribute name="xref">
  362. <xsl:value-of select="@id"/>
  363. </xsl:attribute>
  364. </xsl:if>
  365. <mfenced>
  366. <mfrac>
  367. <mn> <xsl:apply-templates select="text()[1]"/> </mn>
  368. <mn> <xsl:apply-templates select="text()[2]"/> </mn>
  369. </mfrac>
  370. </mfenced>
  371. <mn> <xsl:value-of select="@base"/> </mn>
  372. </msub>
  373. </xsl:when>
  374. <xsl:when test="@type='complex-polar' and not(@base) and child::sep[1]">
  375. <mrow>
  376. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  377. <xsl:attribute name="xref">
  378. <xsl:value-of select="@id"/>
  379. </xsl:attribute>
  380. </xsl:if>
  381. <mo> Polar </mo>
  382. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2062;</xsl:text> </mo>
  383. <mfenced separators=",">
  384. <mn> <xsl:apply-templates select="text()[1]"/> </mn>
  385. <mn> <xsl:apply-templates select="text()[2]"/> </mn>
  386. </mfenced>
  387. </mrow>
  388. </xsl:when>
  389. <xsl:when test="@type='complex-polar' and @base and child::sep[1]">
  390. <msub>
  391. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  392. <xsl:attribute name="xref">
  393. <xsl:value-of select="@id"/>
  394. </xsl:attribute>
  395. </xsl:if>
  396. <mrow>
  397. <mo> Polar </mo>
  398. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2062;</xsl:text> </mo>
  399. <mfenced separators=",">
  400. <mn> <xsl:apply-templates select="text()[1]"/> </mn>
  401. <mn> <xsl:apply-templates select="text()[2]"/> </mn>
  402. </mfenced>
  403. </mrow>
  404. <mn> <xsl:value-of select="@base"/> </mn>
  405. </msub>
  406. </xsl:when>
  407. <xsl:otherwise>
  408. <mn> <xsl:apply-templates mode = "semantics"/> </mn>
  409. </xsl:otherwise>
  410. </xsl:choose>
  411. </xsl:template>
  412. <xsl:template match = "ci">
  413. <xsl:choose>
  414. <xsl:when test="@type='vector' or @type='matrix' or @type='set'">
  415. <mi mathvariant="bold">
  416. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  417. <xsl:attribute name="xref">
  418. <xsl:value-of select="@id"/>
  419. </xsl:attribute>
  420. </xsl:if>
  421. <xsl:apply-templates mode = "semantics"/>
  422. </mi>
  423. </xsl:when>
  424. <xsl:when test="child::text() and not(child::*[1])">
  425. <mi>
  426. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  427. <xsl:attribute name="xref">
  428. <xsl:value-of select="@id"/>
  429. </xsl:attribute>
  430. </xsl:if>
  431. <xsl:apply-templates/>
  432. </mi>
  433. </xsl:when>
  434. <xsl:when test="child::text() and *[1] and not(*[1]=sep)">
  435. <mrow>
  436. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  437. <xsl:attribute name="xref">
  438. <xsl:value-of select="@id"/>
  439. </xsl:attribute>
  440. </xsl:if>
  441. <xsl:apply-templates/>
  442. </mrow>
  443. </xsl:when>
  444. <xsl:otherwise>
  445. <xsl:if test="*[2]">
  446. <mrow>
  447. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  448. <xsl:attribute name="xref">
  449. <xsl:value-of select="@id"/>
  450. </xsl:attribute>
  451. </xsl:if>
  452. <xsl:apply-templates select="*"/>
  453. </mrow>
  454. </xsl:if>
  455. <xsl:if test="not(*[2])">
  456. <xsl:apply-templates select="*[1]"/>
  457. </xsl:if>
  458. </xsl:otherwise>
  459. </xsl:choose>
  460. </xsl:template>
  461. <xsl:template match = "ci/*[not(self::sep)]">
  462. <xsl:copy-of select = "."/>
  463. </xsl:template>
  464. <xsl:template match = "csymbol">
  465. <mrow>
  466. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  467. <xsl:attribute name="xref">
  468. <xsl:value-of select="@id"/>
  469. </xsl:attribute>
  470. </xsl:if>
  471. <xsl:copy-of select = "* | text()"/>
  472. </mrow>
  473. </xsl:template>
  474. <!-- ***************** BASIC CONTENT ELEMENTS ***************** -->
  475. <!-- General <apply> <AnyFunction/> ... </apply> -->
  476. <!-- Dependants: csymbol apply[fn inverse compose] -->
  477. <xsl:template match = "apply">
  478. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  479. <xsl:param name="PARAM" select="$NO_PARAM"/>
  480. <xsl:param name="PAREN" select="$PAR_NO"/>
  481. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  482. <mrow>
  483. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  484. <xsl:attribute name="xref">
  485. <xsl:value-of select="@id"/>
  486. </xsl:attribute>
  487. </xsl:if>
  488. <xsl:apply-templates select = "*[1]" mode = "semantics">
  489. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  490. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  491. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  492. </xsl:apply-templates>
  493. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  494. <mfenced separators=",">
  495. <xsl:apply-templates select = "*[position()>1]" mode = "semantics">
  496. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  497. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  498. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  499. </xsl:apply-templates>
  500. </mfenced>
  501. </mrow>
  502. </xsl:template>
  503. <!-- fn is ***DEPRECATED*** -->
  504. <xsl:template match = "fn">
  505. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  506. <xsl:param name="PARAM" select="$NO_PARAM"/>
  507. <xsl:param name="PAREN" select="$PAR_NO"/>
  508. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  509. <xsl:apply-templates mode = "semantics">
  510. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  511. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  512. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  513. </xsl:apply-templates>
  514. </xsl:template>
  515. <xsl:template match = "interval">
  516. <mfenced>
  517. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  518. <xsl:attribute name="xref">
  519. <xsl:value-of select="@id"/>
  520. </xsl:attribute>
  521. </xsl:if>
  522. <xsl:if test="not(@closure) or @closure='closed' or @closure='closed-open' or not(@closure='open') and not(@closure='open-closed')">
  523. <xsl:attribute name="open"> [ </xsl:attribute>
  524. </xsl:if>
  525. <xsl:if test="not(@closure) or @closure='closed' or @closure='open-closed' or not(@closure='open') and not(@closure='closed-open')">
  526. <xsl:attribute name="close"> ] </xsl:attribute>
  527. </xsl:if>
  528. <xsl:apply-templates select="*" mode = "semantics"/>
  529. </mfenced>
  530. </xsl:template>
  531. <xsl:template match = "apply[*[1][self::inverse]]">
  532. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  533. <xsl:param name="PAREN" select="$PAR_NO"/>
  534. <xsl:param name="PARAM" select="$NO_PARAM"/>
  535. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  536. <xsl:choose>
  537. <xsl:when test="*[2]=exp | *[2]=ln | *[2]=sin | *[2]=cos |
  538. *[2]=tan | *[2]=sec | *[2]=csc | *[2]=cot |
  539. *[2]=sinh | *[2]=cosh | *[2]=tanh | *[2]=sech |
  540. *[2]=csch | *[2]=coth | *[2]=arcsin |
  541. *[2]=arccos | *[2]=arctan">
  542. <mo>
  543. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  544. <xsl:attribute name="xref">
  545. <xsl:value-of select="@id"/>
  546. </xsl:attribute>
  547. </xsl:if>
  548. <xsl:apply-templates select="*[2]" mode="inverse"/>
  549. </mo>
  550. </xsl:when>
  551. <xsl:otherwise>
  552. <msup>
  553. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  554. <xsl:attribute name="xref">
  555. <xsl:value-of select="@id"/>
  556. </xsl:attribute>
  557. </xsl:if>
  558. <mrow>
  559. <xsl:apply-templates select = "*[2]">
  560. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  561. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  562. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  563. </xsl:apply-templates>
  564. </mrow>
  565. <mfenced>
  566. <mn> -1 </mn>
  567. </mfenced>
  568. </msup>
  569. </xsl:otherwise>
  570. </xsl:choose>
  571. </xsl:template>
  572. <xsl:template match = "*" mode="inverse">
  573. <xsl:choose>
  574. <xsl:when test="self::exp">
  575. <xsl:value-of select="'ln'"/>
  576. </xsl:when>
  577. <xsl:when test="self::ln">
  578. <xsl:value-of select="'exp'"/>
  579. </xsl:when>
  580. <xsl:when test="self::sin">
  581. <xsl:value-of select="'arcsin'"/>
  582. </xsl:when>
  583. <xsl:when test="self::cos">
  584. <xsl:value-of select="'arccos'"/>
  585. </xsl:when>
  586. <xsl:when test="self::tan">
  587. <xsl:value-of select="'arctan'"/>
  588. </xsl:when>
  589. <xsl:when test="self::sec">
  590. <xsl:value-of select="'arcsec'"/>
  591. </xsl:when>
  592. <xsl:when test="self::csc">
  593. <xsl:value-of select="'arccsc'"/>
  594. </xsl:when>
  595. <xsl:when test="self::cot">
  596. <xsl:value-of select="'arccot'"/>
  597. </xsl:when>
  598. <xsl:when test="self::sinh">
  599. <xsl:value-of select="'arcsinh'"/>
  600. </xsl:when>
  601. <xsl:when test="self::cosh">
  602. <xsl:value-of select="'arccosh'"/>
  603. </xsl:when>
  604. <xsl:when test="self::tanh">
  605. <xsl:value-of select="'arctanh'"/>
  606. </xsl:when>
  607. <xsl:when test="self::sech">
  608. <xsl:value-of select="'arcsech'"/>
  609. </xsl:when>
  610. <xsl:when test="self::csch">
  611. <xsl:value-of select="'arccsch'"/>
  612. </xsl:when>
  613. <xsl:when test="self::coth">
  614. <xsl:value-of select="'arccoth'"/>
  615. </xsl:when>
  616. <xsl:when test="self::arcsin">
  617. <xsl:value-of select="'sin'"/>
  618. </xsl:when>
  619. <xsl:when test="self::arccos">
  620. <xsl:value-of select="'cos'"/>
  621. </xsl:when>
  622. <xsl:when test="self::arctan">
  623. <xsl:value-of select="'tan'"/>
  624. </xsl:when>
  625. </xsl:choose>
  626. </xsl:template>
  627. <xsl:template match = "condition">
  628. <mrow>
  629. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  630. <xsl:attribute name="xref">
  631. <xsl:value-of select="@id"/>
  632. </xsl:attribute>
  633. </xsl:if>
  634. <xsl:apply-templates select="*" mode = "semantics"/>
  635. </mrow>
  636. </xsl:template>
  637. <xsl:template match = "declare"/>
  638. <xsl:template match = "lambda">
  639. <mrow>
  640. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  641. <xsl:attribute name="xref">
  642. <xsl:value-of select="@id"/>
  643. </xsl:attribute>
  644. </xsl:if>
  645. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x03BB;</xsl:text> </mo>
  646. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  647. <mfenced>
  648. <xsl:for-each select = "*">
  649. <xsl:choose>
  650. <xsl:when test="self::ci or self::cn">
  651. <xsl:apply-templates select = "." mode="semantics"/>
  652. </xsl:when>
  653. <xsl:otherwise>
  654. <mrow>
  655. <xsl:apply-templates select = "." mode="semantics"/>
  656. </mrow>
  657. </xsl:otherwise>
  658. </xsl:choose>
  659. </xsl:for-each>
  660. </mfenced>
  661. </mrow>
  662. </xsl:template>
  663. <xsl:template match = "apply[*[1][self::compose]]">
  664. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  665. <xsl:param name="PAREN" select="$PAR_NO"/>
  666. <xsl:param name="PARAM" select="$NO_PARAM"/>
  667. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  668. <xsl:choose>
  669. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  670. ($IN_PREC &gt; $FUNCTN_PREC or $IN_PREC=$FUNCTN_PREC and $PARAM=$PAR_SAME)">
  671. <mfenced separators="">
  672. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  673. <xsl:attribute name="xref">
  674. <xsl:value-of select="@id"/>
  675. </xsl:attribute>
  676. </xsl:if>
  677. <xsl:apply-templates select = "*[2]" mode="semantics"/>
  678. <xsl:for-each select = "*[position()>2]">
  679. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2218;</xsl:text> </mo>
  680. <xsl:apply-templates select = "." mode="semantics">
  681. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  682. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  683. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  684. </xsl:apply-templates>
  685. </xsl:for-each>
  686. </mfenced>
  687. </xsl:when>
  688. <xsl:otherwise>
  689. <mrow>
  690. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  691. <xsl:attribute name="xref">
  692. <xsl:value-of select="@id"/>
  693. </xsl:attribute>
  694. </xsl:if>
  695. <xsl:apply-templates select = "*[2]" mode="semantics"/>
  696. <xsl:for-each select = "*[position()>2]">
  697. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2218;</xsl:text> </mo>
  698. <xsl:apply-templates select = "." mode="semantics">
  699. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  700. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  701. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  702. </xsl:apply-templates>
  703. </xsl:for-each>
  704. </mrow>
  705. </xsl:otherwise>
  706. </xsl:choose>
  707. </xsl:template>
  708. <xsl:template match = "ident">
  709. <xsl:choose>
  710. <xsl:when test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  711. <mtext xref="{@id}">id</mtext>
  712. </xsl:when>
  713. <xsl:otherwise>
  714. <mtext>id</mtext>
  715. </xsl:otherwise>
  716. </xsl:choose>
  717. </xsl:template>
  718. <xsl:template match="apply[*[1]=domain or *[1]=codomain or *[1]=image]">
  719. <mrow>
  720. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  721. <xsl:attribute name="xref">
  722. <xsl:value-of select="@id"/>
  723. </xsl:attribute>
  724. </xsl:if>
  725. <xsl:if test="*[1]=domain">
  726. <mtext>domain</mtext>
  727. </xsl:if>
  728. <xsl:if test="*[1]=codomain">
  729. <mtext>codomain</mtext>
  730. </xsl:if>
  731. <xsl:if test="*[1]=image">
  732. <mtext>image</mtext>
  733. </xsl:if>
  734. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  735. <mfenced separators="">
  736. <xsl:apply-templates select="*[position()>1]" mode = "semantics"/>
  737. </mfenced>
  738. </mrow>
  739. </xsl:template>
  740. <xsl:template match = "domainofapplication">
  741. <mrow>
  742. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  743. <xsl:attribute name="xref">
  744. <xsl:value-of select="@id"/>
  745. </xsl:attribute>
  746. </xsl:if>
  747. <xsl:apply-templates select = "*" mode = "semantics"/>
  748. </mrow>
  749. </xsl:template>
  750. <xsl:template match="piecewise">
  751. <mrow>
  752. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  753. <xsl:attribute name="xref">
  754. <xsl:value-of select="@id"/>
  755. </xsl:attribute>
  756. </xsl:if>
  757. <mo stretchy="true"> { </mo>
  758. <mtable columnalign="left left">
  759. <xsl:for-each select="piece">
  760. <mtr>
  761. <mtd>
  762. <xsl:apply-templates select="*[position()=1]" mode = "semantics"/>
  763. </mtd>
  764. <mtd>
  765. <mtext>if </mtext>
  766. <xsl:apply-templates select="*[position()=2]" mode = "semantics"/>
  767. </mtd>
  768. </mtr>
  769. </xsl:for-each>
  770. <xsl:if test="otherwise">
  771. <mtr>
  772. <mtd>
  773. <xsl:apply-templates select="otherwise/*" mode = "semantics"/>
  774. </mtd>
  775. <mtd>
  776. <mtext>otherwise</mtext>
  777. </mtd>
  778. </mtr>
  779. </xsl:if>
  780. </mtable>
  781. </mrow>
  782. </xsl:template>
  783. <!-- ***************** ARITHMETIC, ALGEBRA & LOGIC ***************** -->
  784. <xsl:template match = "apply[quotient[1]]">
  785. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  786. <xsl:param name="PARAM" select="$NO_PARAM"/>
  787. <xsl:param name="PAREN" select="$PAR_NO"/>
  788. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  789. <mrow>
  790. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  791. <xsl:attribute name="xref">
  792. <xsl:value-of select="@id"/>
  793. </xsl:attribute>
  794. </xsl:if>
  795. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x230A;</xsl:text> </mo>
  796. <mfrac>
  797. <mrow>
  798. <xsl:apply-templates select="*[2]" mode = "semantics">
  799. <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
  800. <xsl:with-param name="PARAM" select="$PARAM"/>
  801. <xsl:with-param name="PAREN" select="$PAREN"/>
  802. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  803. </xsl:apply-templates>
  804. </mrow>
  805. <mrow>
  806. <xsl:apply-templates select="*[3]" mode = "semantics">
  807. <xsl:with-param name="IN_PREC" select="$DIV_PREC"/>
  808. <xsl:with-param name="PARAM" select="$PARAM"/>
  809. <xsl:with-param name="PAREN" select="$PAREN"/>
  810. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  811. </xsl:apply-templates>
  812. </mrow>
  813. </mfrac>
  814. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x230B;</xsl:text> </mo>
  815. </mrow>
  816. </xsl:template>
  817. <xsl:template match = "apply[*[1][self::exp]]">
  818. <msup>
  819. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  820. <xsl:attribute name="xref">
  821. <xsl:value-of select="@id"/>
  822. </xsl:attribute>
  823. </xsl:if>
  824. <mn> <xsl:text disable-output-escaping='yes'>&amp;#x2147;</xsl:text> </mn>
  825. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  826. </msup>
  827. </xsl:template>
  828. <xsl:template match = "apply[factorial[1]]">
  829. <mrow>
  830. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  831. <xsl:attribute name="xref">
  832. <xsl:value-of select="@id"/>
  833. </xsl:attribute>
  834. </xsl:if>
  835. <xsl:apply-templates select = "*[2]" mode = "semantics">
  836. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  837. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  838. </xsl:apply-templates>
  839. <mo> ! </mo>
  840. </mrow>
  841. </xsl:template>
  842. <xsl:template match = "apply[max[1] | min[1]]">
  843. <mrow>
  844. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  845. <xsl:attribute name="xref">
  846. <xsl:value-of select="@id"/>
  847. </xsl:attribute>
  848. </xsl:if>
  849. <xsl:choose>
  850. <xsl:when test="*[2]=bvar">
  851. <munder>
  852. <xsl:if test="*[1]=max">
  853. <mo> max </mo>
  854. </xsl:if>
  855. <xsl:if test="*[1]=min">
  856. <mo> min </mo>
  857. </xsl:if>
  858. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  859. </munder>
  860. </xsl:when>
  861. <xsl:otherwise>
  862. <xsl:if test="*[1]=max">
  863. <mo> max </mo>
  864. </xsl:if>
  865. <xsl:if test="*[1]=min">
  866. <mo> min </mo>
  867. </xsl:if>
  868. </xsl:otherwise>
  869. </xsl:choose>
  870. <mfenced open="{{" close="}}">
  871. <xsl:if test="child::condition">
  872. <xsl:attribute name="separators"/>
  873. <xsl:if test="*[position()>1 and not(self::bvar) and not(self::condition)]">
  874. <mfenced open="" close="" separators=",">
  875. <xsl:for-each select = "*[position()>1 and not(self::bvar) and not(self::condition)]">
  876. <xsl:apply-templates select = "." mode="semantics"/>
  877. </xsl:for-each>
  878. </mfenced>
  879. <mo lspace="0.1666em" rspace="0.1666em"> | </mo>
  880. </xsl:if>
  881. <xsl:apply-templates select="condition" mode = "semantics"/>
  882. </xsl:if>
  883. <xsl:if test="not(child::condition)">
  884. <xsl:for-each select = "*[position()>1 and not(self::bvar)]">
  885. <xsl:apply-templates select = "." mode="semantics"/>
  886. </xsl:for-each>
  887. </xsl:if>
  888. </mfenced>
  889. </mrow>
  890. </xsl:template>
  891. <xsl:template match = "apply[minus[1]]">
  892. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  893. <xsl:param name="PARAM" select="$NO_PARAM"/>
  894. <xsl:param name="PAREN" select="$PAR_NO"/>
  895. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  896. <xsl:choose>
  897. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  898. ($IN_PREC &gt; $MINUS_PREC or $IN_PREC=$MINUS_PREC and $PARAM=$PAR_SAME)">
  899. <mfenced separators="">
  900. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  901. <xsl:attribute name="xref">
  902. <xsl:value-of select="@id"/>
  903. </xsl:attribute>
  904. </xsl:if>
  905. <xsl:apply-templates select="." mode="minus">
  906. <xsl:with-param name="PARAM" select="$PARAM"/>
  907. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  908. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  909. </xsl:apply-templates>
  910. </mfenced>
  911. </xsl:when>
  912. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  913. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  914. and not($SEM_SW=$SEM_XREF_EXT)">
  915. <xsl:apply-templates select="." mode="minus">
  916. <xsl:with-param name="PARAM" select="$PARAM"/>
  917. <xsl:with-param name="PAREN" select="$PAREN"/>
  918. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  919. </xsl:apply-templates>
  920. </xsl:when>
  921. <xsl:otherwise>
  922. <mrow>
  923. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  924. <xsl:attribute name="xref">
  925. <xsl:value-of select="@id"/>
  926. </xsl:attribute>
  927. </xsl:if>
  928. <xsl:apply-templates select="." mode="minus">
  929. <xsl:with-param name="PARAM" select="$PARAM"/>
  930. <xsl:with-param name="PAREN" select="$PAREN"/>
  931. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  932. </xsl:apply-templates>
  933. </mrow>
  934. </xsl:otherwise>
  935. </xsl:choose>
  936. </xsl:template>
  937. <xsl:template match = "apply[minus[1]]" mode="minus">
  938. <xsl:param name="PARAM" select="$NO_PARAM"/>
  939. <xsl:param name="PAREN" select="$PAR_NO"/>
  940. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  941. <xsl:if test="not(*[3])">
  942. <mo> - </mo>
  943. <xsl:apply-templates select="*[2]" mode = "semantics">
  944. <xsl:with-param name="IN_PREC" select="$NEG_PREC"/>
  945. <xsl:with-param name="PAREN" select="$PAREN"/>
  946. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  947. </xsl:apply-templates>
  948. </xsl:if>
  949. <xsl:if test="*[3]">
  950. <xsl:apply-templates select="*[2]" mode = "semantics">
  951. <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
  952. <xsl:with-param name="PARAM" select="$PARAM"/>
  953. <xsl:with-param name="PAREN" select="$PAREN"/>
  954. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  955. </xsl:apply-templates>
  956. <mo> - </mo>
  957. <xsl:apply-templates select="*[3]" mode = "semantics">
  958. <xsl:with-param name="IN_PREC" select="$MINUS_PREC"/>
  959. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  960. <xsl:with-param name="PAREN" select="$PAREN"/>
  961. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  962. </xsl:apply-templates>
  963. </xsl:if>
  964. </xsl:template>
  965. <xsl:template match = "apply[plus[1]]">
  966. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  967. <xsl:param name="PARAM" select="$NO_PARAM"/>
  968. <xsl:param name="PAREN" select="$PAR_NO"/>
  969. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  970. <xsl:choose>
  971. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  972. ($IN_PREC &gt; $PLUS_PREC or $IN_PREC=$PLUS_PREC and $PARAM=$PAR_SAME)">
  973. <mfenced separators="">
  974. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  975. <xsl:attribute name="xref">
  976. <xsl:value-of select="@id"/>
  977. </xsl:attribute>
  978. </xsl:if>
  979. <xsl:apply-templates select="." mode="plus">
  980. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  981. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  982. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  983. </xsl:apply-templates>
  984. </mfenced>
  985. </xsl:when>
  986. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  987. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  988. and not($SEM_SW=$SEM_XREF_EXT)">
  989. <xsl:apply-templates select="." mode="plus">
  990. <xsl:with-param name="PARAM" select="$PARAM"/>
  991. <xsl:with-param name="PAREN" select="$PAREN"/>
  992. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  993. </xsl:apply-templates>
  994. </xsl:when>
  995. <xsl:otherwise>
  996. <mrow>
  997. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  998. <xsl:attribute name="xref">
  999. <xsl:value-of select="@id"/>
  1000. </xsl:attribute>
  1001. </xsl:if>
  1002. <xsl:apply-templates select="." mode="plus">
  1003. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1004. <xsl:with-param name="PAREN" select="$PAREN"/>
  1005. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1006. </xsl:apply-templates>
  1007. </mrow>
  1008. </xsl:otherwise>
  1009. </xsl:choose>
  1010. </xsl:template>
  1011. <xsl:template match = "apply[plus[1]]" mode="plus">
  1012. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1013. <xsl:param name="PAREN" select="$PAR_NO"/>
  1014. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1015. <xsl:if test="*[2]">
  1016. <xsl:apply-templates select="*[2]" mode = "semantics">
  1017. <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
  1018. <xsl:with-param name="PARAM" select="$PARAM"/>
  1019. <xsl:with-param name="PAREN" select="$PAREN"/>
  1020. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1021. </xsl:apply-templates>
  1022. <xsl:for-each select = "*[position()>2]">
  1023. <xsl:choose>
  1024. <xsl:when test=". &lt; 0">
  1025. <mo> - </mo>
  1026. <mn> <xsl:value-of select="-."/> </mn>
  1027. </xsl:when>
  1028. <xsl:when test="self::apply[minus[1]] and not(*[3])">
  1029. <xsl:apply-templates select="." mode = "semantics">
  1030. <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
  1031. <xsl:with-param name="PAREN" select="$PAREN"/>
  1032. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1033. </xsl:apply-templates>
  1034. </xsl:when>
  1035. <xsl:otherwise>
  1036. <mo> + </mo>
  1037. <xsl:apply-templates select="." mode = "semantics">
  1038. <xsl:with-param name="IN_PREC" select="$PLUS_PREC"/>
  1039. <xsl:with-param name="PAREN" select="$PAREN"/>
  1040. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1041. </xsl:apply-templates>
  1042. </xsl:otherwise>
  1043. </xsl:choose>
  1044. </xsl:for-each>
  1045. </xsl:if>
  1046. </xsl:template>
  1047. <xsl:template match = "apply[*[1][self::power]]">
  1048. <xsl:choose>
  1049. <xsl:when test="*[2]=apply[ln[1] | log[1] | abs[1] |
  1050. gcd[1] | lcm[1] | sin[1] | cos[1] | tan[1] |
  1051. sec[1] | csc[1] | cot[1] | sinh[1] |
  1052. cosh[1] | tanh[1] | sech[1] | csch[1] |
  1053. coth[1] | arcsin[1] | arccos[1] |
  1054. arctan[1] | arcsec[1] | arccsc[1] |
  1055. arccot[1] | arcsinh[1] | arccosh[1] |
  1056. arctanh[1] | arcsech[1] | arccsch[1] |
  1057. arccoth[1]]">
  1058. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  1059. </xsl:when>
  1060. <xsl:otherwise>
  1061. <msup>
  1062. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1063. <xsl:attribute name="xref">
  1064. <xsl:value-of select="@id"/>
  1065. </xsl:attribute>
  1066. </xsl:if>
  1067. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1068. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1069. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1070. </xsl:apply-templates>
  1071. <xsl:apply-templates select = "*[3]" mode = "semantics"/>
  1072. </msup>
  1073. </xsl:otherwise>
  1074. </xsl:choose>
  1075. </xsl:template>
  1076. <xsl:template match = "apply[divide[1]]">
  1077. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1078. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1079. <xsl:param name="PAREN" select="$PAR_NO"/>
  1080. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1081. <xsl:choose>
  1082. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1083. ($IN_PREC &gt; $DIV_PREC or $IN_PREC=$DIV_PREC and $PARAM=$PAR_SAME)">
  1084. <mfenced separators="">
  1085. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1086. <xsl:attribute name="xref">
  1087. <xsl:value-of select="@id"/>
  1088. </xsl:attribute>
  1089. </xsl:if>
  1090. <xsl:apply-templates select="." mode="div">
  1091. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1092. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1093. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1094. </xsl:apply-templates>
  1095. </mfenced>
  1096. </xsl:when>
  1097. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1098. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  1099. and not($SEM_SW=$SEM_XREF_EXT)">
  1100. <xsl:apply-templates select="." mode="div">
  1101. <xsl:with-param name="PARAM" select="$PARAM"/>
  1102. <xsl:with-param name="PAREN" select="$PAREN"/>
  1103. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1104. </xsl:apply-templates>
  1105. </xsl:when>
  1106. <xsl:otherwise>
  1107. <mrow>
  1108. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1109. <xsl:attribute name="xref">
  1110. <xsl:value-of select="@id"/>
  1111. </xsl:attribute>
  1112. </xsl:if>
  1113. <xsl:apply-templates select="." mode="div">
  1114. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1115. <xsl:with-param name="PAREN" select="$PAREN"/>
  1116. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1117. </xsl:apply-templates>
  1118. </mrow>
  1119. </xsl:otherwise>
  1120. </xsl:choose>
  1121. </xsl:template>
  1122. <xsl:template match = "apply[divide[1]]" mode="div">
  1123. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1124. <xsl:param name="PAREN" select="$PAR_NO"/>
  1125. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1126. <mfrac>
  1127. <mrow>
  1128. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1129. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  1130. <xsl:with-param name="PARAM" select="$PARAM"/>
  1131. <xsl:with-param name="PAREN" select="$PAREN"/>
  1132. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1133. </xsl:apply-templates>
  1134. </mrow>
  1135. <mrow>
  1136. <xsl:apply-templates select = "*[3]" mode = "semantics">
  1137. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  1138. <xsl:with-param name="PARAM" select="$PARAM"/>
  1139. <xsl:with-param name="PAREN" select="$PAREN"/>
  1140. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1141. </xsl:apply-templates>
  1142. </mrow>
  1143. </mfrac>
  1144. </xsl:template>
  1145. <xsl:template match = "apply[rem[1]]">
  1146. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1147. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1148. <xsl:param name="PAREN" select="$PAR_NO"/>
  1149. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1150. <xsl:choose>
  1151. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1152. ($IN_PREC &gt; $REM_PREC or $IN_PREC=$REM_PREC and $PARAM=$PAR_SAME)">
  1153. <mfenced separators="">
  1154. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1155. <xsl:attribute name="xref">
  1156. <xsl:value-of select="@id"/>
  1157. </xsl:attribute>
  1158. </xsl:if>
  1159. <xsl:apply-templates select="." mode="rem">
  1160. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1161. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1162. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1163. </xsl:apply-templates>
  1164. </mfenced>
  1165. </xsl:when>
  1166. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1167. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  1168. and not($SEM_SW=$SEM_XREF_EXT)">
  1169. <xsl:apply-templates select="." mode="rem">
  1170. <xsl:with-param name="PARAM" select="$PARAM"/>
  1171. <xsl:with-param name="PAREN" select="$PAREN"/>
  1172. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1173. </xsl:apply-templates>
  1174. </xsl:when>
  1175. <xsl:otherwise>
  1176. <mrow>
  1177. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1178. <xsl:attribute name="xref">
  1179. <xsl:value-of select="@id"/>
  1180. </xsl:attribute>
  1181. </xsl:if>
  1182. <xsl:apply-templates select="." mode="rem">
  1183. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1184. <xsl:with-param name="PAREN" select="$PAREN"/>
  1185. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1186. </xsl:apply-templates>
  1187. </mrow>
  1188. </xsl:otherwise>
  1189. </xsl:choose>
  1190. </xsl:template>
  1191. <xsl:template match = "apply[rem[1]]" mode="rem">
  1192. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1193. <xsl:param name="PAREN" select="$PAR_NO"/>
  1194. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1195. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1196. <xsl:with-param name="IN_PREC" select="$REM_PREC"/>
  1197. <xsl:with-param name="PARAM" select="$PARAM"/>
  1198. <xsl:with-param name="PAREN" select="$PAREN"/>
  1199. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1200. </xsl:apply-templates>
  1201. <mo lspace="thickmathspace" rspace="thickmathspace"> <xsl:value-of select="'mod'"/> </mo>
  1202. <xsl:apply-templates select = "*[3]" mode = "semantics">
  1203. <xsl:with-param name="IN_PREC" select="$REM_PREC"/>
  1204. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  1205. <xsl:with-param name="PAREN" select="$PAREN"/>
  1206. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1207. </xsl:apply-templates>
  1208. </xsl:template>
  1209. <xsl:template match = "apply[times[1]]">
  1210. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1211. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1212. <xsl:param name="PAREN" select="$PAR_NO"/>
  1213. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1214. <xsl:choose>
  1215. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1216. ($IN_PREC &gt; $MUL_PREC or $IN_PREC=$MUL_PREC and $PARAM=$PAR_SAME)">
  1217. <mfenced separators="">
  1218. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1219. <xsl:attribute name="xref">
  1220. <xsl:value-of select="@id"/>
  1221. </xsl:attribute>
  1222. </xsl:if>
  1223. <xsl:apply-templates select="." mode="times">
  1224. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1225. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1226. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1227. </xsl:apply-templates>
  1228. </mfenced>
  1229. </xsl:when>
  1230. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1231. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  1232. and not($SEM_SW=$SEM_XREF_EXT)">
  1233. <xsl:apply-templates select="." mode="times">
  1234. <xsl:with-param name="PARAM" select="$PARAM"/>
  1235. <xsl:with-param name="PAREN" select="$PAREN"/>
  1236. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1237. </xsl:apply-templates>
  1238. </xsl:when>
  1239. <xsl:otherwise>
  1240. <mrow>
  1241. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1242. <xsl:attribute name="xref">
  1243. <xsl:value-of select="@id"/>
  1244. </xsl:attribute>
  1245. </xsl:if>
  1246. <xsl:apply-templates select="." mode="times">
  1247. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1248. <xsl:with-param name="PAREN" select="$PAREN"/>
  1249. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1250. </xsl:apply-templates>
  1251. </mrow>
  1252. </xsl:otherwise>
  1253. </xsl:choose>
  1254. </xsl:template>
  1255. <xsl:template match = "apply[times[1]]" mode="times">
  1256. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1257. <xsl:param name="PAREN" select="$PAR_NO"/>
  1258. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1259. <xsl:apply-templates select="*[2]" mode = "semantics">
  1260. <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
  1261. <xsl:with-param name="PARAM" select="$PARAM"/>
  1262. <xsl:with-param name="PAREN" select="$PAREN"/>
  1263. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1264. </xsl:apply-templates>
  1265. <xsl:if test="*[3]">
  1266. <xsl:for-each select = "*[position()>2]">
  1267. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2062;</xsl:text> </mo>
  1268. <xsl:apply-templates select="." mode = "semantics">
  1269. <xsl:with-param name="IN_PREC" select="$MUL_PREC"/>
  1270. <xsl:with-param name="PAREN" select="$PAREN"/>
  1271. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1272. </xsl:apply-templates>
  1273. </xsl:for-each>
  1274. </xsl:if>
  1275. </xsl:template>
  1276. <xsl:template match = "apply[*[1]=root and *[2]=degree]">
  1277. <mroot>
  1278. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1279. <xsl:attribute name="xref">
  1280. <xsl:value-of select="@id"/>
  1281. </xsl:attribute>
  1282. </xsl:if>
  1283. <xsl:apply-templates select="*[3]" mode = "semantics">
  1284. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  1285. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1286. </xsl:apply-templates>
  1287. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  1288. </mroot>
  1289. </xsl:template>
  1290. <xsl:template match = "apply[*[1]=root and not(*[2]=degree)]">
  1291. <msqrt>
  1292. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1293. <xsl:attribute name="xref">
  1294. <xsl:value-of select="@id"/>
  1295. </xsl:attribute>
  1296. </xsl:if>
  1297. <xsl:apply-templates select="*[2]" mode = "semantics">
  1298. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  1299. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1300. </xsl:apply-templates>
  1301. </msqrt>
  1302. </xsl:template>
  1303. <xsl:template match = "apply[gcd[1] | lcm[1]]">
  1304. <mrow>
  1305. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1306. <xsl:attribute name="xref">
  1307. <xsl:value-of select="@id"/>
  1308. </xsl:attribute>
  1309. </xsl:if>
  1310. <xsl:if test="not(parent::apply[power[1]])">
  1311. <xsl:if test="gcd[1]">
  1312. <mo> gcd </mo>
  1313. </xsl:if>
  1314. <xsl:if test="lcm[1]">
  1315. <mo> lcm </mo>
  1316. </xsl:if>
  1317. </xsl:if>
  1318. <xsl:if test="parent::apply[power[1]]">
  1319. <msup>
  1320. <xsl:if test="gcd[1]">
  1321. <mo> gcd </mo>
  1322. </xsl:if>
  1323. <xsl:if test="lcm[1]">
  1324. <mo> lcm </mo>
  1325. </xsl:if>
  1326. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  1327. </msup>
  1328. </xsl:if>
  1329. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1330. <mfenced separators=",">
  1331. <xsl:for-each select = "*[position()>1]">
  1332. <xsl:apply-templates select = "." mode="semantics"/>
  1333. </xsl:for-each>
  1334. </mfenced>
  1335. </mrow>
  1336. </xsl:template>
  1337. <xsl:template match = "apply[and[1]]">
  1338. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1339. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1340. <xsl:param name="PAREN" select="$PAR_NO"/>
  1341. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1342. <xsl:choose>
  1343. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1344. ($IN_PREC &gt; $AND_PREC or $IN_PREC=$AND_PREC and $PARAM=$PAR_SAME)">
  1345. <mfenced separators="">
  1346. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1347. <xsl:attribute name="xref">
  1348. <xsl:value-of select="@id"/>
  1349. </xsl:attribute>
  1350. </xsl:if>
  1351. <xsl:apply-templates select="." mode="and">
  1352. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1353. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1354. </xsl:apply-templates>
  1355. </mfenced>
  1356. </xsl:when>
  1357. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1358. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  1359. and not($SEM_SW=$SEM_XREF_EXT)">
  1360. <xsl:apply-templates select="." mode="and">
  1361. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1362. <xsl:with-param name="PAREN" select="$PAREN"/>
  1363. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1364. </xsl:apply-templates>
  1365. </xsl:when>
  1366. <xsl:otherwise>
  1367. <mrow>
  1368. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1369. <xsl:attribute name="xref">
  1370. <xsl:value-of select="@id"/>
  1371. </xsl:attribute>
  1372. </xsl:if>
  1373. <xsl:apply-templates select="." mode="and">
  1374. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1375. <xsl:with-param name="PAREN" select="$PAREN"/>
  1376. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1377. </xsl:apply-templates>
  1378. </mrow>
  1379. </xsl:otherwise>
  1380. </xsl:choose>
  1381. </xsl:template>
  1382. <xsl:template match = "apply[and[1]]" mode="and">
  1383. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1384. <xsl:param name="PAREN" select="$PAR_NO"/>
  1385. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1386. <xsl:apply-templates select="*[2]" mode = "semantics">
  1387. <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
  1388. <xsl:with-param name="PARAM" select="$PARAM"/>
  1389. <xsl:with-param name="PAREN" select="$PAREN"/>
  1390. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1391. </xsl:apply-templates>
  1392. <xsl:for-each select = "*[position()>2]">
  1393. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2227;</xsl:text> </mo>
  1394. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1395. <xsl:apply-templates select="." mode = "semantics">
  1396. <xsl:with-param name="IN_PREC" select="$AND_PREC"/>
  1397. <xsl:with-param name="PAREN" select="$PAREN"/>
  1398. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1399. </xsl:apply-templates>
  1400. </xsl:for-each>
  1401. </xsl:template>
  1402. <xsl:template match = "apply[or[1]]">
  1403. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1404. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1405. <xsl:param name="PAREN" select="$PAR_NO"/>
  1406. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1407. <xsl:choose>
  1408. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1409. ($IN_PREC &gt; $OR_PREC or $IN_PREC=$OR_PREC and $PARAM=$PAR_SAME)">
  1410. <mfenced separators="">
  1411. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1412. <xsl:attribute name="xref">
  1413. <xsl:value-of select="@id"/>
  1414. </xsl:attribute>
  1415. </xsl:if>
  1416. <xsl:apply-templates select="." mode="or">
  1417. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1418. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1419. </xsl:apply-templates>
  1420. </mfenced>
  1421. </xsl:when>
  1422. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1423. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  1424. and not($SEM_SW=$SEM_XREF_EXT)">
  1425. <xsl:apply-templates select="." mode="or">
  1426. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1427. <xsl:with-param name="PAREN" select="$PAREN"/>
  1428. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1429. </xsl:apply-templates>
  1430. </xsl:when>
  1431. <xsl:otherwise>
  1432. <mrow>
  1433. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1434. <xsl:attribute name="xref">
  1435. <xsl:value-of select="@id"/>
  1436. </xsl:attribute>
  1437. </xsl:if>
  1438. <xsl:apply-templates select="." mode="or">
  1439. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1440. <xsl:with-param name="PAREN" select="$PAREN"/>
  1441. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1442. </xsl:apply-templates>
  1443. </mrow>
  1444. </xsl:otherwise>
  1445. </xsl:choose>
  1446. </xsl:template>
  1447. <xsl:template match = "apply[or[1]]" mode="or">
  1448. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1449. <xsl:param name="PAREN" select="$PAR_NO"/>
  1450. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1451. <xsl:apply-templates select="*[2]" mode = "semantics">
  1452. <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
  1453. <xsl:with-param name="PARAM" select="$PARAM"/>
  1454. <xsl:with-param name="PAREN" select="$PAREN"/>
  1455. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1456. </xsl:apply-templates>
  1457. <xsl:for-each select = "*[position()>2]">
  1458. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2228;</xsl:text> </mo>
  1459. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1460. <xsl:apply-templates select="." mode = "semantics">
  1461. <xsl:with-param name="IN_PREC" select="$OR_PREC"/>
  1462. <xsl:with-param name="PAREN" select="$PAREN"/>
  1463. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1464. </xsl:apply-templates>
  1465. </xsl:for-each>
  1466. </xsl:template>
  1467. <xsl:template match = "apply[xor[1]]">
  1468. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1469. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1470. <xsl:param name="PAREN" select="$PAR_NO"/>
  1471. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1472. <xsl:choose>
  1473. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and
  1474. ($IN_PREC &gt; $XOR_PREC or $IN_PREC=$XOR_PREC and $PARAM=$PAR_SAME)">
  1475. <mfenced separators="">
  1476. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1477. <xsl:attribute name="xref">
  1478. <xsl:value-of select="@id"/>
  1479. </xsl:attribute>
  1480. </xsl:if>
  1481. <xsl:apply-templates select="." mode="xor">
  1482. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1483. <xsl:with-param name="PAREN" select="$PAR_YES"/>
  1484. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1485. </xsl:apply-templates>
  1486. </mfenced>
  1487. </xsl:when>
  1488. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  1489. and not($SEM_SW=$SEM_ALL)">
  1490. <xsl:apply-templates select="." mode="xor">
  1491. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1492. <xsl:with-param name="PAREN" select="$PAREN"/>
  1493. </xsl:apply-templates>
  1494. </xsl:when>
  1495. <xsl:otherwise>
  1496. <mrow>
  1497. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1498. <xsl:attribute name="xref">
  1499. <xsl:value-of select="@id"/>
  1500. </xsl:attribute>
  1501. </xsl:if>
  1502. <xsl:apply-templates select="." mode="xor">
  1503. <xsl:with-param name="PARAM" select="$IN_PREC"/>
  1504. <xsl:with-param name="PAREN" select="$PAREN"/>
  1505. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1506. </xsl:apply-templates>
  1507. </mrow>
  1508. </xsl:otherwise>
  1509. </xsl:choose>
  1510. </xsl:template>
  1511. <xsl:template match = "apply[xor[1]]" mode="xor">
  1512. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1513. <xsl:param name="PAREN" select="$PAR_NO"/>
  1514. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1515. <xsl:apply-templates select="*[2]" mode = "semantics">
  1516. <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
  1517. <xsl:with-param name="PARAM" select="$PARAM"/>
  1518. <xsl:with-param name="PAREN" select="$PAREN"/>
  1519. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  1520. </xsl:apply-templates>
  1521. <xsl:for-each select = "*[position()>2]">
  1522. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x22BB;</xsl:text> </mo>
  1523. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1524. <xsl:apply-templates select="." mode = "semantics">
  1525. <xsl:with-param name="IN_PREC" select="$XOR_PREC"/>
  1526. <xsl:with-param name="PAREN" select="$PAREN"/>
  1527. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1528. </xsl:apply-templates>
  1529. </xsl:for-each>
  1530. </xsl:template>
  1531. <xsl:template match = "apply[not[1]]">
  1532. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  1533. <xsl:param name="PARAM" select="$NO_PARAM"/>
  1534. <xsl:param name="PAREN" select="$PAR_NO"/>
  1535. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  1536. <xsl:choose>
  1537. <xsl:when test="$IN_PREC &lt; $GEN_FUN_PREC and $IN_PREC &gt;= $NOT_PREC">
  1538. <mfenced separators="">
  1539. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1540. <xsl:attribute name="xref">
  1541. <xsl:value-of select="@id"/>
  1542. </xsl:attribute>
  1543. </xsl:if>
  1544. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x00AC;</xsl:text> </mo>
  1545. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1546. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1547. <xsl:with-param name="IN_PREC" select="$NOT_PREC"/>
  1548. <xsl:with-param name="PAREN" select="$PAREN"/>
  1549. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1550. </xsl:apply-templates>
  1551. </mfenced>
  1552. </xsl:when>
  1553. <xsl:otherwise>
  1554. <mrow>
  1555. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1556. <xsl:attribute name="xref">
  1557. <xsl:value-of select="@id"/>
  1558. </xsl:attribute>
  1559. </xsl:if>
  1560. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x00AC;</xsl:text> </mo>
  1561. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1562. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1563. <xsl:with-param name="IN_PREC" select="$NOT_PREC"/>
  1564. <xsl:with-param name="PAREN" select="$PAREN"/>
  1565. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1566. </xsl:apply-templates>
  1567. </mrow>
  1568. </xsl:otherwise>
  1569. </xsl:choose>
  1570. </xsl:template>
  1571. <xsl:template match = "apply[forall[1]]">
  1572. <mrow>
  1573. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1574. <xsl:attribute name="xref">
  1575. <xsl:value-of select="@id"/>
  1576. </xsl:attribute>
  1577. </xsl:if>
  1578. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2200;</xsl:text> </mo>
  1579. <xsl:if test="count(bvar)=1">
  1580. <xsl:apply-templates select = "bvar" mode="semantics"/>
  1581. </xsl:if>
  1582. <xsl:if test="count(bvar) &gt; 1">
  1583. <mfenced open="" close="">
  1584. <xsl:for-each select = "bvar">
  1585. <xsl:apply-templates select = "." mode="semantics"/>
  1586. </xsl:for-each>
  1587. </mfenced>
  1588. </xsl:if>
  1589. <xsl:if test="condition">
  1590. <mo> : </mo>
  1591. <xsl:apply-templates select = "condition/*" mode = "semantics"/>
  1592. </xsl:if>
  1593. <xsl:if test="*[position()>1 and not(self::bvar) and not(self::condition)]">
  1594. <mo> , </mo>
  1595. <xsl:apply-templates select = "*[position()>1 and not(self::bvar) and
  1596. not(self::condition)]" mode = "semantics"/>
  1597. </xsl:if>
  1598. </mrow>
  1599. </xsl:template>
  1600. <xsl:template match = "apply[exists[1]]">
  1601. <mrow>
  1602. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1603. <xsl:attribute name="xref">
  1604. <xsl:value-of select="@id"/>
  1605. </xsl:attribute>
  1606. </xsl:if>
  1607. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2203;</xsl:text> </mo>
  1608. <xsl:if test="count(bvar) &gt; 1">
  1609. <mfenced open="" close="">
  1610. <xsl:for-each select = "bvar">
  1611. <xsl:apply-templates select = "." mode="semantics"/>
  1612. </xsl:for-each>
  1613. </mfenced>
  1614. </xsl:if>
  1615. <xsl:if test="count(bvar)=1">
  1616. <xsl:apply-templates select = "bvar" mode="semantics"/>
  1617. </xsl:if>
  1618. <xsl:if test="condition">
  1619. <mo> : </mo>
  1620. <xsl:apply-templates select = "condition/*" mode = "semantics"/>
  1621. </xsl:if>
  1622. <xsl:if test="*[position()>1 and not(self::bvar) and not(self::condition)]">
  1623. <mo> , </mo>
  1624. <xsl:apply-templates select = "*[position()>1 and not(self::bvar) and
  1625. not(self::condition)]" mode = "semantics"/>
  1626. </xsl:if>
  1627. </mrow>
  1628. </xsl:template>
  1629. <xsl:template match = "apply[abs[1]]">
  1630. <xsl:if test="not(parent::apply[power[1]])">
  1631. <mfenced open="&#x2223;" close="&#x2223;" separators="">
  1632. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1633. <xsl:attribute name="xref">
  1634. <xsl:value-of select="@id"/>
  1635. </xsl:attribute>
  1636. </xsl:if>
  1637. <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
  1638. </mfenced>
  1639. </xsl:if>
  1640. <xsl:if test="parent::apply[power[1]]">
  1641. <msup>
  1642. <mfenced open="&#x2223;" close="&#x2223;" separators="">
  1643. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1644. <xsl:attribute name="xref">
  1645. <xsl:value-of select="@id"/>
  1646. </xsl:attribute>
  1647. </xsl:if>
  1648. <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
  1649. </mfenced>
  1650. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  1651. </msup>
  1652. </xsl:if>
  1653. </xsl:template>
  1654. <xsl:template match = "apply[conjugate[1]]">
  1655. <mover>
  1656. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1657. <xsl:attribute name="xref">
  1658. <xsl:value-of select="@id"/>
  1659. </xsl:attribute>
  1660. </xsl:if>
  1661. <mrow>
  1662. <xsl:apply-templates select = "*[position()>1]" mode = "semantics"/>
  1663. </mrow>
  1664. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x00AF;</xsl:text> </mo>
  1665. </mover>
  1666. </xsl:template>
  1667. <xsl:template match = "apply[arg[1] | real[1] | imaginary[1]]">
  1668. <mrow>
  1669. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1670. <xsl:attribute name="xref">
  1671. <xsl:value-of select="@id"/>
  1672. </xsl:attribute>
  1673. </xsl:if>
  1674. <mo>
  1675. <xsl:if test="arg">
  1676. <xsl:value-of select="'arg'"/>
  1677. </xsl:if>
  1678. <xsl:if test="real">
  1679. <xsl:text disable-output-escaping='yes'>&amp;#x211C;</xsl:text>
  1680. </xsl:if>
  1681. <xsl:if test="imaginary">
  1682. <xsl:text disable-output-escaping='yes'>&amp;#x2111;</xsl:text>
  1683. </xsl:if>
  1684. </mo>
  1685. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  1686. <mfenced separators="">
  1687. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  1688. </mfenced>
  1689. </mrow>
  1690. </xsl:template>
  1691. <xsl:template match = "apply[floor[1] or ceiling[1]]">
  1692. <mrow>
  1693. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1694. <xsl:attribute name="xref">
  1695. <xsl:value-of select="@id"/>
  1696. </xsl:attribute>
  1697. </xsl:if>
  1698. <mo>
  1699. <xsl:if test="floor[1]">
  1700. <xsl:text disable-output-escaping='yes'>&amp;#x230A;</xsl:text>
  1701. </xsl:if>
  1702. <xsl:if test="ceiling[1]">
  1703. <xsl:text disable-output-escaping='yes'>&amp;#x2308;</xsl:text>
  1704. </xsl:if>
  1705. </mo>
  1706. <xsl:apply-templates select="*[position()>1]" mode="semantics"/>
  1707. <mo>
  1708. <xsl:if test="floor[1]">
  1709. <xsl:text disable-output-escaping='yes'>&amp;#x230B;</xsl:text>
  1710. </xsl:if>
  1711. <xsl:if test="ceiling[1]">
  1712. <xsl:text disable-output-escaping='yes'>&amp;#x2309;</xsl:text>
  1713. </xsl:if>
  1714. </mo>
  1715. </mrow>
  1716. </xsl:template>
  1717. <!-- ***************** RELATIONS ***************** -->
  1718. <xsl:template match = "apply[neq | approx | tendsto | implies
  1719. | in | notin | notsubset | notprsubset
  1720. | subset | prsubset | eq | gt | lt
  1721. | geq | leq | equivalent | factorof]">
  1722. <mrow>
  1723. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1724. <xsl:attribute name="xref">
  1725. <xsl:value-of select="@id"/>
  1726. </xsl:attribute>
  1727. </xsl:if>
  1728. <xsl:apply-templates select="." mode="relations"/>
  1729. </mrow>
  1730. </xsl:template>
  1731. <!-- reln is ***DEPRECATED*** -->
  1732. <xsl:template match = "reln[neq | approx | tendsto | implies
  1733. | in | notin | notsubset | notprsubset
  1734. | subset | prsubset | eq | gt | lt
  1735. | geq | leq | equivalent | factorof]">
  1736. <mrow>
  1737. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1738. <xsl:attribute name="xref">
  1739. <xsl:value-of select="@id"/>
  1740. </xsl:attribute>
  1741. </xsl:if>
  1742. <xsl:apply-templates select="." mode="relations"/>
  1743. </mrow>
  1744. </xsl:template>
  1745. <xsl:template match = "*" mode="relations">
  1746. <xsl:if test="*[1]=neq or *[1]=approx or *[1]=factorof or *[1]=tendsto or
  1747. *[1]=implies or *[1]=in or *[1]=notin or
  1748. *[1]=notsubset or *[1]=notprsubset">
  1749. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  1750. <mo>
  1751. <xsl:if test="*[1]=neq">
  1752. <xsl:text disable-output-escaping='yes'>&amp;#x2260;</xsl:text>
  1753. </xsl:if>
  1754. <xsl:if test="*[1]=approx">
  1755. <xsl:text disable-output-escaping='yes'>&amp;#x2248;</xsl:text>
  1756. </xsl:if>
  1757. <xsl:if test="*[1]=factorof">
  1758. <xsl:text disable-output-escaping='yes'>&amp;#x2223;</xsl:text>
  1759. </xsl:if>
  1760. <xsl:if test="*[1]=tendsto">
  1761. <xsl:choose>
  1762. <xsl:when test="tendsto[@type='above']">
  1763. <xsl:text disable-output-escaping='yes'>&amp;#x2198;</xsl:text>
  1764. </xsl:when>
  1765. <xsl:when test="tendsto[@type='below']">
  1766. <xsl:text disable-output-escaping='yes'>&amp;#x2197;</xsl:text>
  1767. </xsl:when>
  1768. <xsl:otherwise>
  1769. <xsl:text disable-output-escaping='yes'>&amp;#x2192;</xsl:text>
  1770. </xsl:otherwise>
  1771. </xsl:choose>
  1772. </xsl:if>
  1773. <xsl:if test="*[1]=implies">
  1774. <xsl:text disable-output-escaping='yes'>&amp;#x21D2;</xsl:text>
  1775. </xsl:if>
  1776. <xsl:if test="*[1]=in">
  1777. <xsl:text disable-output-escaping='yes'>&amp;#x2208;</xsl:text>
  1778. </xsl:if>
  1779. <xsl:if test="*[1]=notin">
  1780. <xsl:text disable-output-escaping='yes'>&amp;#x2209;</xsl:text>
  1781. </xsl:if>
  1782. <xsl:if test="*[1]=notsubset">
  1783. <xsl:text disable-output-escaping='yes'>&amp;#x2284;</xsl:text>
  1784. </xsl:if>
  1785. <xsl:if test="*[1]=notprsubset">
  1786. <xsl:text disable-output-escaping='yes'>&amp;#x2288;</xsl:text>
  1787. </xsl:if>
  1788. </mo>
  1789. <xsl:apply-templates select = "*[3]" mode = "semantics"/>
  1790. </xsl:if>
  1791. <xsl:if test="*[1]=subset or *[1]=prsubset or *[1]=eq or *[1]=gt
  1792. or *[1]=lt or *[1]=geq or *[1]=leq or *[1]=equivalent">
  1793. <xsl:apply-templates select = "*[2]" mode="semantics"/>
  1794. <xsl:for-each select = "*[position()>2]">
  1795. <mo>
  1796. <xsl:if test="../*[self::subset][1]">
  1797. <xsl:text disable-output-escaping='yes'>&amp;#x2286;</xsl:text>
  1798. </xsl:if>
  1799. <xsl:if test="../*[self::prsubset][1]">
  1800. <xsl:text disable-output-escaping='yes'>&amp;#x2282;</xsl:text>
  1801. </xsl:if>
  1802. <xsl:if test="../*[self::eq][1]">
  1803. <xsl:value-of select="'='"/>
  1804. </xsl:if>
  1805. <xsl:if test="../*[self::gt][1]">
  1806. <xsl:value-of select="'&gt;'"/>
  1807. </xsl:if>
  1808. <xsl:if test="../*[self::lt][1]">
  1809. <xsl:value-of select="'&lt;'"/>
  1810. </xsl:if>
  1811. <xsl:if test="../*[self::geq][1]">
  1812. <xsl:text disable-output-escaping='yes'>&amp;#x2265;</xsl:text>
  1813. </xsl:if>
  1814. <xsl:if test="../*[self::leq][1]">
  1815. <xsl:text disable-output-escaping='yes'>&amp;#x2264;</xsl:text>
  1816. </xsl:if>
  1817. <xsl:if test="../*[self::equivalent][1]">
  1818. <xsl:text disable-output-escaping='yes'>&amp;#x2261;</xsl:text>
  1819. </xsl:if>
  1820. </mo>
  1821. <xsl:apply-templates select = "." mode="semantics"/>
  1822. </xsl:for-each>
  1823. </xsl:if>
  1824. </xsl:template>
  1825. <!-- ***************** CALCULUS ***************** -->
  1826. <xsl:template match = "apply[*[1][self::ln]]">
  1827. <mrow>
  1828. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1829. <xsl:attribute name="xref">
  1830. <xsl:value-of select="@id"/>
  1831. </xsl:attribute>
  1832. </xsl:if>
  1833. <xsl:choose>
  1834. <xsl:when test="parent::apply[power[1]]">
  1835. <msup>
  1836. <mo> ln </mo>
  1837. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  1838. </msup>
  1839. </xsl:when>
  1840. <xsl:otherwise>
  1841. <mo rspace="thinmathspace"> ln </mo>
  1842. </xsl:otherwise>
  1843. </xsl:choose>
  1844. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1845. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1846. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1847. </xsl:apply-templates>
  1848. </mrow>
  1849. </xsl:template>
  1850. <xsl:template match = "apply[log[1]]">
  1851. <mrow>
  1852. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1853. <xsl:attribute name="xref">
  1854. <xsl:value-of select="@id"/>
  1855. </xsl:attribute>
  1856. </xsl:if>
  1857. <xsl:choose>
  1858. <xsl:when test="parent::apply[power[1]]">
  1859. <xsl:if test="not(*[2]=logbase)">
  1860. <msup>
  1861. <mo> log </mo>
  1862. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  1863. </msup>
  1864. </xsl:if>
  1865. <xsl:if test="*[2]=logbase">
  1866. <msubsup>
  1867. <mo> log </mo>
  1868. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  1869. <xsl:apply-templates select = "logbase" mode = "semantics"/>
  1870. </msubsup>
  1871. </xsl:if>
  1872. </xsl:when>
  1873. <xsl:otherwise>
  1874. <xsl:if test="not(*[2]=logbase)">
  1875. <mo rspace="thinmathspace"> log </mo>
  1876. </xsl:if>
  1877. <xsl:if test="*[2]=logbase">
  1878. <msub>
  1879. <mo> log </mo>
  1880. <xsl:apply-templates select = "logbase" mode = "semantics"/>
  1881. </msub>
  1882. </xsl:if>
  1883. </xsl:otherwise>
  1884. </xsl:choose>
  1885. <xsl:if test="*[2]=logbase">
  1886. <xsl:apply-templates select = "*[3]" mode = "semantics">
  1887. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1888. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1889. </xsl:apply-templates>
  1890. </xsl:if>
  1891. <xsl:if test="not(*[2]=logbase)">
  1892. <xsl:apply-templates select = "*[2]" mode = "semantics">
  1893. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1894. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1895. </xsl:apply-templates>
  1896. </xsl:if>
  1897. </mrow>
  1898. </xsl:template>
  1899. <xsl:template match = "apply[diff[1]]">
  1900. <mrow>
  1901. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1902. <xsl:attribute name="xref">
  1903. <xsl:value-of select="@id"/>
  1904. </xsl:attribute>
  1905. </xsl:if>
  1906. <xsl:choose>
  1907. <xsl:when test="bvar">
  1908. <xsl:if test="not(bvar[*[2]=degree])">
  1909. <mfrac>
  1910. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2146;</xsl:text> </mo>
  1911. <mrow>
  1912. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2146;</xsl:text> </mo>
  1913. <xsl:apply-templates select = "bvar/*[1]" mode = "semantics"/>
  1914. </mrow>
  1915. </mfrac>
  1916. </xsl:if>
  1917. <xsl:if test="bvar[*[2]=degree]">
  1918. <mfrac>
  1919. <msup>
  1920. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2146;</xsl:text> </mo>
  1921. <xsl:apply-templates select = "bvar/degree" mode = "semantics"/>
  1922. </msup>
  1923. <mrow>
  1924. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2146;</xsl:text> </mo>
  1925. <msup>
  1926. <xsl:apply-templates select = "bvar/*[1]" mode = "semantics"/>
  1927. <xsl:apply-templates select = "bvar/degree" mode = "semantics"/>
  1928. </msup>
  1929. </mrow>
  1930. </mfrac>
  1931. </xsl:if>
  1932. <xsl:apply-templates select = "*[position()=last() and not(self::bvar)]" mode = "semantics">
  1933. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1934. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1935. </xsl:apply-templates>
  1936. </xsl:when>
  1937. <xsl:otherwise>
  1938. <xsl:apply-templates select = "*[position()=last() and not(self::bvar)]" mode = "semantics">
  1939. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  1940. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  1941. </xsl:apply-templates>
  1942. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2032;</xsl:text> </mo>
  1943. </xsl:otherwise>
  1944. </xsl:choose>
  1945. </mrow>
  1946. </xsl:template>
  1947. <xsl:template match = "apply[partialdiff[1]]">
  1948. <mrow>
  1949. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  1950. <xsl:attribute name="xref">
  1951. <xsl:value-of select="@id"/>
  1952. </xsl:attribute>
  1953. </xsl:if>
  1954. <xsl:choose>
  1955. <xsl:when test="list">
  1956. <msub>
  1957. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2145;</xsl:text> </mo>
  1958. <xsl:apply-templates select = "list" mode = "semantics"/>
  1959. </msub>
  1960. </xsl:when>
  1961. <xsl:otherwise>
  1962. <xsl:if test="degree">
  1963. <mfrac>
  1964. <msup>
  1965. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  1966. <xsl:apply-templates select = "degree" mode = "semantics"/>
  1967. </msup>
  1968. <mrow>
  1969. <xsl:for-each select = "bvar">
  1970. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  1971. <xsl:if test="*[last()]=degree">
  1972. <msup>
  1973. <xsl:apply-templates select = "*[1]" mode = "semantics"/>
  1974. <xsl:apply-templates select = "degree" mode = "semantics"/>
  1975. </msup>
  1976. </xsl:if>
  1977. <xsl:if test="not(*[last()]=degree)">
  1978. <xsl:apply-templates select = "*[1]" mode = "semantics"/>
  1979. </xsl:if>
  1980. </xsl:for-each>
  1981. </mrow>
  1982. </mfrac>
  1983. </xsl:if>
  1984. <xsl:if test="not(degree)">
  1985. <xsl:for-each select = "bvar">
  1986. <xsl:if test="*[last()]=degree">
  1987. <mfrac>
  1988. <msup>
  1989. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  1990. <xsl:apply-templates select = "degree" mode = "semantics"/>
  1991. </msup>
  1992. <mrow>
  1993. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  1994. <msup>
  1995. <xsl:apply-templates select = "*[1]" mode = "semantics"/>
  1996. <xsl:apply-templates select = "degree" mode = "semantics"/>
  1997. </msup>
  1998. </mrow>
  1999. </mfrac>
  2000. </xsl:if>
  2001. <xsl:if test="not(*[last()]=degree)">
  2002. <mfrac>
  2003. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  2004. <mrow>
  2005. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2202;</xsl:text> </mo>
  2006. <xsl:apply-templates select = "*[1]" mode = "semantics"/>
  2007. </mrow>
  2008. </mfrac>
  2009. </xsl:if>
  2010. </xsl:for-each>
  2011. </xsl:if>
  2012. </xsl:otherwise>
  2013. </xsl:choose>
  2014. <xsl:apply-templates select = "*[last()]" mode = "semantics">
  2015. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  2016. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2017. </xsl:apply-templates>
  2018. </mrow>
  2019. </xsl:template>
  2020. <xsl:template match = "lowlimit | uplimit | bvar | degree | logbase">
  2021. <mrow>
  2022. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2023. <xsl:attribute name="xref">
  2024. <xsl:value-of select="@id"/>
  2025. </xsl:attribute>
  2026. </xsl:if>
  2027. <xsl:apply-templates select="*" mode = "semantics"/>
  2028. </mrow>
  2029. </xsl:template>
  2030. <xsl:template match = "apply[divergence[1] | grad[1] | curl[1]]">
  2031. <mrow>
  2032. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2033. <xsl:attribute name="xref">
  2034. <xsl:value-of select="@id"/>
  2035. </xsl:attribute>
  2036. </xsl:if>
  2037. <mo>
  2038. <xsl:if test="*[1]=divergence">
  2039. <xsl:value-of select="'div'"/>
  2040. </xsl:if>
  2041. <xsl:if test="*[1]=grad">
  2042. <xsl:value-of select="'grad'"/>
  2043. </xsl:if>
  2044. <xsl:if test="*[1]=curl">
  2045. <xsl:value-of select="'curl'"/>
  2046. </xsl:if>
  2047. </mo>
  2048. <mspace width="0.01em" linebreak="nobreak"/>
  2049. <xsl:choose>
  2050. <xsl:when test="*[2]=ci">
  2051. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2052. </xsl:when>
  2053. <xsl:otherwise>
  2054. <mfenced separators="">
  2055. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2056. </mfenced>
  2057. </xsl:otherwise>
  2058. </xsl:choose>
  2059. </mrow>
  2060. </xsl:template>
  2061. <xsl:template match = "apply[laplacian[1]]">
  2062. <mrow>
  2063. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2064. <xsl:attribute name="xref">
  2065. <xsl:value-of select="@id"/>
  2066. </xsl:attribute>
  2067. </xsl:if>
  2068. <msup>
  2069. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2207;</xsl:text> </mo>
  2070. <mn> 2 </mn>
  2071. </msup>
  2072. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2061;</xsl:text> </mo>
  2073. <xsl:apply-templates select = "*[2]" mode = "semantics">
  2074. <xsl:with-param name="IN_PREC" select="$GEN_FUN_PREC"/>
  2075. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2076. </xsl:apply-templates>
  2077. </mrow>
  2078. </xsl:template>
  2079. <!-- ***************** SET THEORY ***************** -->
  2080. <xsl:template match = "set | list">
  2081. <mfenced>
  2082. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2083. <xsl:attribute name="xref">
  2084. <xsl:value-of select="@id"/>
  2085. </xsl:attribute>
  2086. </xsl:if>
  2087. <xsl:if test="self::set">
  2088. <xsl:attribute name="open">
  2089. <xsl:value-of select="'{'"/>
  2090. </xsl:attribute>
  2091. <xsl:attribute name="close">
  2092. <xsl:value-of select="'}'"/>
  2093. </xsl:attribute>
  2094. </xsl:if>
  2095. <xsl:if test="self::list">
  2096. <xsl:attribute name="open">
  2097. <xsl:value-of select="'['"/>
  2098. </xsl:attribute>
  2099. <xsl:attribute name="close">
  2100. <xsl:value-of select="']'"/>
  2101. </xsl:attribute>
  2102. </xsl:if>
  2103. <xsl:choose>
  2104. <xsl:when test="not(child::bvar) and not(child::condition)">
  2105. <xsl:apply-templates select = "*" mode="semantics"/>
  2106. </xsl:when>
  2107. <xsl:otherwise>
  2108. <xsl:attribute name="separators"/>
  2109. <xsl:apply-templates select = "*[not(self::condition) and not(self::bvar)]" mode="semantics"/>
  2110. <mo lspace="0.1666em" rspace="0.1666em"> | </mo>
  2111. <xsl:apply-templates select="condition" mode = "semantics"/>
  2112. </xsl:otherwise>
  2113. </xsl:choose>
  2114. </mfenced>
  2115. </xsl:template>
  2116. <xsl:template match = "apply[union[1]]">
  2117. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  2118. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2119. <xsl:param name="PAREN" select="$PAR_NO"/>
  2120. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2121. <xsl:choose>
  2122. <xsl:when test="$IN_PREC &gt; $UNION_PREC or $IN_PREC=$UNION_PREC
  2123. and $PARAM=$PAR_SAME">
  2124. <mfenced separators="">
  2125. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2126. <xsl:attribute name="xref">
  2127. <xsl:value-of select="@id"/>
  2128. </xsl:attribute>
  2129. </xsl:if>
  2130. <xsl:apply-templates select="." mode="union">
  2131. <xsl:with-param name="PARAM" select="$PARAM"/>
  2132. <xsl:with-param name="PAREN" select="$PAREN"/>
  2133. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2134. </xsl:apply-templates>
  2135. </mfenced>
  2136. </xsl:when>
  2137. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  2138. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  2139. and not($SEM_SW=$SEM_XREF_EXT)">
  2140. <xsl:apply-templates select="." mode="union">
  2141. <xsl:with-param name="PARAM" select="$PARAM"/>
  2142. <xsl:with-param name="PAREN" select="$PAREN"/>
  2143. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2144. </xsl:apply-templates>
  2145. </xsl:when>
  2146. <xsl:otherwise>
  2147. <mrow>
  2148. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2149. <xsl:attribute name="xref">
  2150. <xsl:value-of select="@id"/>
  2151. </xsl:attribute>
  2152. </xsl:if>
  2153. <xsl:apply-templates select="." mode="union">
  2154. <xsl:with-param name="PARAM" select="$PARAM"/>
  2155. <xsl:with-param name="PAREN" select="$PAREN"/>
  2156. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2157. </xsl:apply-templates>
  2158. </mrow>
  2159. </xsl:otherwise>
  2160. </xsl:choose>
  2161. </xsl:template>
  2162. <xsl:template match = "apply[union[1]]" mode="union">
  2163. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2164. <xsl:param name="PAREN" select="$PAR_NO"/>
  2165. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2166. <xsl:apply-templates select = "*[2]" mode="semantics">
  2167. <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
  2168. <xsl:with-param name="PARAM" select="$PARAM"/>
  2169. <xsl:with-param name="PAREN" select="$PAREN"/>
  2170. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2171. </xsl:apply-templates>
  2172. <xsl:for-each select = "*[position()>2]">
  2173. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222A;</xsl:text> </mo>
  2174. <xsl:apply-templates select = "." mode="semantics">
  2175. <xsl:with-param name="IN_PREC" select="$UNION_PREC"/>
  2176. <xsl:with-param name="PAREN" select="$PAREN"/>
  2177. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2178. </xsl:apply-templates>
  2179. </xsl:for-each>
  2180. </xsl:template>
  2181. <xsl:template match = "apply[intersect[1]]">
  2182. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  2183. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2184. <xsl:param name="PAREN" select="$PAR_NO"/>
  2185. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2186. <xsl:choose>
  2187. <xsl:when test="$IN_PREC &gt; $INTERSECT_PREC or $IN_PREC=$INTERSECT_PREC
  2188. and $PARAM=$PAR_SAME">
  2189. <mfenced separators="">
  2190. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2191. <xsl:attribute name="xref">
  2192. <xsl:value-of select="@id"/>
  2193. </xsl:attribute>
  2194. </xsl:if>
  2195. <xsl:apply-templates select="." mode="intersect">
  2196. <xsl:with-param name="PARAM" select="$PARAM"/>
  2197. <xsl:with-param name="PAREN" select="$PAREN"/>
  2198. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2199. </xsl:apply-templates>
  2200. </mfenced>
  2201. </xsl:when>
  2202. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  2203. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  2204. and not($SEM_SW=$SEM_XREF_EXT)">
  2205. <xsl:apply-templates select="." mode="intersect">
  2206. <xsl:with-param name="PARAM" select="$PARAM"/>
  2207. <xsl:with-param name="PAREN" select="$PAREN"/>
  2208. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2209. </xsl:apply-templates>
  2210. </xsl:when>
  2211. <xsl:otherwise>
  2212. <mrow>
  2213. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2214. <xsl:attribute name="xref">
  2215. <xsl:value-of select="@id"/>
  2216. </xsl:attribute>
  2217. </xsl:if>
  2218. <xsl:apply-templates select="." mode="intersect">
  2219. <xsl:with-param name="PARAM" select="$PARAM"/>
  2220. <xsl:with-param name="PAREN" select="$PAREN"/>
  2221. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2222. </xsl:apply-templates>
  2223. </mrow>
  2224. </xsl:otherwise>
  2225. </xsl:choose>
  2226. </xsl:template>
  2227. <xsl:template match = "apply[intersect[1]]" mode="intersect">
  2228. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2229. <xsl:param name="PAREN" select="$PAR_NO"/>
  2230. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2231. <xsl:apply-templates select = "*[2]" mode="semantics">
  2232. <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
  2233. <xsl:with-param name="PARAM" select="$PARAM"/>
  2234. <xsl:with-param name="PAREN" select="$PAREN"/>
  2235. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2236. </xsl:apply-templates>
  2237. <xsl:for-each select = "*[position()>2]">
  2238. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2229;</xsl:text> </mo>
  2239. <xsl:apply-templates select = "." mode="semantics">
  2240. <xsl:with-param name="IN_PREC" select="$INTERSECT_PREC"/>
  2241. <xsl:with-param name="PAREN" select="$PAREN"/>
  2242. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2243. </xsl:apply-templates>
  2244. </xsl:for-each>
  2245. </xsl:template>
  2246. <xsl:template match = "apply[setdiff[1]]">
  2247. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  2248. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2249. <xsl:param name="PAREN" select="$PAR_NO"/>
  2250. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2251. <xsl:choose>
  2252. <xsl:when test="$IN_PREC &gt; $SETDIFF_PREC or $IN_PREC=$SETDIFF_PREC
  2253. and $PARAM=$PAR_SAME">
  2254. <mfenced separators="">
  2255. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2256. <xsl:attribute name="xref">
  2257. <xsl:value-of select="@id"/>
  2258. </xsl:attribute>
  2259. </xsl:if>
  2260. <xsl:apply-templates select="." mode="setdiff">
  2261. <xsl:with-param name="PARAM" select="$PARAM"/>
  2262. <xsl:with-param name="PAREN" select="$PAREN"/>
  2263. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2264. </xsl:apply-templates>
  2265. </mfenced>
  2266. </xsl:when>
  2267. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  2268. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  2269. and not($SEM_SW=$SEM_XREF_EXT)">
  2270. <xsl:apply-templates select="." mode="setdiff">
  2271. <xsl:with-param name="PARAM" select="$PARAM"/>
  2272. <xsl:with-param name="PAREN" select="$PAREN"/>
  2273. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2274. </xsl:apply-templates>
  2275. </xsl:when>
  2276. <xsl:otherwise>
  2277. <mrow>
  2278. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2279. <xsl:attribute name="xref">
  2280. <xsl:value-of select="@id"/>
  2281. </xsl:attribute>
  2282. </xsl:if>
  2283. <xsl:apply-templates select="." mode="setdiff">
  2284. <xsl:with-param name="PARAM" select="$PARAM"/>
  2285. <xsl:with-param name="PAREN" select="$PAREN"/>
  2286. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2287. </xsl:apply-templates>
  2288. </mrow>
  2289. </xsl:otherwise>
  2290. </xsl:choose>
  2291. </xsl:template>
  2292. <xsl:template match = "apply[setdiff[1]]" mode="setdiff">
  2293. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2294. <xsl:param name="PAREN" select="$PAR_NO"/>
  2295. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2296. <xsl:apply-templates select = "*[2]" mode = "semantics">
  2297. <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
  2298. <xsl:with-param name="PARAM" select="$PARAM"/>
  2299. <xsl:with-param name="PAREN" select="$PAREN"/>
  2300. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2301. </xsl:apply-templates>
  2302. <mo>\</mo>
  2303. <xsl:apply-templates select = "*[3]" mode = "semantics">
  2304. <xsl:with-param name="IN_PREC" select="$SETDIFF_PREC"/>
  2305. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  2306. <xsl:with-param name="PAREN" select="$PAREN"/>
  2307. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2308. </xsl:apply-templates>
  2309. </xsl:template>
  2310. <xsl:template match = "apply[cartesianproduct[1]]">
  2311. <xsl:param name="IN_PREC" select="$NO_PREC"/>
  2312. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2313. <xsl:param name="PAREN" select="$PAR_NO"/>
  2314. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2315. <xsl:choose>
  2316. <xsl:when test="$IN_PREC &gt; $CARTPROD_PREC or $IN_PREC=$CARTPROD_PREC
  2317. and $PARAM=$PAR_SAME">
  2318. <mfenced separators="">
  2319. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2320. <xsl:attribute name="xref">
  2321. <xsl:value-of select="@id"/>
  2322. </xsl:attribute>
  2323. </xsl:if>
  2324. <xsl:apply-templates select="." mode="cartprod">
  2325. <xsl:with-param name="PARAM" select="$PARAM"/>
  2326. <xsl:with-param name="PAREN" select="$PAREN"/>
  2327. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2328. </xsl:apply-templates>
  2329. </mfenced>
  2330. </xsl:when>
  2331. <xsl:when test="$IN_PREC &gt; $NO_PREC and $IN_PREC &lt; $GEN_FUN_PREC
  2332. and not($SEM_SW=$SEM_ALL) and not($SEM_SW=$SEM_XREF)
  2333. and not($SEM_SW=$SEM_XREF_EXT)">
  2334. <xsl:apply-templates select="." mode="cartprod">
  2335. <xsl:with-param name="PARAM" select="$PARAM"/>
  2336. <xsl:with-param name="PAREN" select="$PAREN"/>
  2337. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2338. </xsl:apply-templates>
  2339. </xsl:when>
  2340. <xsl:otherwise>
  2341. <mrow>
  2342. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2343. <xsl:attribute name="xref">
  2344. <xsl:value-of select="@id"/>
  2345. </xsl:attribute>
  2346. </xsl:if>
  2347. <xsl:apply-templates select="." mode="cartprod">
  2348. <xsl:with-param name="PARAM" select="$PARAM"/>
  2349. <xsl:with-param name="PAREN" select="$PAREN"/>
  2350. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2351. </xsl:apply-templates>
  2352. </mrow>
  2353. </xsl:otherwise>
  2354. </xsl:choose>
  2355. </xsl:template>
  2356. <xsl:template match = "*" mode="cartprod">
  2357. <xsl:param name="PARAM" select="$NO_PARAM"/>
  2358. <xsl:param name="PAREN" select="$PAR_NO"/>
  2359. <xsl:param name="PAR_NO_IGNORE" select="$YES"/>
  2360. <xsl:apply-templates select = "*[2]" mode = "semantics">
  2361. <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
  2362. <xsl:with-param name="PARAM" select="$PARAM"/>
  2363. <xsl:with-param name="PAREN" select="$PAREN"/>
  2364. <xsl:with-param name="PAR_NO_IGNORE" select="$PAR_NO_IGNORE"/>
  2365. </xsl:apply-templates>
  2366. <xsl:for-each select = "*[position()>2]">
  2367. <mo><xsl:text disable-output-escaping='yes'>&amp;#x00D7;</xsl:text></mo>
  2368. <xsl:apply-templates select = "." mode="semantics">
  2369. <xsl:with-param name="IN_PREC" select="$CARTPROD_PREC"/>
  2370. <xsl:with-param name="PARAM" select="$PAR_SAME"/>
  2371. <xsl:with-param name="PAREN" select="$PAREN"/>
  2372. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2373. </xsl:apply-templates>
  2374. </xsl:for-each>
  2375. </xsl:template>
  2376. <xsl:template match = "apply[card[1]]">
  2377. <mfenced open="&#x2223;" close="&#x2223;" separators=",">
  2378. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2379. <xsl:attribute name="xref">
  2380. <xsl:value-of select="@id"/>
  2381. </xsl:attribute>
  2382. </xsl:if>
  2383. <xsl:for-each select = "*[position()>1]">
  2384. <xsl:apply-templates select = "." mode="semantics"/>
  2385. </xsl:for-each>
  2386. </mfenced>
  2387. </xsl:template>
  2388. <!-- ***************** SEQUENCES AND SERIES ***************** -->
  2389. <xsl:template match = "apply[sum[1] | product[1]]">
  2390. <mrow>
  2391. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2392. <xsl:attribute name="xref">
  2393. <xsl:value-of select="@id"/>
  2394. </xsl:attribute>
  2395. </xsl:if>
  2396. <xsl:choose>
  2397. <xsl:when test="*[2]=bvar and lowlimit and uplimit">
  2398. <munderover>
  2399. <mo>
  2400. <xsl:if test="*[1]=sum">
  2401. <xsl:text disable-output-escaping='yes'>&amp;#x2211;</xsl:text>
  2402. </xsl:if>
  2403. <xsl:if test="*[1]=product">
  2404. <xsl:text disable-output-escaping='yes'>&amp;#x220F;</xsl:text>
  2405. </xsl:if>
  2406. </mo>
  2407. <mrow>
  2408. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2409. <mo> = </mo>
  2410. <xsl:apply-templates select = "lowlimit" mode = "semantics"/>
  2411. </mrow>
  2412. <xsl:apply-templates select = "uplimit" mode = "semantics"/>
  2413. </munderover>
  2414. <xsl:apply-templates select = "*[5]" mode = "semantics"/>
  2415. </xsl:when>
  2416. <xsl:when test="*[2]=bvar and *[3]=condition">
  2417. <munder>
  2418. <mo>
  2419. <xsl:if test="*[1]=sum">
  2420. <xsl:text disable-output-escaping='yes'>&amp;#x2211;</xsl:text>
  2421. </xsl:if>
  2422. <xsl:if test="*[1]=product">
  2423. <xsl:text disable-output-escaping='yes'>&amp;#x220F;</xsl:text>
  2424. </xsl:if>
  2425. </mo>
  2426. <xsl:apply-templates select = "*[3]" mode = "semantics"/>
  2427. </munder>
  2428. <xsl:apply-templates select = "*[4]" mode = "semantics"/>
  2429. </xsl:when>
  2430. <xsl:when test="*[2]=domainofapplication">
  2431. <munder>
  2432. <mo>
  2433. <xsl:if test="*[1]=sum">
  2434. <xsl:text disable-output-escaping='yes'>&amp;#x2211;</xsl:text>
  2435. </xsl:if>
  2436. <xsl:if test="*[1]=product">
  2437. <xsl:text disable-output-escaping='yes'>&amp;#x220F;</xsl:text>
  2438. </xsl:if>
  2439. </mo>
  2440. <xsl:apply-templates select="domainofapplication" mode = "semantics"/>
  2441. </munder>
  2442. <mrow>
  2443. <xsl:apply-templates select="*[position()=last()]" mode = "semantics"/>
  2444. </mrow>
  2445. </xsl:when>
  2446. </xsl:choose>
  2447. </mrow>
  2448. </xsl:template>
  2449. <xsl:template match="apply[*[1][self::int]]">
  2450. <mrow>
  2451. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2452. <xsl:attribute name="xref">
  2453. <xsl:value-of select="@id"/>
  2454. </xsl:attribute>
  2455. </xsl:if>
  2456. <xsl:choose>
  2457. <xsl:when test="domainofapplication">
  2458. <munder>
  2459. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222B;</xsl:text> </mo>
  2460. <xsl:apply-templates select="domainofapplication" mode="semantics"/>
  2461. </munder>
  2462. </xsl:when>
  2463. <xsl:when test="condition">
  2464. <munder>
  2465. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222B;</xsl:text> </mo>
  2466. <xsl:apply-templates select="condition" mode="semantics"/>
  2467. </munder>
  2468. </xsl:when>
  2469. <xsl:when test="interval">
  2470. <munderover>
  2471. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222B;</xsl:text> </mo>
  2472. <mrow>
  2473. <xsl:apply-templates select="interval/*[position()=1]" mode="semantics"/>
  2474. </mrow>
  2475. <mrow>
  2476. <mspace width="1em"/>
  2477. <xsl:apply-templates select="interval/*[position()=2]" mode="semantics"/>
  2478. </mrow>
  2479. </munderover>
  2480. </xsl:when>
  2481. <xsl:when test="lowlimit | uplimit">
  2482. <munderover>
  2483. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222B;</xsl:text> </mo>
  2484. <xsl:apply-templates select="lowlimit" mode="semantics"/>
  2485. <mrow>
  2486. <mspace width="1em"/>
  2487. <xsl:apply-templates select="uplimit" mode="semantics"/>
  2488. </mrow>
  2489. </munderover>
  2490. </xsl:when>
  2491. <xsl:otherwise>
  2492. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x222B;</xsl:text> </mo>
  2493. </xsl:otherwise>
  2494. </xsl:choose>
  2495. <xsl:apply-templates select="*[position()=last() and last()>1 and not(self::domainofapplication) and not(self::condition) and not(self::interval) and not(self::lowlimit) and not(self::uplimit) and not(self::bvar)]" mode="semantics">
  2496. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  2497. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2498. </xsl:apply-templates>
  2499. <xsl:if test="bvar">
  2500. <mrow>
  2501. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2146;</xsl:text> </mo>
  2502. <xsl:apply-templates select="bvar" mode="semantics"/>
  2503. </mrow>
  2504. </xsl:if>
  2505. </mrow>
  2506. </xsl:template>
  2507. <xsl:template match = "apply[limit[1]]">
  2508. <mrow>
  2509. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2510. <xsl:attribute name="xref">
  2511. <xsl:value-of select="@id"/>
  2512. </xsl:attribute>
  2513. </xsl:if>
  2514. <munder>
  2515. <mo> lim </mo>
  2516. <mrow>
  2517. <xsl:if test="*[2]=bvar and *[3]=lowlimit">
  2518. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2519. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2192;</xsl:text> </mo>
  2520. <xsl:apply-templates select = "*[3]" mode = "semantics"/>
  2521. </xsl:if>
  2522. <xsl:if test="*[2]=bvar and *[3]=condition">
  2523. <xsl:apply-templates select = "*[3]" mode = "semantics"/>
  2524. </xsl:if>
  2525. </mrow>
  2526. </munder>
  2527. <xsl:apply-templates select = "*[4]" mode = "semantics"/>
  2528. </mrow>
  2529. </xsl:template>
  2530. <!-- ***************** TRIGONOMETRY ***************** -->
  2531. <xsl:template match = "apply[*[1][self::sin | self::cos |
  2532. self::tan | self::sec | self::csc |
  2533. self::cot | self::sinh | self::cosh |
  2534. self::tanh | self::sech | self::csch |
  2535. self::coth | self::arcsin | self::arccos |
  2536. self::arctan | self::arcsec | self::arccsc |
  2537. self::arccot | self::arcsinh | self::arccosh |
  2538. self::arctanh | self::arcsech | self::arccsch |
  2539. self::arccoth]]">
  2540. <mrow>
  2541. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2542. <xsl:attribute name="xref">
  2543. <xsl:value-of select="@id"/>
  2544. </xsl:attribute>
  2545. </xsl:if>
  2546. <xsl:if test="not(parent::apply[power[1]])">
  2547. <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
  2548. </xsl:if>
  2549. <xsl:if test="parent::apply[power[1]]">
  2550. <msup>
  2551. <xsl:apply-templates select = "*[1]" mode = "trigonometry"/>
  2552. <xsl:apply-templates select = "../*[3]" mode = "semantics"/>
  2553. </msup>
  2554. </xsl:if>
  2555. <mspace width="0.01em" linebreak="nobreak"/>
  2556. <xsl:apply-templates select = "*[2]" mode = "semantics">
  2557. <xsl:with-param name="IN_PREC" select="$FUNCTN_PREC"/>
  2558. <xsl:with-param name="PAR_NO_IGNORE" select="$NO"/>
  2559. </xsl:apply-templates>
  2560. </mrow>
  2561. </xsl:template>
  2562. <xsl:template match = "sin | cos |
  2563. tan | sec | csc |
  2564. cot | sinh | cosh |
  2565. tanh | sech | csch |
  2566. coth | arcsin | arccos |
  2567. arctan | arcsec | arccsc |
  2568. arccot | arcsinh | arccosh |
  2569. arctanh | arcsech | arccsch |
  2570. arccoth">
  2571. <xsl:apply-templates select = "." mode = "trigonometry"/>
  2572. </xsl:template>
  2573. <xsl:template match = "*" mode="trigonometry">
  2574. <mo>
  2575. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2576. <xsl:attribute name="xref">
  2577. <xsl:value-of select="@id"/>
  2578. </xsl:attribute>
  2579. </xsl:if>
  2580. <xsl:choose>
  2581. <xsl:when test="self::sin">
  2582. <xsl:value-of select="'sin'"/>
  2583. </xsl:when>
  2584. <xsl:when test="self::cos">
  2585. <xsl:value-of select="'cos'"/>
  2586. </xsl:when>
  2587. <xsl:when test="self::tan">
  2588. <xsl:value-of select="'tan'"/>
  2589. </xsl:when>
  2590. <xsl:when test="self::sec">
  2591. <xsl:value-of select="'sec'"/>
  2592. </xsl:when>
  2593. <xsl:when test="self::csc">
  2594. <xsl:value-of select="'csc'"/>
  2595. </xsl:when>
  2596. <xsl:when test="self::cot">
  2597. <xsl:value-of select="'cot'"/>
  2598. </xsl:when>
  2599. <xsl:when test="self::sinh">
  2600. <xsl:value-of select="'sinh'"/>
  2601. </xsl:when>
  2602. <xsl:when test="self::cosh">
  2603. <xsl:value-of select="'cosh'"/>
  2604. </xsl:when>
  2605. <xsl:when test="self::tanh">
  2606. <xsl:value-of select="'tanh'"/>
  2607. </xsl:when>
  2608. <xsl:when test="self::sech">
  2609. <xsl:value-of select="'sech'"/>
  2610. </xsl:when>
  2611. <xsl:when test="self::csch">
  2612. <xsl:value-of select="'csch'"/>
  2613. </xsl:when>
  2614. <xsl:when test="self::coth">
  2615. <xsl:value-of select="'coth'"/>
  2616. </xsl:when>
  2617. <xsl:when test="self::arcsin">
  2618. <xsl:value-of select="'arcsin'"/>
  2619. </xsl:when>
  2620. <xsl:when test="self::arccos">
  2621. <xsl:value-of select="'arccos'"/>
  2622. </xsl:when>
  2623. <xsl:when test="self::arctan">
  2624. <xsl:value-of select="'arctan'"/>
  2625. </xsl:when>
  2626. <xsl:when test="self::arcsec">
  2627. <xsl:value-of select="'arcsec'"/>
  2628. </xsl:when>
  2629. <xsl:when test="self::arccsc">
  2630. <xsl:value-of select="'arccsc'"/>
  2631. </xsl:when>
  2632. <xsl:when test="self::arccot">
  2633. <xsl:value-of select="'arccot'"/>
  2634. </xsl:when>
  2635. <xsl:when test="self::arcsinh">
  2636. <xsl:value-of select="'arcsinh'"/>
  2637. </xsl:when>
  2638. <xsl:when test="self::arccosh">
  2639. <xsl:value-of select="'arccosh'"/>
  2640. </xsl:when>
  2641. <xsl:when test="self::arctanh">
  2642. <xsl:value-of select="'arctanh'"/>
  2643. </xsl:when>
  2644. <xsl:when test="self::arcsech">
  2645. <xsl:value-of select="'arcsech'"/>
  2646. </xsl:when>
  2647. <xsl:when test="self::arccsch">
  2648. <xsl:value-of select="'arccsch'"/>
  2649. </xsl:when>
  2650. <xsl:when test="self::arccoth">
  2651. <xsl:value-of select="'arccot'"/>
  2652. </xsl:when>
  2653. </xsl:choose>
  2654. </mo>
  2655. </xsl:template>
  2656. <!-- ***************** STATISTICS ***************** -->
  2657. <xsl:template match = "apply[mean[1]]">
  2658. <mfenced open="&#x2329;" close="&#x232A;" separators=",">
  2659. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2660. <xsl:attribute name="xref">
  2661. <xsl:value-of select="@id"/>
  2662. </xsl:attribute>
  2663. </xsl:if>
  2664. <xsl:for-each select = "*[position()>1]">
  2665. <xsl:apply-templates select = "." mode="semantics"/>
  2666. </xsl:for-each>
  2667. </mfenced>
  2668. </xsl:template>
  2669. <xsl:template match = "apply[sdev[1]]">
  2670. <mrow>
  2671. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2672. <xsl:attribute name="xref">
  2673. <xsl:value-of select="@id"/>
  2674. </xsl:attribute>
  2675. </xsl:if>
  2676. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x03C3;</xsl:text> </mo>
  2677. <mfenced separators=",">
  2678. <xsl:for-each select = "*[position()>1]">
  2679. <xsl:apply-templates select = "." mode="semantics"/>
  2680. </xsl:for-each>
  2681. </mfenced>
  2682. </mrow>
  2683. </xsl:template>
  2684. <xsl:template match = "apply[variance[1]]">
  2685. <mrow>
  2686. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2687. <xsl:attribute name="xref">
  2688. <xsl:value-of select="@id"/>
  2689. </xsl:attribute>
  2690. </xsl:if>
  2691. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x03C3;</xsl:text> </mo>
  2692. <msup>
  2693. <mfenced separators=",">
  2694. <xsl:for-each select = "*[position()>1]">
  2695. <xsl:apply-templates select = "." mode="semantics"/>
  2696. </xsl:for-each>
  2697. </mfenced>
  2698. <mn> 2 </mn>
  2699. </msup>
  2700. </mrow>
  2701. </xsl:template>
  2702. <xsl:template match = "apply[median[1]]">
  2703. <mrow>
  2704. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2705. <xsl:attribute name="xref">
  2706. <xsl:value-of select="@id"/>
  2707. </xsl:attribute>
  2708. </xsl:if>
  2709. <mo> median </mo>
  2710. <mfenced separators=",">
  2711. <xsl:for-each select = "*[position()>1]">
  2712. <xsl:apply-templates select = "." mode="semantics"/>
  2713. </xsl:for-each>
  2714. </mfenced>
  2715. </mrow>
  2716. </xsl:template>
  2717. <xsl:template match = "apply[mode[1]]">
  2718. <mrow>
  2719. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2720. <xsl:attribute name="xref">
  2721. <xsl:value-of select="@id"/>
  2722. </xsl:attribute>
  2723. </xsl:if>
  2724. <mo> mode </mo>
  2725. <mfenced separators=",">
  2726. <xsl:for-each select = "*[position()>1]">
  2727. <xsl:apply-templates select = "." mode="semantics"/>
  2728. </xsl:for-each>
  2729. </mfenced>
  2730. </mrow>
  2731. </xsl:template>
  2732. <xsl:template match = "apply[moment[1]]">
  2733. <mfenced open="&#x2329;" close="&#x232A;" separators="">
  2734. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2735. <xsl:attribute name="xref">
  2736. <xsl:value-of select="@id"/>
  2737. </xsl:attribute>
  2738. </xsl:if>
  2739. <xsl:if test="*[2]=degree and not(*[3]=momentabout)">
  2740. <msup>
  2741. <xsl:apply-templates select="*[3]" mode = "semantics"/>
  2742. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  2743. </msup>
  2744. </xsl:if>
  2745. <xsl:if test="*[2]=degree and *[3]=momentabout">
  2746. <msup>
  2747. <xsl:apply-templates select="*[4]" mode = "semantics"/>
  2748. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  2749. </msup>
  2750. </xsl:if>
  2751. <xsl:if test="not(*[2]=degree) and *[2]=momentabout">
  2752. <xsl:for-each select = "*[position()>2]">
  2753. <xsl:apply-templates select = "." mode="semantics"/>
  2754. </xsl:for-each>
  2755. </xsl:if>
  2756. <xsl:if test="not(*[2]=degree) and not(*[2]=momentabout)">
  2757. <xsl:for-each select = "*[position()>1]">
  2758. <xsl:apply-templates select = "." mode="semantics"/>
  2759. </xsl:for-each>
  2760. </xsl:if>
  2761. </mfenced>
  2762. </xsl:template>
  2763. <!-- ***************** LINEAR ALGEBRA ***************** -->
  2764. <xsl:template match="vector">
  2765. <mfenced separators="">
  2766. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2767. <xsl:attribute name="xref">
  2768. <xsl:value-of select="@id"/>
  2769. </xsl:attribute>
  2770. </xsl:if>
  2771. <mtable columnalign="center">
  2772. <xsl:for-each select="*">
  2773. <mtr>
  2774. <mtd> <xsl:apply-templates select="." mode = "semantics"/> </mtd>
  2775. </mtr>
  2776. </xsl:for-each>
  2777. </mtable>
  2778. </mfenced>
  2779. </xsl:template>
  2780. <xsl:template match = "matrix">
  2781. <mfenced separators="">
  2782. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2783. <xsl:attribute name="xref">
  2784. <xsl:value-of select="@id"/>
  2785. </xsl:attribute>
  2786. </xsl:if>
  2787. <mtable>
  2788. <xsl:apply-templates mode = "semantics"/>
  2789. </mtable>
  2790. </mfenced>
  2791. </xsl:template>
  2792. <xsl:template match = "matrixrow">
  2793. <mtr>
  2794. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2795. <xsl:attribute name="xref">
  2796. <xsl:value-of select="@id"/>
  2797. </xsl:attribute>
  2798. </xsl:if>
  2799. <xsl:for-each select="*">
  2800. <mtd>
  2801. <xsl:apply-templates select="." mode = "semantics"/>
  2802. </mtd>
  2803. </xsl:for-each>
  2804. </mtr>
  2805. </xsl:template>
  2806. <xsl:template match = "apply[determinant[1]]">
  2807. <mrow>
  2808. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2809. <xsl:attribute name="xref">
  2810. <xsl:value-of select="@id"/>
  2811. </xsl:attribute>
  2812. </xsl:if>
  2813. <mo> det </mo>
  2814. <mspace width="0.2em" linebreak="nobreak"/>
  2815. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2816. </mrow>
  2817. </xsl:template>
  2818. <xsl:template match = "apply[transpose[1]]">
  2819. <msup>
  2820. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2821. <xsl:attribute name="xref">
  2822. <xsl:value-of select="@id"/>
  2823. </xsl:attribute>
  2824. </xsl:if>
  2825. <xsl:apply-templates select = "*[2]" mode = "semantics"/>
  2826. <mo> T </mo>
  2827. </msup>
  2828. </xsl:template>
  2829. <xsl:template match = "apply[selector[1]]">
  2830. <msub>
  2831. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2832. <xsl:attribute name="xref">
  2833. <xsl:value-of select="@id"/>
  2834. </xsl:attribute>
  2835. </xsl:if>
  2836. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  2837. <mfenced open="" close="">
  2838. <xsl:for-each select="*[position()>2]">
  2839. <xsl:apply-templates select="." mode = "semantics"/>
  2840. </xsl:for-each>
  2841. </mfenced>
  2842. </msub>
  2843. </xsl:template>
  2844. <xsl:template match = "apply[vectorproduct[1] |
  2845. scalarproduct[1] | outerproduct[1]]">
  2846. <mrow>
  2847. <xsl:if test="($SEM_SW=$SEM_XREF or $SEM_SW=$SEM_XREF_EXT) and @id">
  2848. <xsl:attribute name="xref">
  2849. <xsl:value-of select="@id"/>
  2850. </xsl:attribute>
  2851. </xsl:if>
  2852. <xsl:apply-templates select="*[2]" mode = "semantics"/>
  2853. <mo>
  2854. <xsl:if test="vectorproduct[1]">
  2855. <xsl:text disable-output-escaping='yes'>&amp;#x00D7;</xsl:text>
  2856. </xsl:if>
  2857. <xsl:if test="scalarproduct[1]">
  2858. <xsl:text disable-output-escaping='yes'>&amp;#x22C5;</xsl:text>
  2859. </xsl:if>
  2860. <xsl:if test="outerproduct[1]">
  2861. <xsl:text disable-output-escaping='yes'>&amp;#x2297;</xsl:text>
  2862. </xsl:if>
  2863. </mo>
  2864. <xsl:apply-templates select="*[3]" mode = "semantics"/>
  2865. </mrow>
  2866. </xsl:template>
  2867. <!-- ***************** CONSTANT and SYMBOL ELEMENTS ***************** -->
  2868. <xsl:template match="integers">
  2869. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2124;</xsl:text> </mo>
  2870. </xsl:template>
  2871. <xsl:template match="reals">
  2872. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x211D;</xsl:text> </mo>
  2873. </xsl:template>
  2874. <xsl:template match="rationals">
  2875. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x211A;</xsl:text> </mo>
  2876. </xsl:template>
  2877. <xsl:template match="naturalnumbers">
  2878. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2115;</xsl:text> </mo>
  2879. </xsl:template>
  2880. <xsl:template match="complexes">
  2881. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2102;</xsl:text> </mo>
  2882. </xsl:template>
  2883. <xsl:template match="primes">
  2884. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2119;</xsl:text> </mo>
  2885. </xsl:template>
  2886. <xsl:template match="exponentiale">
  2887. <mn> <xsl:text disable-output-escaping='yes'>&amp;#x2147;</xsl:text> </mn>
  2888. </xsl:template>
  2889. <xsl:template match="imaginaryi">
  2890. <mn> <xsl:text disable-output-escaping='yes'>&amp;#x2148;</xsl:text> </mn>
  2891. </xsl:template>
  2892. <xsl:template match="notanumber">
  2893. <mo> NaN </mo>
  2894. </xsl:template>
  2895. <xsl:template match="true">
  2896. <mo> true </mo>
  2897. </xsl:template>
  2898. <xsl:template match="false">
  2899. <mo> false </mo>
  2900. </xsl:template>
  2901. <xsl:template match="emptyset">
  2902. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x2205;</xsl:text> </mo>
  2903. </xsl:template>
  2904. <xsl:template match="pi">
  2905. <mn> <xsl:text disable-output-escaping='yes'>&amp;#x03C0;</xsl:text> </mn>
  2906. </xsl:template>
  2907. <xsl:template match="eulergamma">
  2908. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x213D;</xsl:text> </mo>
  2909. </xsl:template>
  2910. <xsl:template match="infinity">
  2911. <mo> <xsl:text disable-output-escaping='yes'>&amp;#x221E;</xsl:text> </mo>
  2912. </xsl:template>
  2913. </xsl:stylesheet>