]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/mathml_editor/xsl/tml-mmlp.xsl
Initial revision
[helm.git] / helm / DEVEL / mathml_editor / xsl / tml-mmlp.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet
3      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
4      xmlns:tml="http://helm.cs.unibo.it/2002/TML"
5      xmlns:m="http://www.w3.org/1998/Math/MathML"
6      version="1.0">
7
8   <xsl:output indent="yes"/>
9
10   <xsl:param name="id" select="/.."/>
11
12   <xsl:template match="/">
13     <xsl:choose>
14       <xsl:when test="$id">
15         <xsl:apply-templates select="descendant::*[@id=$id]"/>
16       </xsl:when>
17       <xsl:otherwise>
18         <xsl:apply-templates/>
19       </xsl:otherwise>
20     </xsl:choose>
21   </xsl:template>
22
23   <xsl:template match="tml:math">
24     <m:math>
25       <xsl:if test="@id">
26         <xsl:attribute name="xref">
27           <xsl:value-of select="@id"/>
28         </xsl:attribute>
29       </xsl:if>
30        <xsl:if test="@display='1'">
31         <xsl:attribute name="display">block</xsl:attribute>
32       </xsl:if>
33       <xsl:attribute name="display">block</xsl:attribute>
34       <xsl:apply-templates select="*"/>
35     </m:math>
36   </xsl:template>
37
38   <xsl:template match="tml:i">
39     <m:mi>
40       <xsl:if test="@id">
41         <xsl:attribute name="xref">
42           <xsl:value-of select="@id"/>
43         </xsl:attribute>
44       </xsl:if>
45       <xsl:value-of select="@val"/>
46     </m:mi>
47   </xsl:template>
48
49   <xsl:template match="tml:n">
50     <m:mn>
51       <xsl:if test="@id">
52         <xsl:attribute name="xref">
53           <xsl:value-of select="@id"/>
54         </xsl:attribute>
55       </xsl:if>
56       <xsl:value-of select="@val"/>
57     </m:mn>
58   </xsl:template>
59
60   <xsl:template match="tml:o">
61     <m:mo>
62       <xsl:if test="@id">
63         <xsl:attribute name="xref">
64           <xsl:value-of select="@id"/>
65         </xsl:attribute>
66       </xsl:if>
67       <xsl:value-of select="@val"/>
68     </m:mo>
69   </xsl:template>
70
71   <xsl:template match="tml:cursor">
72     <xsl:choose>
73       <xsl:when test="substring(@val,1,1)='\'">
74         <m:mrow>
75           <xsl:if test="@id">
76             <xsl:attribute name="xref">
77               <xsl:value-of select="@id"/>
78             </xsl:attribute>
79           </xsl:if>
80           <m:mo stretchy="false">&#x2329;</m:mo>
81           <m:mtext mathcolor="blue"><xsl:value-of select="@val"/></m:mtext>
82           <m:mo stretchy="false">&#x232a;</m:mo>
83         </m:mrow>
84       </xsl:when>
85       <xsl:otherwise>
86         <m:mtext mathcolor="blue">
87           <xsl:if test="@id">
88             <xsl:attribute name="xref">
89               <xsl:value-of select="@id"/>
90             </xsl:attribute>
91           </xsl:if>
92           <xsl:value-of select="@val"/>
93         </m:mtext>
94       </xsl:otherwise>
95     </xsl:choose>
96   </xsl:template>
97
98   <xsl:template match="tml:sb[@under='1'][*[1]/tml:sp[@over='1']]">
99     <m:munderover>
100       <xsl:if test="@id">
101         <xsl:attribute name="xref">
102           <xsl:value-of select="@id"/>
103         </xsl:attribute>
104       </xsl:if>
105       <xsl:apply-templates select="*[1]/*[1]"/>
106       <xsl:apply-templates select="*[2]"/>
107       <xsl:apply-templates select="*[1]/*[2]"/>
108     </m:munderover>
109   </xsl:template>
110
111   <xsl:template match="tml:sb[@under='1']">
112     <m:munder>
113       <xsl:if test="@id">
114         <xsl:attribute name="xref">
115           <xsl:value-of select="@id"/>
116         </xsl:attribute>
117       </xsl:if>
118       <xsl:apply-templates select="*[1]"/>
119       <xsl:apply-templates select="*[2]"/>
120     </m:munder>
121   </xsl:template>
122
123   <xsl:template match="tml:sb[*[1][self::tml:sp[not(@over) or @over='0']]]">
124     <m:msubsup>
125       <xsl:if test="@id">
126         <xsl:attribute name="xref">
127           <xsl:value-of select="@id"/>
128         </xsl:attribute>
129       </xsl:if>
130       <xsl:apply-templates select="*[1]/*[1]"/>
131       <xsl:apply-templates select="*[1]"/>
132       <xsl:apply-templates select="*[1]/*[2]"/>
133     </m:msubsup>
134   </xsl:template>
135
136   <xsl:template match="tml:sb">
137     <m:msub>
138       <xsl:if test="@id">
139         <xsl:attribute name="xref">
140           <xsl:value-of select="@id"/>
141         </xsl:attribute>
142       </xsl:if>
143       <xsl:apply-templates select="*[1]"/>
144       <xsl:apply-templates select="*[2]"/>
145     </m:msub>
146   </xsl:template>
147
148   <xsl:template match="tml:sp[@over='1'][*[1]/tml:sb[@under='1']]">
149     <m:munderover>
150       <xsl:if test="@id">
151         <xsl:attribute name="xref">
152           <xsl:value-of select="@id"/>
153         </xsl:attribute>
154       </xsl:if>
155       <xsl:apply-templates select="*[1]/*[1]"/>
156       <xsl:apply-templates select="*[1]/*[2]"/>
157       <xsl:apply-templates select="*[2]"/>
158     </m:munderover>
159   </xsl:template>
160
161   <xsl:template match="tml:sp[@over='1']">
162     <m:mover>
163       <xsl:if test="@id">
164         <xsl:attribute name="xref">
165           <xsl:value-of select="@id"/>
166         </xsl:attribute>
167       </xsl:if>
168       <xsl:apply-templates select="*[1]"/>
169       <xsl:apply-templates select="*[2]"/>
170     </m:mover>
171   </xsl:template>
172
173   <xsl:template match="tml:sp[*[1][self::tml:sb[not(@over) or @over='0']]]">
174     <m:msubsup>
175       <xsl:if test="@id">
176         <xsl:attribute name="xref">
177           <xsl:value-of select="@id"/>
178         </xsl:attribute>
179       </xsl:if>
180       <xsl:apply-templates select="*[1]/*[1]"/>
181       <xsl:apply-templates select="*[1]/*[2]"/>
182       <xsl:apply-templates select="*[2]"/>
183     </m:msubsup>
184   </xsl:template>
185
186   <xsl:template match="tml:sp">
187     <m:msup>
188       <xsl:if test="@id">
189         <xsl:attribute name="xref">
190           <xsl:value-of select="@id"/>
191         </xsl:attribute>
192       </xsl:if>
193       <xsl:apply-templates select="*[1]"/>
194       <xsl:apply-templates select="*[2]"/>
195     </m:msup>
196   </xsl:template>
197
198   <xsl:template match="tml:g">
199     <xsl:choose>
200       <xsl:when test="not(@id) and count(*) = 1">
201         <xsl:apply-templates select="*[1]"/>
202       </xsl:when>
203       <xsl:when test="tml:cursor">
204         <m:mstyle mathbackground="#e0e0e0">
205           <xsl:if test="@id">
206             <xsl:attribute name="xref">
207               <xsl:value-of select="@id"/>
208             </xsl:attribute>
209           </xsl:if>
210           <m:mrow>
211             <xsl:apply-templates select="*"/>
212           </m:mrow>
213         </m:mstyle>
214       </xsl:when>
215        <xsl:otherwise>
216         <m:mrow>
217           <xsl:if test="@id">
218             <xsl:attribute name="xref">
219               <xsl:value-of select="@id"/>
220             </xsl:attribute>
221           </xsl:if>
222           <xsl:apply-templates select="*"/>
223         </m:mrow>
224       </xsl:otherwise>
225     </xsl:choose>
226   </xsl:template>
227
228   <xsl:template match="tml:row">
229     <m:mtr>
230       <xsl:apply-templates select="cell"/>
231     </m:mtr>
232   </xsl:template>
233
234   <xsl:template match="tml:cell">
235     <m:mtd>
236       <xsl:apply-templates select="*"/>
237     </m:mtd>
238   </xsl:template>
239
240 <!--/// CONTROL SEQUENCES ///-->
241
242   <xsl:template match="tml:c">
243     <m:mrow>
244       <xsl:if test="@id">
245         <xsl:attribute name="xref">
246           <xsl:value-of select="@id"/>
247         </xsl:attribute>
248       </xsl:if>
249       <m:mtext mathcolor="blue">\<xsl:value-of select="@name"/></m:mtext>
250       <xsl:apply-templates select="*"/>
251     </m:mrow>
252   </xsl:template>
253
254   <xsl:template match="tml:c[@name='fun' and count(*)=3]">
255     <m:mrow>
256       <xsl:if test="@id">
257         <xsl:attribute name="xref">
258           <xsl:value-of select="@id"/>
259         </xsl:attribute>
260       </xsl:if>
261       <m:mo mathcolor="red">&#x03bb;</m:mo>
262       <xsl:apply-templates select="*[1]"/>
263       <m:mo>:</m:mo>
264       <xsl:apply-templates select="*[2]"/>
265       <m:mo>.</m:mo>
266       <xsl:apply-templates select="*[3]"/>
267     </m:mrow>
268   </xsl:template>
269
270   <xsl:template match="tml:c[@name='not'][*[1][self::tml:o]]">
271 <!-- not -->
272     <m:mo>
273       <xsl:if test="@id">
274         <xsl:attribute name="xref">
275           <xsl:value-of select="@id"/>
276         </xsl:attribute>
277       </xsl:if>
278       <xsl:value-of select="*[1]/@val"/>&#x0338;</m:mo>
279   </xsl:template>
280
281   <xsl:template match="tml:c[@name='buildrel']">
282 <!-- buildrel -->
283     <m:mover>
284       <xsl:if test="@id">
285         <xsl:attribute name="xref">
286           <xsl:value-of select="@id"/>
287         </xsl:attribute>
288       </xsl:if>
289       <xsl:apply-templates select="*[2]"/>
290       <xsl:apply-templates select="*[1]"/>
291     </m:mover>
292   </xsl:template>
293
294   <xsl:template match="tml:c[@name='left' or @name='right'][*[1][self::tml:o]]">
295 <!-- left -->
296     <m:mo stretchy="true">
297       <xsl:if test="@id">
298         <xsl:attribute name="xref">
299           <xsl:value-of select="@id"/>
300         </xsl:attribute>
301       </xsl:if>
302       <xsl:value-of select="*[1]/@val"/>
303     </m:mo>
304   </xsl:template>
305
306   <xsl:template match="tml:c[@name='bigl' or @name='bigr' or @name='bigm' or @name='big'][*[1][self::tml:o]]">
307 <!-- bigl -->
308     <m:mo stretchy="true" minsize="8.5pt">
309       <xsl:if test="@id">
310         <xsl:attribute name="xref">
311           <xsl:value-of select="@id"/>
312         </xsl:attribute>
313       </xsl:if>
314       <xsl:value-of select="*[1]/@val"/>
315     </m:mo>
316   </xsl:template>
317
318   <xsl:template match="tml:c[@name='Bigl' or @name='Bigr' or @name='Bigm'][*[1][self::tml:o]]">
319 <!-- Bigl -->
320     <m:mo stretchy="true" minsize="11.5pt">
321       <xsl:if test="@id">
322         <xsl:attribute name="xref">
323           <xsl:value-of select="@id"/>
324         </xsl:attribute>
325       </xsl:if>
326       <xsl:value-of select="*[1]/@val"/>
327     </m:mo>
328   </xsl:template>
329
330   <xsl:template match="tml:c[@name='biggl' or @name='biggr' or @name='biggm'][*[1][self::tml:o]]">
331 <!-- biggl -->
332     <m:mo stretchy="true" minsize="14.5pt">
333       <xsl:if test="@id">
334         <xsl:attribute name="xref">
335           <xsl:value-of select="@id"/>
336         </xsl:attribute>
337       </xsl:if>
338       <xsl:value-of select="*[1]/@val"/>
339     </m:mo>
340   </xsl:template>
341
342   <xsl:template match="tml:c[@name='Biggl' or @name='Biggr' or @name='Biggm'][*[1][self::tml:o]]">
343 <!-- biggl -->
344     <m:mo stretchy="true" minsize="17.5pt">
345       <xsl:if test="@id">
346         <xsl:attribute name="xref">
347           <xsl:value-of select="@id"/>
348         </xsl:attribute>
349       </xsl:if>
350       <xsl:value-of select="*[1]/@val"/>
351     </m:mo>
352   </xsl:template>
353
354   <xsl:template match="tml:c[@name='hat']">
355 <!-- hat -->
356     <m:mover accent="true">
357       <xsl:if test="@id">
358         <xsl:attribute name="xref">
359           <xsl:value-of select="@id"/>
360         </xsl:attribute>
361       </xsl:if>
362       <xsl:apply-templates select="*[1]"/>
363       <m:mo>&#x0302;</m:mo>
364     </m:mover>
365   </xsl:template>
366
367   <xsl:template match="tml:c[@name='widehat']">
368 <!-- widehat -->
369     <m:mover accent="false">
370       <xsl:if test="@id">
371         <xsl:attribute name="xref">
372           <xsl:value-of select="@id"/>
373         </xsl:attribute>
374       </xsl:if>
375       <xsl:apply-templates select="*[1]"/>
376       <m:mo stretchy="true">&#x0302;</m:mo>
377     </m:mover>
378   </xsl:template>
379
380   <xsl:template match="tml:c[@name='check']">
381 <!-- check -->
382     <m:mover accent="true">
383       <xsl:if test="@id">
384         <xsl:attribute name="xref">
385           <xsl:value-of select="@id"/>
386         </xsl:attribute>
387       </xsl:if>
388       <xsl:apply-templates select="*[1]"/>
389       <m:mo>&#x030c;</m:mo>
390     </m:mover>
391   </xsl:template>
392
393   <xsl:template match="tml:c[@name='tilde']">
394 <!-- tilde -->
395     <m:mover accent="true">
396       <xsl:if test="@id">
397         <xsl:attribute name="xref">
398           <xsl:value-of select="@id"/>
399         </xsl:attribute>
400       </xsl:if>
401       <xsl:apply-templates select="*[1]"/>
402       <m:mo>&#x0303;</m:mo>
403     </m:mover>
404   </xsl:template>
405
406   <xsl:template match="tml:c[@name='widetilde']">
407 <!-- widetilde -->
408     <m:mover>
409       <xsl:if test="@id">
410         <xsl:attribute name="xref">
411           <xsl:value-of select="@id"/>
412         </xsl:attribute>
413       </xsl:if>
414       <xsl:apply-templates select="*[1]"/>
415       <m:mo stretchy="true">&#x0303;</m:mo>
416     </m:mover>>
417   </xsl:template>
418
419   <xsl:template match="tml:c[@name='acute']">
420 <!-- acute -->
421     <m:mover accent="true">
422       <xsl:if test="@id">
423         <xsl:attribute name="xref">
424           <xsl:value-of select="@id"/>
425         </xsl:attribute>
426       </xsl:if>
427       <xsl:apply-templates select="*[1]"/>
428       <m:mo>&#x0301;</m:mo>
429     </m:mover>
430   </xsl:template>
431
432   <xsl:template match="tml:c[@name='grave']">
433 <!-- grave -->
434     <m:mover accent="true">
435       <xsl:if test="@id">
436         <xsl:attribute name="xref">
437           <xsl:value-of select="@id"/>
438         </xsl:attribute>
439       </xsl:if>
440       <xsl:apply-templates select="*[1]"/>
441       <m:mo>&#x0300;</m:mo>
442     </m:mover>>
443   </xsl:template>
444
445   <xsl:template match="tml:c[@name='dot']">
446 <!-- dot -->
447     <m:mover accent="true">
448       <xsl:if test="@id">
449         <xsl:attribute name="xref">
450           <xsl:value-of select="@id"/>
451         </xsl:attribute>
452       </xsl:if>
453       <xsl:apply-templates select="*[1]"/>
454       <m:mo>&#x0307;</m:mo>
455     </m:mover>
456   </xsl:template>
457
458   <xsl:template match="tml:c[@name='ddot']">
459 <!-- ddot -->
460     <m:mover accent="true">
461       <xsl:if test="@id">
462         <xsl:attribute name="xref">
463           <xsl:value-of select="@id"/>
464         </xsl:attribute>
465       </xsl:if>
466       <xsl:apply-templates select="*[1]"/>
467       <m:mo>&#x0308;</m:mo>
468     </m:mover>
469   </xsl:template>
470
471   <xsl:template match="tml:c[@name='breve']">
472 <!-- breve -->
473     <m:mover accent="true">
474       <xsl:if test="@id">
475         <xsl:attribute name="xref">
476           <xsl:value-of select="@id"/>
477         </xsl:attribute>
478       </xsl:if>
479       <xsl:apply-templates select="*[1]"/>
480       <m:mo>&#x0306;</m:mo>
481     </m:mover>
482   </xsl:template>
483
484   <xsl:template match="tml:c[@name='bar']">
485 <!-- bar -->
486     <m:mover accent="true">
487       <xsl:if test="@id">
488         <xsl:attribute name="xref">
489           <xsl:value-of select="@id"/>
490         </xsl:attribute>
491       </xsl:if>
492       <xsl:apply-templates select="*[1]"/>
493       <m:mo>&#x0304;</m:mo>
494     </m:mover>
495   </xsl:template>
496
497   <xsl:template match="tml:c[@name='vec']">
498 <!-- vec -->
499     <m:mover accent="true">
500       <xsl:if test="@id">
501         <xsl:attribute name="xref">
502           <xsl:value-of select="@id"/>
503         </xsl:attribute>
504       </xsl:if>
505       <xsl:apply-templates select="*[1]"/>
506       <m:mo>&#x20d7;</m:mo>
507     </m:mover>
508   </xsl:template>
509
510   <xsl:template match="tml:c[@name='overline']">
511 <!-- overline -->
512     <m:mover>
513       <xsl:if test="@id">
514         <xsl:attribute name="xref">
515           <xsl:value-of select="@id"/>
516         </xsl:attribute>
517       </xsl:if>
518       <xsl:apply-templates select="*[1]"/>
519       <m:mo stretchy="true">&#x0305;</m:mo>
520     </m:mover>>
521   </xsl:template>
522
523   <xsl:template match="tml:c[@name='underline']">
524 <!-- underline -->
525     <m:munder>
526       <xsl:if test="@id">
527         <xsl:attribute name="xref">
528           <xsl:value-of select="@id"/>
529         </xsl:attribute>
530       </xsl:if>
531       <xsl:apply-templates select="*[1]"/>
532       <m:mo stretchy="true">&#x0332;</m:mo>
533     </m:munder>
534   </xsl:template>
535
536   <xsl:template match="tml:c[@name='sqrt']">
537 <!-- sqrt -->
538     <m:msqrt>
539       <xsl:if test="@id">
540         <xsl:attribute name="xref">
541           <xsl:value-of select="@id"/>
542         </xsl:attribute>
543       </xsl:if>
544       <xsl:apply-templates select="*"/>
545     </m:msqrt>
546   </xsl:template>
547
548   <xsl:template match="tml:c[@name='root']">
549 <!-- root -->
550     <m:mroot>
551       <xsl:if test="@id">
552         <xsl:attribute name="xref">
553           <xsl:value-of select="@id"/>
554         </xsl:attribute>
555       </xsl:if>
556       <xsl:apply-templates select="*[2]"/>
557       <xsl:apply-templates select="*[1]"/>
558     </m:mroot>
559   </xsl:template>
560
561   <xsl:template match="tml:c[@name='frac']">
562 <!-- frac -->
563     <m:mfrac>
564       <xsl:if test="@id">
565         <xsl:attribute name="xref">
566           <xsl:value-of select="@id"/>
567         </xsl:attribute>
568       </xsl:if>
569       <xsl:apply-templates select="*[1]"/>
570       <xsl:apply-templates select="*[2]"/>
571     </m:mfrac>
572   </xsl:template>
573
574   <xsl:template match="tml:c[@name='over']">
575 <!-- over -->
576     <m:mfrac>
577       <xsl:if test="@id">
578         <xsl:attribute name="xref">
579           <xsl:value-of select="@id"/>
580         </xsl:attribute>
581       </xsl:if>
582       <xsl:apply-templates select="*[1]"/>
583       <xsl:apply-templates select="*[2]"/>
584     </m:mfrac>
585   </xsl:template>
586
587   <xsl:template match="tml:c[@name='atop']">
588 <!-- atop -->
589     <m:mfrac linethickness="0">
590       <xsl:if test="@id">
591         <xsl:attribute name="xref">
592           <xsl:value-of select="@id"/>
593         </xsl:attribute>
594       </xsl:if>
595       <xsl:apply-templates select="*[1]"/>
596       <xsl:apply-templates select="*[2]"/>
597     </m:mfrac>
598   </xsl:template>
599
600   <xsl:template match="tml:c[@name='choose']">
601 <!-- choose -->
602     <m:mrow>
603       <xsl:if test="@id">
604         <xsl:attribute name="xref">
605           <xsl:value-of select="@id"/>
606         </xsl:attribute>
607       </xsl:if>
608       <m:mo stretchy="true">(</m:mo>
609       <m:mfrac linethickness="0">
610         <xsl:apply-templates select="*[1]"/>
611         <xsl:apply-templates select="*[2]"/>
612       </m:mfrac>
613       <m:mo stretchy="true">)</m:mo>
614     </m:mrow>
615   </xsl:template>
616
617   <xsl:template match="tml:c[@name='brace']">
618 <!-- brace -->
619     <m:mrow>
620       <xsl:if test="@id">
621         <xsl:attribute name="xref">
622           <xsl:value-of select="@id"/>
623         </xsl:attribute>
624       </xsl:if>
625       <m:mo stretchy="true">{</m:mo>
626       <m:mfrac linethickness="0">
627         <xsl:apply-templates select="*[1]"/>
628         <xsl:apply-templates select="*[2]"/>
629       </m:mfrac>
630       <m:mo stretchy="true">}</m:mo>
631     </m:mrow>
632   </xsl:template>
633
634   <xsl:template match="tml:c[@name='brack']">
635 <!-- brack -->
636     <m:mrow>
637       <xsl:if test="@id">
638         <xsl:attribute name="xref">
639           <xsl:value-of select="@id"/>
640         </xsl:attribute>
641       </xsl:if>
642       <m:mo stretchy="true">[</m:mo>
643       <m:mfrac linethickness="0">
644         <xsl:apply-templates select="*[1]"/>
645         <xsl:apply-templates select="*[2]"/>
646       </m:mfrac>
647       <m:mo stretchy="true">]</m:mo>
648     </m:mrow>
649   </xsl:template>
650
651   <xsl:template match="tml:c[@name='displaystyle']">
652 <!-- displaystyle -->
653     <m:mstyle displaystyle="true">
654       <xsl:if test="@id">
655         <xsl:attribute name="xref">
656           <xsl:value-of select="@id"/>
657         </xsl:attribute>
658       </xsl:if>
659       <xsl:apply-templates select="*[1]"/>
660     </m:mstyle>
661   </xsl:template>
662
663   <xsl:template match="tml:c[@name='textstyle']">
664 <!-- textstyle -->
665     <m:mstyle scriptlevel="0">
666       <xsl:if test="@id">
667         <xsl:attribute name="xref">
668           <xsl:value-of select="@id"/>
669         </xsl:attribute>
670       </xsl:if>
671       <xsl:apply-templates select="*[1]"/>
672     </m:mstyle>
673   </xsl:template>
674
675   <xsl:template match="tml:c[@name='scriptstyle']">
676 <!-- scriptstyle -->
677     <m:mstyle scriptlevel="1">
678       <xsl:if test="@id">
679         <xsl:attribute name="xref">
680           <xsl:value-of select="@id"/>
681         </xsl:attribute>
682       </xsl:if>
683       <xsl:apply-templates select="*[1]"/>
684     </m:mstyle>
685   </xsl:template>
686
687   <xsl:template match="tml:c[@name='scriptscriptstyle']">
688 <!-- scriptscriptstyle -->
689     <m:mstyle scriptlevel="2">
690       <xsl:if test="@id">
691         <xsl:attribute name="xref">
692           <xsl:value-of select="@id"/>
693         </xsl:attribute>
694       </xsl:if>
695       <xsl:apply-templates select="*[1]"/>
696     </m:mstyle>
697   </xsl:template>
698
699   <xsl:template match="tml:c[@name='pmod']">
700 <!-- pmod -->
701     <m:mrow>
702       <xsl:if test="@id">
703         <xsl:attribute name="xref">
704           <xsl:value-of select="@id"/>
705         </xsl:attribute>
706       </xsl:if>
707       <m:mo>(</m:mo>
708       <m:mrow>
709         <m:mo>mod</m:mo>
710         <xsl:apply-templates select="*[1]"/>
711       </m:mrow>
712       <m:mo>)</m:mo>
713     </m:mrow>
714   </xsl:template>
715
716   <xsl:template match="tml:c[@name='rm']">
717 <!-- rm -->
718     <m:mstyle mathvariant="normal">
719       <xsl:if test="@id">
720         <xsl:attribute name="xref">
721           <xsl:value-of select="@id"/>
722         </xsl:attribute>
723       </xsl:if>
724       <xsl:apply-templates select="*[1]"/>
725     </m:mstyle>
726   </xsl:template>
727
728   <xsl:template match="tml:c[@name='bf']">
729 <!-- bf -->
730     <m:mstyle mathvariant="bold">
731       <xsl:if test="@id">
732         <xsl:attribute name="xref">
733           <xsl:value-of select="@id"/>
734         </xsl:attribute>
735       </xsl:if>
736       <xsl:apply-templates select="*[1]"/>
737     </m:mstyle>
738   </xsl:template>
739
740   <xsl:template match="tml:c[@name='tt']">
741 <!-- tt -->
742     <m:mstyle mathvariant="monospace">
743       <xsl:if test="@id">
744         <xsl:attribute name="xref">
745           <xsl:value-of select="@id"/>
746         </xsl:attribute>
747       </xsl:if>
748       <xsl:apply-templates select="*[1]"/>
749     </m:mstyle>
750   </xsl:template>
751
752   <xsl:template match="tml:c[@name='sl']">
753 <!-- sl -->
754     <m:mstyle mathvariant="italic">
755       <xsl:if test="@id">
756         <xsl:attribute name="xref">
757           <xsl:value-of select="@id"/>
758         </xsl:attribute>
759       </xsl:if>
760       <xsl:apply-templates select="*[1]"/>
761     </m:mstyle>
762   </xsl:template>
763
764   <xsl:template match="tml:c[@name='it']">
765 <!-- it -->
766     <m:mstyle mathvariant="italic">
767       <xsl:if test="@id">
768         <xsl:attribute name="xref">
769           <xsl:value-of select="@id"/>
770         </xsl:attribute>
771       </xsl:if>
772       <xsl:apply-templates select="*[1]"/>
773     </m:mstyle>
774   </xsl:template>
775
776   <xsl:template match="tml:c[@name=',']">
777 <!-- , -->
778     <m:mspace width="thinmathspace">
779       <xsl:if test="@id">
780         <xsl:attribute name="xref">
781           <xsl:value-of select="@id"/>
782         </xsl:attribute>
783       </xsl:if>
784     </m:mspace>
785   </xsl:template>
786
787   <xsl:template match="tml:c[@name='&gt;']">
788 <!-- > -->
789     <m:mspace width="mediummathspace">
790       <xsl:if test="@id">
791         <xsl:attribute name="xref">
792           <xsl:value-of select="@id"/>
793         </xsl:attribute>
794       </xsl:if>
795     </m:mspace>
796   </xsl:template>
797
798   <xsl:template match="tml:c[@name=';']">
799 <!-- ; -->
800     <m:mspace width="thickmathspace">
801       <xsl:if test="@id">
802         <xsl:attribute name="xref">
803           <xsl:value-of select="@id"/>
804         </xsl:attribute>
805       </xsl:if>
806     </m:mspace>
807   </xsl:template>
808
809   <xsl:template match="tml:c[@name='!']">
810 <!-- ! -->
811     <m:mspace width="-0.166667em">
812       <xsl:if test="@id">
813         <xsl:attribute name="xref">
814           <xsl:value-of select="@id"/>
815         </xsl:attribute>
816       </xsl:if>
817     </m:mspace>
818   </xsl:template>
819
820   <xsl:template name="table-content">
821       <xsl:choose>
822         <xsl:when test="tml:row">
823           <xsl:apply-templates select="tml:row"/>
824         </xsl:when>
825         <xsl:otherwise>
826           <m:mtr>
827             <m:mtd>
828               <xsl:apply-templates select="*"/>
829             </m:mtd>
830           </m:mtr>
831         </xsl:otherwise>
832       </xsl:choose>
833   </xsl:template>
834
835   <xsl:template match="tml:c[@name='matrix']">
836 <!-- matrix -->
837     <m:mtable>
838       <xsl:if test="@id">
839         <xsl:attribute name="xref">
840           <xsl:value-of select="@id"/>
841         </xsl:attribute>
842       </xsl:if>
843       <xsl:call-template name="table-content"/>
844     </m:mtable>
845   </xsl:template>
846
847   <xsl:template match="tml:row">
848     <m:mtr>
849       <xsl:apply-templates select="tml:cell"/>
850     </m:mtr>
851   </xsl:template>
852
853   <xsl:template match="tml:cell">
854     <m:mtd>
855       <xsl:apply-templates select="*"/>
856     </m:mtd>
857   </xsl:template>
858
859   <xsl:template match="tml:c[@name='pmatrix']">
860 <!-- pmatrix -->
861     <m:mrow>
862       <xsl:if test="@id">
863         <xsl:attribute name="xref">
864           <xsl:value-of select="@id"/>
865         </xsl:attribute>
866       </xsl:if>
867       <m:mo stretchy="true">(</m:mo>
868       <m:mtable>
869         <xsl:call-template name="table-content"/>
870       </m:mtable>
871       <m:mo stretchy="true">)</m:mo>
872     </m:mrow>
873   </xsl:template>
874
875   <xsl:template match="tml:c[@name='bordermatrix']">
876 <!-- bordermatrix -->
877     <m:mtable>
878       <xsl:if test="@id">
879         <xsl:attribute name="xref">
880           <xsl:value-of select="@id"/>
881         </xsl:attribute>
882       </xsl:if>
883       <m:mtr>
884         <xsl:apply-templates select="tml:row[1]/tml:cell[1]"/>
885         <m:mtd/>
886         <xsl:apply-templates select="tml:row[1]/tml:cell[position() &gt; 1]"/>
887         <m:mtd/>
888       </m:mtr>
889       <xsl:for-each select="tml:row[position() &gt; 1]">
890         <m:mtr>
891           <xsl:apply-templates select="tml:cell[1]"/>
892           <xsl:if test="position() = 1">
893             <m:mtd rowspan="{count(../tml:row) - 1}">
894               <m:mo stretchy="true">(</m:mo>
895             </m:mtd>
896           </xsl:if>
897           <xsl:apply-templates select="tml:cell[position() &gt; 1]"/>
898           <xsl:if test="position() = 1">
899             <m:mtd rowspan="{count(../tml:row) - 1}">
900               <m:mo stretchy="true">)</m:mo>
901             </m:mtd>
902           </xsl:if>         
903         </m:mtr>
904       </xsl:for-each>      
905     </m:mtable>
906   </xsl:template>
907
908   <xsl:template match="tml:c[@name='overbrace']">
909 <!-- overbrace -->
910     <m:mover>
911       <xsl:if test="@id">
912         <xsl:attribute name="xref">
913           <xsl:value-of select="@id"/>
914         </xsl:attribute>
915       </xsl:if>
916       <xsl:apply-templates select="*[1]"/>
917       <m:mo stretchy="true">????</m:mo>
918     </m:mover>>
919   </xsl:template>
920
921   <xsl:template match="tml:c[@name='underbrace']">
922 <!-- underbrace -->
923     <m:munder>
924       <xsl:if test="@id">
925         <xsl:attribute name="xref">
926           <xsl:value-of select="@id"/>
927         </xsl:attribute>
928       </xsl:if>
929       <xsl:apply-templates select="*[1]"/>
930       <m:mo stretchy="true">????</m:mo>
931     </m:munder>
932   </xsl:template>
933
934   <xsl:template match="tml:c[@name='cases']">
935 <!-- cases -->
936     <m:mrow>
937       <xsl:if test="@id">
938         <xsl:attribute name="xref">
939           <xsl:value-of select="@id"/>
940         </xsl:attribute>
941       </xsl:if>
942       <m:mo stretchy="true">{</m:mo>
943       <m:mtable>
944         <xsl:call-template name="table-content"/>
945       </m:mtable>
946     </m:mrow>
947   </xsl:template>
948
949 </xsl:stylesheet>