1 <!-- saved from url=(0013)about:internet -->
2 <?xml version=
"1.0" encoding=
"iso-8859-1"?>
4 Presentation MathML Stylesheet
8 $Id: pmathmlcss.xsl,v 1.1 2002/03/20 12:20:57 mf Exp $
10 Copyright David Carlisle 2001, 2002.
12 Use and distribution of this code are permitted under the terms of the <a
13 href="http://www.w3.org/Consortium/Legal/copyright-software-19980720"
14 >W3C Software Notice and License</a>.
19 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
20 xmlns:
h=
"http://www.w3.org/1999/xhtml"
21 xmlns:
m=
"http://www.w3.org/1998/Math/MathML"
22 xmlns:
doc=
"http://www.dcarlisle.demon.co.uk/xsldoc"
24 exclude-result-prefixes=
"x h doc"
27 <h:h2>Dictionary
</h:h2>
29 <h:p> The following elements in the x: namespace form an
30 implementation of an
"Operator Dictionary" for this MathML
31 Implementation. In the case of stretch operators, the element
32 specifies the symbol parts via the latin-
1 equivalent character based
33 on the encoding in the symbol font. It is a clear
"failure to comply
34 to the spec" that using latin
1 characters (or numeric character
35 references) in the latin
1 range access glyphs in teh symbol font via
36 font position, however most of these character parts are not in
37 Unicode (until
3.2), so there is no standard way to access these characters.
</h:p>
39 <x:x x=
"{" m=
"0em" stretch=
"true" top=
"ì" middle=
"í" extend=
"ï" bottom=
"î">{
</x:x>
40 <x:x x=
"}" m=
"0em" stretch=
"true" top=
"ü" middle=
"ý" extend=
"ú" bottom=
"þ">{
</x:x>
42 <x:x x=
"(" m=
"0em" stretch=
"true" top=
"æ" middle=
"ç" extend=
"ç" bottom=
"è">(
</x:x>
43 <x:x x=
")" m=
"0em" stretch=
"true" top=
"ö" middle=
"÷" extend=
"÷" bottom=
"ø">)
</x:x>
45 <x:x x=
"[" m=
"0em" stretch=
"true" top=
"é" middle=
"ê" extend=
"ê" bottom=
"ë">[
</x:x>
46 <x:x x=
"]" m=
"0em" stretch=
"true" top=
"ù" middle=
"ú" extend=
"ú" bottom=
"û">]
</x:x>
48 <x:x x=
"〚" m=
"0em" stretch=
"true" top=
"éé" middle=
"êê" extend=
"êê" bottom=
"ëë">[[
</x:x>
49 <x:x x=
"〛" m=
"0em" stretch=
"true" top=
"ùù" middle=
"úú" extend=
"úú" bottom=
"ûû">]]
</x:x>
51 <x:x x=
"|" m=
"0em" stretch=
"true" top=
"ç" middle=
"ç" extend=
"ç" bottom=
"ç">|
</x:x>
52 <x:x x=
"||" m=
"0em" stretch=
"true" top=
"çç" middle=
"çç" extend=
"çç" bottom=
"çç">||
</x:x>
54 <x:x x=
"⁡" m=
"0em"></x:x><!-- applyfunction -->
55 <x:x x=
"⁢" m=
"0em"></x:x><!-- invisibletimes -->
56 <x:x x=
"-">−</x:x>
57 <x:x x=
"≃"><span style=
"position:
58 relative; top: +.1em;">−</span><span style=
"position:
59 relative; left: -.55em; top: -.2em; margin: 0em;">~
</span></x:x>
60 <x:x x=
"︸" m=
"0em">_v_
</x:x>
63 <h:p>Remove these for now, as XML parser in IE6 is broken and doesn't
64 accept plane
1 characters.
</h:p>
66 <x:x x="𝔸" v="doublestruck">A</x:x>
67 <x:x x="𝔹" v="doublestruck">B</x:x>
68 <x:x x="ℂ" v="doublestruck">C</x:x>
69 <x:x x="𝔻" v="doublestruck">D</x:x>
71 <x:x x="𝕒" v="doublestruck">a</x:x>
72 <x:x x="𝕓" v="doublestruck">b</x:x>
73 <x:x x="𝕔" v="doublestruck">c</x:x>
74 <x:x x="𝕕" v="doublestruck">d</x:x>
76 <x:x x="𝔄" v="fraktur">A</x:x>
77 <x:x x="𝔅" v="fraktur">B</x:x>
78 <x:x x="ℭ" v="fraktur">C</x:x>
79 <x:x x="𝔇" v="fraktur">D</x:x>
81 <x:x x="𝔞" v="fraktur">a</x:x>
82 <x:x x="𝔟" v="fraktur">b</x:x>
83 <x:x x="𝔠" v="fraktur">c</x:x>
84 <x:x x="𝔡" v="fraktur">d</x:x>
87 <h:p>Grab all of the above into a variable.
</h:p>
88 <xsl:variable name=
"opdict" select=
"document('')/*/x:x"/>
90 <h:h2>HTML elements
</h:h2>
93 XHTML elements get passed straight through, sans namespace prefix.
95 <xsl:template match=
"h:*">
96 <xsl:element name=
"{local-name(.)}">
97 <xsl:copy-of select=
"@*"/>
98 <xsl:apply-templates/>
106 Template for the head element copies the original content, aand in
107 addition adds a script element and CSS style element that implement
108 the core of the MathML renderer.
111 <h:p doc:
ref=
"malign">
112 The malign function first finds the left most item in the aligngroup, and
113 then modifies the left margin of each item to make them
114 align. (Currently only left alignment is supported.)
117 <h:p doc:
ref=
"mrowStretch">
118 The mrowStretch function implements stretchy brackets. It is called
119 repeatedly, once for each mo child,after a span corresponding to an
120 mrow. The arguments are the id of teh span and the characters to use
121 for the parts of the stretch operator.
122 constructed fence. The
126 Inline CSS style block handles all font and size specification for the
127 various MathML operators.
130 <xsl:template match=
"h:head">
132 <xsl:element name=
"{local-name(.)}">
133 <xsl:copy-of select=
"@*"/>
134 <xsl:apply-templates/>
138 <xsl:text doc:
id=
"malign">
142 for ( i =
0; i
< l.length ; i++)
144 m = Math.max(m,l[i].offsetLeft);
146 for ( i =
0; i
< l.length ; i++)
148 l[i].style.marginLeft=m - l[i].offsetLeft;
153 <xsl:text doc:
id=
"mrowStretch">
154 function mrowStretch (opid,opt,ope,opm,opb){
155 opH = opid.offsetHeight;
159 if (mrowH
> opH *
2) {
160 m=
"<font size='+1' face='symbol'>" + opm +
"</font><br/>" ;
161 if ((mrowH
< opH *
3)
&&(opm == ope) )
m=
"";
163 for ( i =
3; i
<= mrowH / (
2*opH) ; i +=
1) es +=
"<font size='+1' face='symbol'>" + ope +
"</font><br/>" ;
164 opid.
innerHTML=
"<table class='lr'><tr><td><font size='+1' face='symbol'>" +
165 opt +
"</font><br/>" +
169 "<font size='+1' face='symbol'>" + opb +
"</font></td></tr></table>";
174 <xsl:text doc:
id=
"msubsup">
175 function msubsup (bs,bbs,x,b,p){
177 p.style.setExpression("top",bs +" .offsetTop - " + (p.offsetHeight/2 +(bbs.offsetHeight - Math.max(bbs.offsetHeight, b.offsetHeight + p.offsetHeight)*.5)));
179 p.style.setExpression(
"top",bs +
" .offsetTop -" + (p.offsetHeight/
2));
180 b.style.setExpression(
"top",bs +
".offsetTop + " + (bbs.offsetHeight - b.offsetHeight*
.5));
181 x.style.setExpression(
"marginLeft",Math.max(p.offsetWidth,b.offsetWidth));
182 document.recalc(true);
187 function msubsupzz (bs,x,b,p){
188 p.style.setExpression("top",bs +" .offsetTop - " + bs +
189 "p.offsetHeight/2 +(" + bs + ".offsetHeight - Math.max(" + bs + ".offsetHeight, (" + bs + "b.offsetHeight + " + bs + "p.offsetHeight)*.5))");
190 b.style.setExpression("top",bs + ".offsetTop + " + bs + ".offsetHeight - " + bs + "b.offsetHeight/2");
191 x.style.setExpression("marginLeft","Math.max(" + bs +"p.offsetWidth,"
192 + bs +"b.offsetWidth)");
196 <xsl:text doc:
id=
"msup">
197 function msup (bs,x,p){
198 p.style.setExpression(
"top",bs +
" .offsetTop -" + (p.offsetHeight/
2));
199 x.style.setExpression(
"marginLeft", bs +
"p.offsetWidth");
200 x.style.setExpression(
"height", bs +
".offsetHeight + " + p.offsetHeight);
201 document.recalc(true);
205 <xsl:text doc:
id=
"msub">
206 function msub (bs,x,p){
207 p.style.setExpression(
"top",bs +
" .offsetTop +" + (p.offsetHeight/
2));
208 x.style.setExpression(
"marginLeft", bs +
"p.offsetWidth");
209 x.style.setExpression(
"height", bs +
".offsetHeight + " + p.offsetHeight);
210 document.recalc(true);
214 <xsl:text doc:
id=
"toggle">
215 function toggle (x) {
216 for ( i =
0 ; i
< x.childNodes.length ; i++) {
217 if (x.childNodes.item(i).style.display=='inline') {
218 x.childNodes.item(i).style.display='none';
219 if ( i+
1 == x.childNodes.length) {
220 x.childNodes.item(
0).style.display='inline';
222 x.childNodes.item(i+
1).style.display='inline';
233 <xsl:text doc:
id=
"css">
236 <!--background-color: red;-->
243 vertical-align: middle;
248 vertical-align: middle;
263 font-style: monospace;
271 font-family: castellar, algerian,niagara engraved;
284 border-width:
.1em
0pt
0pt
.1em;
294 border-width:
.1em
.1em
0pt
0pt ;
302 position:relative; top:+
0.5ex;
312 vertical-align: middle;
318 vertical-align: middle;
325 vertical-align: middle;
329 vertical-align: bottom;
333 border-width:
0em
0em
.2ex
0em ; border-style: solid;
343 background-color: white ;
345 border-color: #FF0000;
357 Unimplemented MathML elements get copied literally, in red, mainly as
360 <xsl:template match=
"m:*">
361 <span style=
"color: red;"><<xsl:value-of select=
"local-name(.)"/>></span>
362 <xsl:apply-templates/>
363 <span style=
"color: red;"></
<xsl:value-of select=
"local-name(.)"/>></span>
367 mi: set default font based on string length, otherwise behaviour based
368 on entries in the operator dictionary if one exists, or content is
369 copied through to the output unchanged.
371 <xsl:template match=
"m:mi">
373 <xsl:if test=
"1=string-length(normalize-space(.))">
374 <xsl:attribute name=
"class">mi1
</xsl:attribute>
376 <xsl:apply-templates select=
"@mathvariant"/>
377 <xsl:variable name=
"x" select=
"normalize-space(.)"/>
379 <xsl:when test=
"$opdict[@x=$x and @v]">
380 <xsl:attribute name=
"class"><xsl:value-of select=
"$opdict[@x=$x]/@v"/></xsl:attribute>
381 <xsl:value-of select=
"$opdict[@x=$x and @v]"/>
384 <xsl:value-of select=
"$x"/>
391 Handling of mathvariant attribute.
392 The choice of font families here (currently) avoids math-specific
393 fonts but does use several fionts coming with windows
9.x and/or
396 <xsl:template match=
"@mathvariant[.='bold']">
397 <xsl:attribute name=
"style">font-weight: bold; font-style: upright
</xsl:attribute>
399 <xsl:template match=
"@mathvariant[.='bold-italic']">
400 <xsl:attribute name=
"style">font-style: upright; font-weight: bold; font-style: italic;
</xsl:attribute>
402 <xsl:template match=
"@mathvariant[.='italic']">
403 <xsl:attribute name=
"style">font-style: italic;
</xsl:attribute>
405 <xsl:template match=
"@mathvariant[.='monospace']">
406 <xsl:attribute name=
"style">font-family: monospace;
</xsl:attribute>
409 <xsl:template match=
"@mathvariant[.='sans-serif']">
410 <xsl:attribute name=
"style">font-family: sans-serif;
</xsl:attribute>
412 <xsl:template match=
"@mathvariant[.='bold-sans-serif']">
413 <xsl:attribute name=
"style">font-family: sans-serif; font-weight: bold;
</xsl:attribute>
416 <xsl:template match=
"@mathvariant[.='fraktur']">
417 <xsl:attribute name=
"style">font-family: old english text mt
</xsl:attribute>
418 <xsl:attribute name=
"class"></xsl:attribute>
421 <xsl:template match=
"@mathvariant[.='double-struck']">
422 <xsl:attribute name=
"class">doublestruck
</xsl:attribute>
426 <xsl:template match=
"@mathvariant[.='script']">
427 <xsl:attribute name=
"style">font-family: brush script mt italic
</xsl:attribute>
428 <xsl:attribute name=
"class"></xsl:attribute>
432 <h:p>mo: Generate a unique ID so that a script at the end of any
433 surrounding mrow may replace the conent by a suitably stretched
434 operator if need be.
</h:p>
435 <xsl:template match=
"m:mo">
436 <span id=
"{generate-id()}" class=
"mo">
437 <xsl:apply-templates/>
441 <h:p>mn: a simple span
</h:p>
442 <xsl:template match=
"m:mn">
444 <xsl:apply-templates/>
448 <h:p>munder: currently only supports underline, with a bottom border
</h:p>
449 <xsl:template match=
"m:munder">
450 <span class=
"munder">
451 <xsl:if test=
"normalize-space(*[2])='̲'">
453 name=
"style">border-width:
0pt
0pt
.1em
0pt; border-style: solid;
"</xsl:attribute>
455 <span><xsl:apply-templates select="*[
1]
"/></span>
459 <h:p>mover: currently only supports overline, with a top border</h:p>
460 <xsl:template match="m:mover
">
461 <span class="munder
">
462 <xsl:if test="normalize-space(*[
2])='
¯'
">
464 name="style
">border-width: .1em 0pt 0pt 0pt; border-style: solid;"</xsl:attribute>
466 <span><xsl:apply-templates select=
"*[1]"/></span>
470 <h:p>munderover:
</h:p>
471 <xsl:template match=
"m:munderover">
472 <table class=
"munderover">
473 <tr><td><xsl:apply-templates select=
"*[3]"/></td></tr>
474 <tr><td><xsl:apply-templates select=
"*[1]"/></td></tr>
475 <tr><td><xsl:apply-templates select=
"*[2]"/></td></tr>
479 <h:p>mtext: a simple span
</h:p>
480 <xsl:template match=
"m:mtext">
482 <xsl:value-of select=
"normalize-space(.)"/>
486 <h:p>mstyle: not many attributes currently supported
</h:p>
487 <xsl:template match=
"m:mstyle">
489 <xsl:attribute name=
"style">
490 <xsl:if test=
"@color">color:
<xsl:value-of select=
"@color"/>;
</xsl:if>
491 <xsl:if test=
"@background">background-color:
<xsl:value-of select=
"@background"/>;
</xsl:if>
493 <xsl:apply-templates/>
498 <h:p>mglyph: Uses disable output escaping to construct a numeric
499 character reference. Uses IE's non conforming behaviour of using this
500 number to access the font encoding rather than unicode.
</h:p>
501 <xsl:template match=
"m:mglyph">
502 <font face=
"{@fontfamily}"><xsl:value-of
503 disable-output-escaping=
"yes" select=
"'&#'"/>
504 <xsl:value-of select=
"@index"/>;
<xsl:text/>
508 <h:p>ms: a simple span with left and right character added to the content.
</h:p>
509 <xsl:template match=
"m:ms">
511 <xsl:value-of select=
"@lquote"/><xsl:if test=
"not(@lquote)">"</xsl:if>
512 <xsl:value-of select="normalize-space(.)
"/>
513 <xsl:value-of select="@rquote
"/><xsl:if test="not(@rquote)
">"</xsl:if>
518 <xsl:template match=
"m:math">
519 <xsl:call-template name=
"mrow"/>
524 <xsl:template match=
"m:mfenced">
525 <xsl:variable name=
"l">
527 <xsl:when test=
"@open"><xsl:value-of select=
"@open"/></xsl:when>
528 <xsl:otherwise>(
</xsl:otherwise>
531 <xsl:variable name=
"r">
533 <xsl:when test=
"@close"><xsl:value-of select=
"@close"/></xsl:when>
534 <xsl:otherwise>)
</xsl:otherwise>
537 <xsl:variable name=
"s">
539 <xsl:when test=
"@sep">
540 <xsl:call-template name=
"text">
541 <xsl:with-param name=
"x" select=
"@sep"/>
544 <xsl:otherwise>,
</xsl:otherwise>
547 <span id=
"{generate-id()}L"><xsl:value-of select=
"$l"/></span>
548 <span id=
"{generate-id()}M">
549 <xsl:for-each select=
"*">
550 <xsl:apply-templates select=
"."/>
551 <xsl:if test=
"position() != last()"><span id=
"{generate-id()}X{position()}"><xsl:value-of select=
"$s"/></span></xsl:if>
554 <span id=
"{generate-id()}R"><xsl:value-of select=
"$r"/></span>
557 <xsl:if test=
"$s=$opdict[@stretch='true']/@x">
558 <xsl:for-each select=
"*[position()<last()]">
559 <xsl:variable name=
"opdictentry" select=
"$opdict[@x=$s]"/>
560 mrowStretch(
<xsl:value-of select=
"concat(generate-id(),'X',position())"/>,
"<xsl:value-of
561 select="$opdictentry/@top
"/>",
"<xsl:value-of
562 select="$opdictentry/@extend
"/>",
"<xsl:value-of
563 select="$opdictentry/@middle
"/>",
"<xsl:value-of
564 select="$opdictentry/@bottom
"/>");
</xsl:for-each>
567 <xsl:variable name=
"opdictentry" select=
"$opdict[@x=$l]"/>
568 var mrowH =
<xsl:value-of select=
"generate-id()"/>M.offsetHeight;
569 mrowStretch(
<xsl:value-of select=
"generate-id()"/>L,
"<xsl:value-of
570 select="$opdictentry/@top
"/>",
"<xsl:value-of
571 select="$opdictentry/@extend
"/>",
"<xsl:value-of
572 select="$opdictentry/@middle
"/>",
"<xsl:value-of
573 select="$opdictentry/@bottom
"/>");
<xsl:text/>
575 <xsl:variable name=
"opdictentry2" select=
"$opdict[@x=$r]"/>
576 mrowStretch(
<xsl:value-of select=
"generate-id()"/>R,
"<xsl:value-of
577 select="$opdictentry2/@top
"/>",
"<xsl:value-of
578 select="$opdictentry2/@extend
"/>",
"<xsl:value-of
579 select="$opdictentry2/@middle
"/>",
"<xsl:value-of
580 select="$opdictentry2/@bottom
"/>");
<xsl:text/>
586 <xsl:template match=
"m:mmultiscripts">
587 <table style=
"display:inline; vertical-align: middle;">
589 <xsl:for-each select=
"*[preceding-sibling::m:mprescripts and position() mod 2 = 0]">
590 <td><xsl:apply-templates select=
"."/></td>
592 <td rowspan=
"2"><xsl:apply-templates select=
"*[1]"/></td>
593 <xsl:for-each select=
"*[not(preceding-sibling::m:mprescripts) and position() !=1 and position() mod 2 = 1]">
594 <td><xsl:apply-templates select=
"."/></td>
598 <xsl:for-each select=
"*[preceding-sibling::m:mprescripts and position() mod 2 = 1]">
599 <td><xsl:apply-templates select=
"."/></td>
601 <xsl:for-each select=
"*[not(preceding-sibling::m:mprescripts) and
602 not(self::m:mprescripts) and position() mod 2 = 0]">
603 <td><xsl:apply-templates select=
"."/></td>
610 <xsl:template match=
"m:none"></xsl:template>
612 <xsl:template match=
"m:merror">
613 <span class=
"merror"><xsl:call-template name=
"mrow"/></span>
616 <xsl:template match=
"m:mphantom">
617 <span class=
"mphantom"><xsl:apply-templates/></span>
620 <xsl:template match=
"m:maction[@type='tooltip']">
621 <span title=
"{*[2]}"><xsl:apply-templates select=
"*[1]"/></span>
624 <xsl:template match=
"m:maction[@type='toggle']">
625 <span id=
"{generate-id()}" onclick=
"toggle({generate-id()})">
626 <span style=
"display:inline;"><xsl:apply-templates select=
"*[1]"/></span>
627 <xsl:for-each select=
"*[position() > 1]">
628 <span style=
"display:none;"><xsl:apply-templates select=
"."/></span>
634 <xsl:template match=
"m:maction[@type='statusline']">
635 <span id=
"{generate-id()}"
636 onmouseover=
"window.status='{*[2]}';"
637 onmouseout=
"window.status='';"
639 <xsl:apply-templates select=
"*[1]"/></span>
643 <xsl:template match=
"m:maction[@type='highlight']">
644 <span id=
"{generate-id()}"
645 onmouseover=
"{generate-id()}.style.backgroundColor='yellow';"
646 onmouseout=
"{generate-id()}.style.backgroundColor='white';"><xsl:apply-templates/></span>
651 <xsl:template match=
"m:mrow" name=
"mrow">
652 <span id=
"{generate-id()}" class=
"mrow">
653 <xsl:apply-templates select=
"*"/>
655 <xsl:if test=
"m:mo[@stretch='true' or normalize-space(.)=$opdict[@stretch='true']/@x]">
657 var mrowH =
<xsl:value-of select=
"generate-id()"/>.offsetHeight;
658 <xsl:for-each select=
"m:mo[@stretch='true' or
659 normalize-space(.)=$opdict[@stretch='true']/@x]">
661 <xsl:variable name=
"o" select=
"normalize-space(.)"/>
662 <xsl:variable name=
"opdictentry" select=
"$opdict[@x=$o]"/>
663 mrowStretch(
<xsl:value-of select=
"generate-id()"/>,
"<xsl:value-of
664 select="$opdictentry/@top
"/>",
"<xsl:value-of
665 select="$opdictentry/@extend
"/>",
"<xsl:value-of
666 select="$opdictentry/@middle
"/>",
"<xsl:value-of
667 select="$opdictentry/@bottom
"/>");
</xsl:for-each>
673 <xsl:template match=
"m:msubsup">
674 <span id=
"{generate-id()}" >
675 <xsl:apply-templates select=
"*[1]"/></span
676 ><span id=
"{generate-id()}b" class=
"msubsup"><xsl:apply-templates
677 select=
"*[2]"/></span
678 ><span id=
"{generate-id()}p" class=
"msubsup"><xsl:apply-templates
679 select=
"*[3]"/></span
680 ><span id=
"{generate-id()}x"></span>
682 msubsup(
"<xsl:value-of select="concat(generate-id(),'
",',generate-id(),',',generate-id(),'x,',generate-id(),'b,',generate-id())
"/>p);
686 <xsl:template match="h:table//m:msubsup|m:mtable//m:msubsup|m:msubsup
"
689 <xsl:apply-templates select="*[
1]
"/>
691 ><sub><xsl:apply-templates
692 select="*[
2]
"/></sub>
693 <sup><xsl:apply-templates
694 select="*[
3]
"/></sup>
697 <xsl:template match="m:msup
699 <span id="{generate-id()}
">
700 <xsl:apply-templates select="*[
1]
"/>
702 ><span id="{generate-id()}p
" class="msubsup
"><xsl:apply-templates
703 select="*[
2]
"/></span
704 ><span id="{generate-id()}x
"></span>
706 msup("<xsl:value-of select=
"concat(generate-id(),'",',generate-id(),'x,',generate-id())"/>p);
710 <xsl:template match=
"h:table//m:msup|m:mtable//m:msup|m:msup"
713 <xsl:apply-templates select=
"*[1]"/>
715 ><sup><xsl:apply-templates
716 select=
"*[2]"/></sup>
719 <xsl:template match=
"m:msub
721 <span id=
"{generate-id()}">
722 <xsl:apply-templates select=
"*[1]"/>
724 ><span id=
"{generate-id()}p" class=
"msubsup"><xsl:apply-templates
725 select=
"*[2]"/></span
726 ><span id=
"{generate-id()}x"></span>
728 msub(
"<xsl:value-of select="concat(generate-id(),'
",',generate-id(),'x,',generate-id())
"/>p);
732 <xsl:template match="h:table//m:msub|m:mtable//m:msub|m:msub
"
735 <xsl:apply-templates select="*[
1]
"/>
737 ><sub><xsl:apply-templates
738 select="*[
2]
"/></sub>
742 <xsl:template match="m:*/text()
" name="text
">
743 <xsl:param name="x
" select="normalize-space(.)
"/>
744 <xsl:variable name="mo
" select="document('')/*/x:x[@x=$x]
"/>
746 <xsl:when test="$mo
"><xsl:copy-of select="$mo/node()
"/></xsl:when>
747 <xsl:otherwise><xsl:copy-of select="$x
"/></xsl:otherwise>
752 <xsl:template match="m:msqrt
">
753 <span class="msqrtx
">\</span><span class="msqrt
">
754 <xsl:apply-templates/>
758 <xsl:template match="m:menclose[@notation='radical']
">
759 <span class="msqrtx
">\</span><span class="msqrt
">
760 <xsl:apply-templates/>
764 <xsl:template match="m:menclose[@notation='actuarial']
">
765 <span class="actuarial
">
766 <xsl:apply-templates/>
770 <xsl:template match="m:menclose
">
772 <xsl:apply-templates/>
776 <xsl:template match="m:mroot
">
777 <span class="msqrtx
"><sup><xsl:apply-templates select="*[
2]
"/></sup>\</span><span class="msqrt
">
778 <xsl:apply-templates select="*[
1]
"/>
783 <xsl:template match="m:mfrac
">
784 <xsl:param name="full
" select="not(ancestor::m:mfrac)
"/>
785 <table class="mfrac
">
786 <xsl:if test="$full
">
787 <xsl:attribute name="style
">font-size: 75% ;</xsl:attribute>
789 <xsl:if test="not($full)
">
790 <xsl:attribute name="style
">font-size: 100% ;</xsl:attribute>
792 <tr id="a{generate-id()}
" class="mfraca
"><td class="mfracaa
">
793 <xsl:apply-templates select="*[
1]
"/>
795 <tr id="b{generate-id()}
" class="mfracb
"><td>
796 <xsl:apply-templates select="*[
2]
"/>
798 </table><xsl:if test="$full
"><script>
799 if ( a<xsl:value-of select="generate-id()
"
800 />.offsetHeight > b<xsl:value-of select="generate-id()
"
801 />.offsetHeight ) b<xsl:value-of select="generate-id()
802 "/>.style.setExpression("height
",a<xsl:value-of select="generate-id()
"/>.offsetHeight );
804 select="generate-id()
"/>.style.setExpression("height
",b<xsl:value-of
805 select="generate-id()
"/>.offsetHeight );
809 <xsl:template match="m:padded
">
811 <xsl:attribute name="display
">
813 <xsl:apply-templates/>
818 <xsl:template match="m:mspace
">
819 <span style="padding-left: {@width};
"></span>
822 <xsl:template match="m:mtable
">
823 <table class="mtable
">
824 <xsl:apply-templates/>
827 <xsl:variable name="t
" select=".
"/>
828 <xsl:for-each select="m:mtr[
1]/m:mtd
">
829 <xsl:variable name="c
" select="position()
"/>
830 <xsl:for-each select="descendant::m:maligngroup
">
831 <xsl:variable name="g
" select="position()
"/>
832 malign([<xsl:for-each
833 select="$t/m:mtr/m:mtd[$c]/descendant::m:maligngroup[$g]
">
834 <xsl:value-of select="generate-id()
"/>
835 <xsl:if test="position()
<last()
">,</xsl:if>
836 </xsl:for-each>]);</xsl:for-each>
841 <xsl:template match="m:mtr
">
843 <xsl:apply-templates/>
848 <xsl:template match="m:mtd
">
850 <xsl:apply-templates/>
854 <xsl:template match="m:maligngroup
">
855 <xsl:variable name="g
">
857 <xsl:when test="@groupalign
">
859 <xsl:when test="ancestor::td/@groupalign
">
861 <xsl:when test="ancestor::tr/@groupalign
">
863 <xsl:when test="ancestor::table/@groupalign
">
866 <xsl:otherwise>left</xsl:otherwise>
869 <span id="{generate-id()}
"></span>