simple_mmlctop.xsl 112 KB

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