f83664580a44944e11f53c927fd873929725ef82
[clinton/guile-figl.git] / upstream-man-pages / manglsl / xhtml / pmathmlcss.xsl
1 <!-- saved from url=(0013)about:internet -->
2 <?xml version="1.0" encoding="iso-8859-1"?>
3 <!--
4 Presentation MathML Stylesheet
5 -->
6
7 <!--
8 $Id: pmathmlcss.xsl,v 1.1 2002/03/20 12:20:57 mf Exp $
9
10 Copyright David Carlisle 2001, 2002.
11
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>.
15 -->
16
17 <xsl:stylesheet
18 version="1.0"
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"
23 xmlns:x="data:,x"
24 exclude-result-prefixes="x h doc"
25 >
26
27 <h:h2>Dictionary</h:h2>
28
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>
38
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>
41
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>
44
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>
47
48 <x:x x="&#x301A;" m="0em" stretch="true" top="éé" middle="êê" extend="êê" bottom="ëë">[[</x:x>
49 <x:x x="&#x301B;" m="0em" stretch="true" top="ùù" middle="úú" extend="úú" bottom="ûû">]]</x:x>
50
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>
53
54 <x:x x="&#x2061;" m="0em">&#xFEFF;</x:x><!-- applyfunction -->
55 <x:x x="&#x2062;" m="0em">&#xFEFF;</x:x><!-- invisibletimes -->
56 <x:x x="-">&#x2212;</x:x>
57 <x:x x="&#x2243;"><span style="position:
58 relative; top: +.1em;">&#x2212;</span>&#xFEFF;<span style="position:
59 relative; left: -.55em; top: -.2em; margin: 0em;">~</span></x:x>
60 <x:x x="&#xFE38;" m="0em">_v_</x:x>
61
62
63 <h:p>Remove these for now, as XML parser in IE6 is broken and doesn't
64 accept plane 1 characters.</h:p>
65 <!--
66 <x:x x="&#x1D538;" v="doublestruck">A</x:x>
67 <x:x x="&#x1D539;" v="doublestruck">B</x:x>
68 <x:x x="&#x2102;" v="doublestruck">C</x:x>
69 <x:x x="&#x1D53B;" v="doublestruck">D</x:x>
70
71 <x:x x="&#x1D552;" v="doublestruck">a</x:x>
72 <x:x x="&#x1D553;" v="doublestruck">b</x:x>
73 <x:x x="&#x1D554;" v="doublestruck">c</x:x>
74 <x:x x="&#x1D555;" v="doublestruck">d</x:x>
75
76 <x:x x="&#x1D504;" v="fraktur">A</x:x>
77 <x:x x="&#x1D505;" v="fraktur">B</x:x>
78 <x:x x="&#x212D;" v="fraktur">C</x:x>
79 <x:x x="&#x1D507;" v="fraktur">D</x:x>
80
81 <x:x x="&#x1D51E;" v="fraktur">a</x:x>
82 <x:x x="&#x1D51F;" v="fraktur">b</x:x>
83 <x:x x="&#x1D520;" v="fraktur">c</x:x>
84 <x:x x="&#x1D521;" v="fraktur">d</x:x>
85 -->
86
87 <h:p>Grab all of the above into a variable.</h:p>
88 <xsl:variable name="opdict" select="document('')/*/x:x"/>
89
90 <h:h2>HTML elements</h:h2>
91
92 <h:p>
93 XHTML elements get passed straight through, sans namespace prefix.
94 </h:p>
95 <xsl:template match="h:*">
96 <xsl:element name="{local-name(.)}">
97 <xsl:copy-of select="@*"/>
98 <xsl:apply-templates/>
99 </xsl:element>
100 </xsl:template>
101
102
103
104
105 <h:p>
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.
109 </h:p>
110
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.)
115 </h:p>
116
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
123 </h:p>
124
125 <h:p doc:ref="css">
126 Inline CSS style block handles all font and size specification for the
127 various MathML operators.
128 </h:p>
129
130 <xsl:template match="h:head">
131
132 <xsl:element name="{local-name(.)}">
133 <xsl:copy-of select="@*"/>
134 <xsl:apply-templates/>
135
136 <script>
137
138 <xsl:text doc:id="malign">
139 function malign (l)
140 {
141 var m = 0;
142 for ( i = 0; i &lt; l.length ; i++)
143 {
144 m = Math.max(m,l[i].offsetLeft);
145 }
146 for ( i = 0; i &lt; l.length ; i++)
147 {
148 l[i].style.marginLeft=m - l[i].offsetLeft;
149 }
150 }
151 </xsl:text>
152
153 <xsl:text doc:id="mrowStretch">
154 function mrowStretch (opid,opt,ope,opm,opb){
155 opH = opid.offsetHeight;
156 var opH;
157 var i;
158 var es;
159 if (mrowH &gt; opH * 2) {
160 m= "&lt;font size='+1' face='symbol'>" + opm + "&lt;/font>&lt;br/>" ;
161 if ((mrowH &lt; opH * 3) &amp;&amp;(opm == ope) ) m="";
162 es="";
163 for ( i = 3; i &lt;= mrowH / (2*opH) ; i += 1) es += "&lt;font size='+1' face='symbol'>" + ope + "&lt;/font>&lt;br/>" ;
164 opid.innerHTML="&lt;table class='lr'>&lt;tr>&lt;td>&lt;font size='+1' face='symbol'>" +
165 opt + "&lt;/font>&lt;br/>" +
166 es +
167 m +
168 es +
169 "&lt;font size='+1' face='symbol'>" + opb + "&lt;/font>&lt;/td>&lt;/tr>&lt;/table>";
170 }
171 }
172 </xsl:text>
173
174 <xsl:text doc:id="msubsup">
175 function msubsup (bs,bbs,x,b,p){
176 <!--
177 p.style.setExpression("top",bs +" .offsetTop - " + (p.offsetHeight/2 +(bbs.offsetHeight - Math.max(bbs.offsetHeight, b.offsetHeight + p.offsetHeight)*.5)));
178 -->
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);
183 }
184 </xsl:text>
185
186 <!--
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)");
193 }
194 -->
195
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);
202 }
203 </xsl:text>
204
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);
211 }
212 </xsl:text>
213
214 <xsl:text doc:id="toggle">
215 function toggle (x) {
216 for ( i = 0 ; i &lt; 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';
221 } else {
222 x.childNodes.item(i+1).style.display='inline';
223 };
224 break;
225 }
226 }
227 }
228 </xsl:text>
229 </script>
230
231
232 <style>
233 <xsl:text doc:id="css">
234
235 .msubsup {
236 <!--background-color: red;-->
237 font-size: 80%;
238 position: absolute;
239 }
240
241 .munderover {
242 display: inline;
243 vertical-align: middle;
244 }
245
246 .lr {
247 display: inline;
248 vertical-align: middle;
249 }
250
251 .mi {
252 font-style: serif;
253 }
254
255
256 .mspace{
257 display: inline;
258 }
259 .mtext {
260 font-style: serif;
261 }
262 .ms {
263 font-style: monospace;
264 }
265
266 .mi1 {
267 font-style: italic;
268 }
269
270 .doublestruck {
271 font-family: castellar, algerian,niagara engraved;
272 }
273 .mo {
274 padding-right: .3em;
275 padding-left: .3em;
276 }
277
278 .mn {
279 }
280
281 .msqrt {
282 border-style: solid;
283 border-color: black;
284 border-width: .1em 0pt 0pt .1em;
285 padding-left: .2em;
286 margin-left: 0em;
287 margin-top: .2em;
288 display: inline;
289 }
290
291 .actuarial {
292 border-style: solid;
293 border-color: black;
294 border-width: .1em .1em 0pt 0pt ;
295 padding-right: .2em;
296 margin-right: 0em;
297 margin-top: .2em;
298 display: inline;
299 }
300
301 .ssa {
302 position:relative; top:+0.5ex;
303 width: 0pt;
304 color: red;
305 }
306
307
308 .mover {
309 margin: 0pt;
310 padding: 0pt;
311 display: inline;
312 vertical-align: middle;
313 text-align: center;
314 }
315
316 .mtable {
317 display: inline;
318 vertical-align: middle;
319 }
320
321
322 .mfrac {
323 text-align: center;
324 display:inline;
325 vertical-align: middle;
326 }
327
328 .mfraca {
329 vertical-align: bottom;
330 }
331
332 .mfracaa {
333 border-width: 0em 0em .2ex 0em ; border-style: solid;
334 border-color: black;
335 }
336
337
338 .mfracb {
339 vertical-align: top;
340 }
341
342 .merror{
343 background-color: white ;
344 border-style: solid;
345 border-color: #FF0000;
346 color: #FF0000;
347 }
348 .mphantom{
349 visibility: hidden;
350 }
351 </xsl:text>
352 </style>
353 </xsl:element>
354 </xsl:template>
355
356 <h:p>
357 Unimplemented MathML elements get copied literally, in red, mainly as
358 a debugging aid.
359 </h:p>
360 <xsl:template match="m:*">
361 <span style="color: red;">&lt;<xsl:value-of select="local-name(.)"/>&gt;</span>
362 <xsl:apply-templates/>
363 <span style="color: red;">&lt;/<xsl:value-of select="local-name(.)"/>&gt;</span>
364 </xsl:template>
365
366 <h:p>
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.
370 </h:p>
371 <xsl:template match="m:mi">
372 <span class="mi">
373 <xsl:if test="1=string-length(normalize-space(.))">
374 <xsl:attribute name="class">mi1</xsl:attribute>
375 </xsl:if>
376 <xsl:apply-templates select="@mathvariant"/>
377 <xsl:variable name="x" select="normalize-space(.)"/>
378 <xsl:choose>
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]"/>
382 </xsl:when>
383 <xsl:otherwise>
384 <xsl:value-of select="$x"/>
385 </xsl:otherwise>
386 </xsl:choose>
387 </span>
388 </xsl:template>
389
390 <h:p>
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
394 office 2000.
395 </h:p>
396 <xsl:template match="@mathvariant[.='bold']">
397 <xsl:attribute name="style">font-weight: bold; font-style: upright</xsl:attribute>
398 </xsl:template>
399 <xsl:template match="@mathvariant[.='bold-italic']">
400 <xsl:attribute name="style">font-style: upright; font-weight: bold; font-style: italic;</xsl:attribute>
401 </xsl:template>
402 <xsl:template match="@mathvariant[.='italic']">
403 <xsl:attribute name="style">font-style: italic; </xsl:attribute>
404 </xsl:template>
405 <xsl:template match="@mathvariant[.='monospace']">
406 <xsl:attribute name="style">font-family: monospace; </xsl:attribute>
407 </xsl:template>
408
409 <xsl:template match="@mathvariant[.='sans-serif']">
410 <xsl:attribute name="style">font-family: sans-serif; </xsl:attribute>
411 </xsl:template>
412 <xsl:template match="@mathvariant[.='bold-sans-serif']">
413 <xsl:attribute name="style">font-family: sans-serif; font-weight: bold; </xsl:attribute>
414 </xsl:template>
415
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>
419 </xsl:template>
420
421 <xsl:template match="@mathvariant[.='double-struck']">
422 <xsl:attribute name="class">doublestruck</xsl:attribute>
423 </xsl:template>
424
425
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>
429 </xsl:template>
430
431
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/>
438 </span>
439 </xsl:template>
440
441 <h:p>mn: a simple span</h:p>
442 <xsl:template match="m:mn">
443 <span class="mn">
444 <xsl:apply-templates/>
445 </span>
446 </xsl:template>
447
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])='&#x332;'">
452 <xsl:attribute
453 name="style">border-width: 0pt 0pt .1em 0pt; border-style: solid;"</xsl:attribute>
454 </xsl:if>
455 <span><xsl:apply-templates select="*[1]"/></span>
456 </span>
457 </xsl:template>
458
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])='&#xAF;'">
463 <xsl:attribute
464 name="style">border-width: .1em 0pt 0pt 0pt; border-style: solid;"</xsl:attribute>
465 </xsl:if>
466 <span><xsl:apply-templates select="*[1]"/></span>
467 </span>
468 </xsl:template>
469
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>
476 </table>
477 </xsl:template>
478
479 <h:p>mtext: a simple span</h:p>
480 <xsl:template match="m:mtext">
481 <span class="mtext">
482 <xsl:value-of select="normalize-space(.)"/>
483 </span>
484 </xsl:template>
485
486 <h:p>mstyle: not many attributes currently supported</h:p>
487 <xsl:template match="m:mstyle">
488 <span>
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>
492 </xsl:attribute>
493 <xsl:apply-templates/>
494 </span>
495 </xsl:template>
496
497
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="'&amp;#'"/>
504 <xsl:value-of select="@index"/>;<xsl:text/>
505 </font>
506 </xsl:template>
507
508 <h:p>ms: a simple span with left and right character added to the content.</h:p>
509 <xsl:template match="m:ms">
510 <span class="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>
514 </span>
515 </xsl:template>
516
517
518 <xsl:template match="m:math">
519 <xsl:call-template name="mrow"/>
520 </xsl:template>
521
522
523
524 <xsl:template match="m:mfenced">
525 <xsl:variable name="l">
526 <xsl:choose>
527 <xsl:when test="@open"><xsl:value-of select="@open"/></xsl:when>
528 <xsl:otherwise>(</xsl:otherwise>
529 </xsl:choose>
530 </xsl:variable>
531 <xsl:variable name="r">
532 <xsl:choose>
533 <xsl:when test="@close"><xsl:value-of select="@close"/></xsl:when>
534 <xsl:otherwise>)</xsl:otherwise>
535 </xsl:choose>
536 </xsl:variable>
537 <xsl:variable name="s">
538 <xsl:choose>
539 <xsl:when test="@sep">
540 <xsl:call-template name="text">
541 <xsl:with-param name="x" select="@sep"/>
542 </xsl:call-template>
543 </xsl:when>
544 <xsl:otherwise>,</xsl:otherwise>
545 </xsl:choose>
546 </xsl:variable>
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>
552 </xsl:for-each>
553 </span>
554 <span id="{generate-id()}R"><xsl:value-of select="$r"/></span>
555 <script>
556
557 <xsl:if test="$s=$opdict[@stretch='true']/@x">
558 <xsl:for-each select="*[position()&lt;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>
565 </xsl:if>
566
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/>
574
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/>
581 </script>
582 </xsl:template>
583
584
585
586 <xsl:template match="m:mmultiscripts">
587 <table style="display:inline; vertical-align: middle;">
588 <tr>
589 <xsl:for-each select="*[preceding-sibling::m:mprescripts and position() mod 2 = 0]">
590 <td><xsl:apply-templates select="."/></td>
591 </xsl:for-each>
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>
595 </xsl:for-each>
596 </tr>
597 <tr>
598 <xsl:for-each select="*[preceding-sibling::m:mprescripts and position() mod 2 = 1]">
599 <td><xsl:apply-templates select="."/></td>
600 </xsl:for-each>
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>
604 </xsl:for-each>
605 </tr>
606 </table>
607 </xsl:template>
608
609
610 <xsl:template match="m:none">&#xFEFF;</xsl:template>
611
612 <xsl:template match="m:merror">
613 <span class="merror"><xsl:call-template name="mrow"/></span>
614 </xsl:template>
615
616 <xsl:template match="m:mphantom">
617 <span class="mphantom"><xsl:apply-templates/></span>
618 </xsl:template>
619
620 <xsl:template match="m:maction[@type='tooltip']">
621 <span title="{*[2]}"><xsl:apply-templates select="*[1]"/></span>
622 </xsl:template>
623
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() &gt; 1]">
628 <span style="display:none;"><xsl:apply-templates select="."/></span>
629 </xsl:for-each>
630 </span>
631 </xsl:template>
632
633
634 <xsl:template match="m:maction[@type='statusline']">
635 <span id="{generate-id()}"
636 onmouseover="window.status='{*[2]}';"
637 onmouseout="window.status='';"
638 >
639 <xsl:apply-templates select="*[1]"/></span>
640 </xsl:template>
641
642
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>
647 </xsl:template>
648
649
650
651 <xsl:template match="m:mrow" name="mrow">
652 <span id="{generate-id()}" class="mrow">
653 <xsl:apply-templates select="*"/>
654 </span>
655 <xsl:if test="m:mo[@stretch='true' or normalize-space(.)=$opdict[@stretch='true']/@x]">
656 <script>
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]">
660
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>
668 </script>
669 </xsl:if>
670 </xsl:template>
671
672
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">&#xFEFF;</span>
681 <script>
682 msubsup("<xsl:value-of select="concat(generate-id(),'&quot;,',generate-id(),',',generate-id(),'x,',generate-id(),'b,',generate-id())"/>p);
683 </script>
684 </xsl:template>
685
686 <xsl:template match="h:table//m:msubsup|m:mtable//m:msubsup|m:msubsup"
687 priority="2">
688 <span>
689 <xsl:apply-templates select="*[1]"/>
690 </span
691 ><sub><xsl:apply-templates
692 select="*[2]"/></sub>
693 <sup><xsl:apply-templates
694 select="*[3]"/></sup>
695 </xsl:template>
696
697 <xsl:template match="m:msup
698 ">
699 <span id="{generate-id()}">
700 <xsl:apply-templates select="*[1]"/>
701 </span
702 ><span id="{generate-id()}p" class="msubsup"><xsl:apply-templates
703 select="*[2]"/></span
704 ><span id="{generate-id()}x">&#xFEFF;</span>
705 <script>
706 msup("<xsl:value-of select="concat(generate-id(),'&quot;,',generate-id(),'x,',generate-id())"/>p);
707 </script>
708 </xsl:template>
709
710 <xsl:template match="h:table//m:msup|m:mtable//m:msup|m:msup"
711 priority="2">
712 <span>
713 <xsl:apply-templates select="*[1]"/>
714 </span
715 ><sup><xsl:apply-templates
716 select="*[2]"/></sup>
717 </xsl:template>
718
719 <xsl:template match="m:msub
720 ">
721 <span id="{generate-id()}">
722 <xsl:apply-templates select="*[1]"/>
723 </span
724 ><span id="{generate-id()}p" class="msubsup"><xsl:apply-templates
725 select="*[2]"/></span
726 ><span id="{generate-id()}x">&#xFEFF;</span>
727 <script>
728 msub("<xsl:value-of select="concat(generate-id(),'&quot;,',generate-id(),'x,',generate-id())"/>p);
729 </script>
730 </xsl:template>
731
732 <xsl:template match="h:table//m:msub|m:mtable//m:msub|m:msub"
733 priority="2">
734 <span>
735 <xsl:apply-templates select="*[1]"/>
736 </span
737 ><sub><xsl:apply-templates
738 select="*[2]"/></sub>
739 </xsl:template>
740
741
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]"/>
745 <xsl:choose>
746 <xsl:when test="$mo"><xsl:copy-of select="$mo/node()"/></xsl:when>
747 <xsl:otherwise><xsl:copy-of select="$x"/></xsl:otherwise>
748 </xsl:choose>
749 </xsl:template>
750
751
752 <xsl:template match="m:msqrt">
753 <span class="msqrtx">\&#xFEFF;</span><span class="msqrt">
754 <xsl:apply-templates/>
755 </span>
756 </xsl:template>
757
758 <xsl:template match="m:menclose[@notation='radical']">
759 <span class="msqrtx">\&#xFEFF;</span><span class="msqrt">
760 <xsl:apply-templates/>
761 </span>
762 </xsl:template>
763
764 <xsl:template match="m:menclose[@notation='actuarial']">
765 <span class="actuarial">
766 <xsl:apply-templates/>
767 </span>
768 </xsl:template>
769
770 <xsl:template match="m:menclose">
771 <span class="msqrt">
772 <xsl:apply-templates/>
773 </span>
774 </xsl:template>
775
776 <xsl:template match="m:mroot">
777 <span class="msqrtx"><sup><xsl:apply-templates select="*[2]"/></sup>\&#xFEFF;</span><span class="msqrt">
778 <xsl:apply-templates select="*[1]"/>
779 </span>
780 </xsl:template>
781
782
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>
788 </xsl:if>
789 <xsl:if test="not($full)">
790 <xsl:attribute name="style">font-size: 100% ;</xsl:attribute>
791 </xsl:if>
792 <tr id="a{generate-id()}" class="mfraca"><td class="mfracaa">
793 <xsl:apply-templates select="*[1]"/>
794 </td></tr>
795 <tr id="b{generate-id()}" class="mfracb"><td>
796 <xsl:apply-templates select="*[2]"/>
797 </td></tr>
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 );
803 else a<xsl:value-of
804 select="generate-id()"/>.style.setExpression("height",b<xsl:value-of
805 select="generate-id()"/>.offsetHeight );
806 </script></xsl:if>
807 </xsl:template>
808
809 <xsl:template match="m:padded">
810 <span>
811 <xsl:attribute name="display">
812 </xsl:attribute>
813 <xsl:apply-templates/>
814 </span>
815 </xsl:template>
816
817
818 <xsl:template match="m:mspace">
819 <span style="padding-left: {@width};"></span>
820 </xsl:template>
821
822 <xsl:template match="m:mtable">
823 <table class="mtable">
824 <xsl:apply-templates/>
825 </table>
826 <script>
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()&lt;last()">,</xsl:if>
836 </xsl:for-each>]);</xsl:for-each>
837 </xsl:for-each>
838 </script>
839 </xsl:template>
840
841 <xsl:template match="m:mtr">
842 <tr>
843 <xsl:apply-templates/>
844 </tr>
845 </xsl:template>
846
847
848 <xsl:template match="m:mtd">
849 <td>
850 <xsl:apply-templates/>
851 </td>
852 </xsl:template>
853
854 <xsl:template match="m:maligngroup">
855 <xsl:variable name="g">
856 <xsl:choose>
857 <xsl:when test="@groupalign">
858 </xsl:when>
859 <xsl:when test="ancestor::td/@groupalign">
860 </xsl:when>
861 <xsl:when test="ancestor::tr/@groupalign">
862 </xsl:when>
863 <xsl:when test="ancestor::table/@groupalign">
864 </xsl:when>
865
866 <xsl:otherwise>left</xsl:otherwise>
867 </xsl:choose>
868 </xsl:variable>
869 <span id="{generate-id()}">&#xFEFF;</span>
870 </xsl:template>
871
872
873 </xsl:stylesheet>