rename upstream-man-pages to upstream-doc
[clinton/guile-figl.git] / upstream-doc / manglsl / xhtml / pmathml.xsl
CommitLineData
7faf1d71
AW
1<!-- saved from url=(0013)about:internet -->\r
2<xsl:stylesheet\r
3 version="1.0"\r
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
5 xmlns:mml="http://www.w3.org/1998/Math/MathML"\r
6 xmlns:h="http://www.w3.org/1999/xhtml"\r
7 xmlns="http://www.w3.org/1999/xhtml"\r
8 xmlns:msxsl="urn:schemas-microsoft-com:xslt"\r
9 xmlns:fns="http://www.w3.org/2002/Math/preference"\r
10 xmlns:doc="http://www.dcarlisle.demon.co.uk/xsldoc"\r
11 xmlns:ie5="http://www.w3.org/TR/WD-xsl"\r
12 exclude-result-prefixes="h ie5 fns msxsl fns doc"\r
13 extension-element-prefixes="msxsl fns doc"\r
14>\r
15\r
16<!--\r
17$Id: pmathml.xsl,v 1.8 2003/06/23 14:46:44 davidc Exp $\r
18\r
19Copyright David Carlisle 2001, 2002.\r
20\r
21Use and distribution of this code are permitted under the terms of the <a\r
22href="http://www.w3.org/Consortium/Legal/copyright-software-19980720"\r
23>W3C Software Notice and License</a>.\r
24-->\r
25\r
26<!-- MathPlayer mpdialog code for contributed by\r
27 Jack Dignan and Robert Miner, both of Design Science.\r
28-->\r
29\r
30<xsl:output method="xml" omit-xml-declaration="yes" />\r
31\r
32<ie5:if doc:id="iehack" test=".">\r
33 <ie5:eval no-entities="t">'&lt;!--'</ie5:eval>\r
34</ie5:if>\r
35\r
36\r
37<fns:x name="mathplayer" o="MathPlayer.Factory.1">\r
38<object id="mmlFactory"\r
39 classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">\r
40</object>\r
41<?import namespace="mml" implementation="#mmlFactory"?>\r
42</fns:x>\r
43\r
44<fns:x name="techexplorer" o="techexplorer.AxTchExpCtrl.1">\r
45<object id="mmlFactory" classid="clsid:0E76D59A-C088-11D4-9920-002035EFB1A4">\r
46</object>\r
47<?import namespace="mml" implementation="#mmlFactory"?>\r
48</fns:x>\r
49\r
50\r
51<!-- SCRIPT not script due to weird mozilla bug\r
52http://bugzilla.mozilla.org/show_bug.cgi?id=158457\r
53-->\r
54\r
55<fns:x name="css" o="Microsoft.FreeThreadedXMLDOM">\r
56<SCRIPT for="window" event="onload">\r
57var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");\r
58xsl.async = false;\r
59xsl.validateOnParse = false;\r
60xsl.load("pmathmlcss.xsl");\r
61var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0");\r
62xslTemplate.stylesheet=xsl.documentElement;\r
63var xslProc = xslTemplate.createProcessor();\r
64xslProc.input = document.XMLDocument;\r
65xslProc.transform();\r
66var str = xslProc.output;\r
67<!-- work around bug in IE6 under Win XP, RM 6/5/2002 -->\r
68var repl = "replace";\r
69if (window.navigator.appVersion.match(/Windows NT 5.1/)) { repl = ""; }\r
70var newDoc = document.open("text/html", repl);\r
71newDoc.write(str);\r
72</SCRIPT>\r
73</fns:x>\r
74\r
75\r
76<h:p>\r
77in mpdialog mode, we just write out some JavaScript to display\r
78dialog to the reader asking whether they want to install MathPlayer\r
79Depending on the response we get, we then instantiate an XSL processor\r
80and reprocess the doc, passing $secondpass according to the\r
81reader response.\r
82</h:p>\r
83<h:p>Using d-o-e is fairly horrible, but this code is only for IE\r
84anyway, and we need to force HTML semantics in this case.</h:p>\r
85\r
86<xsl:variable name="mpdialog">\r
87var cookieName = "MathPlayerInstall=";\r
88function MPInstall(){\r
89<!-- IE7 has native support for MathML, so exit early if IE7 detected -->\r
90 if (typeof document.body.style.maxHeight != "undefined") return null;\r
91 var showDialog=true;\r
92 var c = document.cookie;\r
93 var i = c.indexOf(cookieName);\r
94 if (i >= 0) {\r
95 if ( c.substr(i + cookieName.length, 1) >= 2) { showDialog=false; }\r
96 }\r
97 if (showDialog) {\r
98 MPDialog();\r
99 c = document.cookie;\r
100 i = c.indexOf(cookieName);\r
101 }\r
102 if (i >= 0) return c.substr(i + cookieName.length, 1);\r
103 else return null;\r
104}\r
105\r
106function MPDialog() {\r
107 var vArgs="";\r
108 var sFeatures="dialogWidth:410px;dialogHeight:190px;help:off;status:no";\r
109 var text = "";\r
110 text += "javascript:document.write('"\r
111 text += '&lt;script>'\r
112 text += 'function fnClose(v) { '\r
113 text += 'var exp = new Date();'\r
114 text += 'var thirtyDays = exp.getTime() + (30 * 24 * 60 * 60 * 1000);'\r
115 text += 'exp.setTime(thirtyDays);'\r
116 text += 'var cookieProps = ";expires=" + exp.toGMTString();'\r
117 text += 'if (document.forms[0].dontask.checked) v+=2;'\r
118 text += 'document.cookie="' + cookieName + '"+v+cookieProps;'\r
119 text += 'window.close();'\r
120 text += '}'\r
121 text += '&lt;/' + 'script>'\r
122 text += '&lt;head>&lt;title>Install MathPlayer?&lt;/title>&lt;/head>'\r
123 text += '&lt;body bgcolor="#D4D0C8">&lt;form>'\r
124 text += '&lt;table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>'\r
125 text += '&lt;tr>&lt;td align=left>This page requires Design Science\\\'s MathPlayer&amp;trade;.&lt;br>'\r
126 text += 'Do you want to download and install MathPlayer?&lt;/td>&lt;/tr>';\r
127 text += '&lt;tr>&lt;td align=center>&lt;input type="checkbox" name="dontask">'\r
128 text += 'Don\\\'t ask me again&lt;/td>&lt;/tr>'\r
129 text += '&lt;tr>&lt;td align=center>&lt;input id=yes type="button" value=" Yes "'\r
130 text += ' onClick="fnClose(1)">&amp;nbsp;&amp;nbsp;&amp;nbsp;'\r
131 text += '&lt;input type="button" value=" No " onClick="fnClose(0)">&lt;/td>&lt;/tr>'\r
132 text += '&lt;/table>&lt;/form>';\r
133 text += '&lt;/body>'\r
134 text += "')"\r
135 window.showModalDialog( text , vArgs, sFeatures );\r
136}\r
137\r
138function WaitDialog() {\r
139 var vArgs="";\r
140 var sFeatures="dialogWidth:510px;dialogHeight:150px;help:off;status:no";\r
141 var text = "";\r
142 text += "javascript:document.write('"\r
143 text += '&lt;script>'\r
144 text += 'window.onload=fnLoad;'\r
145 text += 'function fnLoad() {document.forms[0].yes.focus();}'\r
146 text += 'function fnClose(v) { '\r
147 text += 'window.returnValue=v;'\r
148 text += 'window.close();'\r
149 text += '}'\r
150 text += '&lt;/' + 'script>'\r
151 text += '&lt;head>&lt;title>Wait for Installation?&lt;/title>&lt;/head>'\r
152 text += '&lt;body bgcolor="#D4D0C8" onload="fnLoad()">&lt;form>&lt;'\r
153 text += 'table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>'\r
154 text += '&lt;tr>&lt;td align=left>Click OK once MathPlayer is installed '\r
155 text += 'to refresh the page.&lt;br>'\r
156 text += 'Click Cancel to view the page immediately without MathPlayer.&lt;/td>&lt;/tr>';\r
157 text += '&lt;tr>&lt;td align=center>&lt;input id=yes type="button" '\r
158 text += 'value=" OK " onClick="fnClose(1)">&amp;nbsp;&amp;nbsp;&amp;nbsp;'\r
159 text += '&lt;input type="button" value="Cancel" onClick="fnClose(0)">&lt;/td>&lt;/tr>'\r
160 text += '&lt;/table>&lt;/form>';\r
161 text += '&lt;/body>'\r
162 text += "')"\r
163 return window.showModalDialog( text , vArgs, sFeatures );\r
164}\r
165\r
166var result = MPInstall();\r
167\r
168var action = "fallthrough";\r
169if (result == 1 || result == 3) {\r
170 window.open("http://www.dessci.com/webmath/mathplayer");\r
171 var wait = WaitDialog();\r
172 if ( wait == 1) {\r
173 action = "install";\r
174 document.location.reload();\r
175\r
176 }\r
177}\r
178if (action == "fallthrough") {\r
179var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");\r
180xsl.async = false;\r
181xsl.validateOnParse = false;\r
182xsl.load("pmathmlcss.xsl");\r
183var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0");\r
184xslTemplate.stylesheet=xsl.documentElement;\r
185var xslProc = xslTemplate.createProcessor();\r
186xslProc.input = document.XMLDocument;\r
187\r
188xslProc.transform();\r
189var str = xslProc.output;\r
190<!-- work around bug in IE6 under Win XP, RM 6/5/2002 -->\r
191var repl = "replace";\r
192if (window.navigator.appVersion.match(/Windows NT 5.1/)) { repl = ""; }\r
193var newDoc = document.open("text/html", repl);\r
194newDoc.write(str);\r
195document.close();\r
196}\r
197</xsl:variable>\r
198\r
199<fns:x name="mathplayer-dl" >mathplayer-dl</fns:x>\r
200\r
201<fns:x name="techexplorer-plugin" >techexplorer-plugin</fns:x>\r
202\r
203<xsl:variable name="root" select="/"/>\r
204\r
205\r
206\r
207<xsl:param name="activex">\r
208 <xsl:choose>\r
209 <xsl:when test="/*/@fns:renderer='techexplorer-plugin'">techexplorer-plugin</xsl:when>\r
210 <xsl:when test="system-property('xsl:vendor')!='Microsoft'"/>\r
211 <xsl:otherwise>\r
212<xsl:variable name="docpref" select="document('')/*/fns:x[@name=$root/*/@fns:renderer][1]"/>\r
213 <xsl:choose>\r
214 <xsl:when test="$docpref='mathplayer-dl'">mathplayer-dl</xsl:when>\r
215 <xsl:when test="$docpref and fns:isinstalled(string($docpref/@o))='true'">\r
216 <xsl:copy-of select="$docpref/node()"/>\r
217 </xsl:when>\r
218 <xsl:otherwise>\r
219 <xsl:copy-of select="(document('')/*/fns:x[fns:isinstalled(string(@o))='true'])[1]/node()"/>\r
220 </xsl:otherwise>\r
221 </xsl:choose>\r
222 </xsl:otherwise>\r
223 </xsl:choose>\r
224</xsl:param>\r
225\r
226<h:div doc:ref="iehack">\r
227<h:h3>IE5 hacks</h:h3>\r
228<h:p>This code will be ignored by an XSLT engine as a top level\r
229element in a foreign namespace. It will be executed by an IE5XSL\r
230engine and insert &lt;!-- into the output stream, ie the start of a\r
231comment. This will comment out all the XSLT code which will be copied\r
232to the output. A similar clause below will close this comment, it is\r
233then followed by the IE5XSL templates to be executed.</h:p>\r
234<h:p>This trick is due to Jonathan Marsh of Microsoft, and used in\r
235<h:a href="http://www.w3.org/TR/2001/WD-query-datamodel-20010607/xmlspec-ie-dm.xsl">the stylesheet for\r
236the XPath 2 data model draft</h:a>.</h:p>\r
237</h:div>\r
238\r
239<h:h2>XSLT stylesheet</h:h2>\r
240<h:h3>MSXSL script block</h:h3>\r
241\r
242<h:p>The following script block implements an extension function that\r
243tests whether a specified ActiveX component is known to the client.\r
244This is used below to test for the existence of MathML rendering\r
245components.</h:p>\r
246<msxsl:script language="JScript" implements-prefix="fns">\r
247 function isinstalled(ax)\r
248 {\r
249 try {\r
250 var ActiveX = new ActiveXObject(ax);\r
251 return "true";\r
252 } catch (e) {\r
253 return "false";\r
254 }\r
255}\r
256</msxsl:script>\r
257\r
258<h:p>The main bulk of this stylesheet is an identity transformation so...</h:p>\r
259<xsl:template match="*|comment()">\r
260<xsl:copy>\r
261<xsl:copy-of select="@*"/>\r
262<xsl:apply-templates/>\r
263</xsl:copy>\r
264</xsl:template>\r
265\r
266\r
267\r
268<h:p>XHTML elements are copied sans prefix (XHTML is default namespace\r
269here, so these elements will still be in XHTML namespace</h:p>\r
270<xsl:template match="h:*">\r
271<xsl:element name="{local-name(.)}">\r
272 <xsl:copy-of select="@*"/>\r
273<xsl:apply-templates/>\r
274</xsl:element>\r
275</xsl:template>\r
276\r
277<h:p>IE's treatment of XHTML as HTML needs a little help here...</h:p>\r
278<xsl:template match="h:br|h:hr">\r
279<xsl:choose>\r
280<xsl:when test="system-property('xsl:vendor')='Microsoft'">\r
281 <xsl:value-of disable-output-escaping="yes" select="concat('&lt;',local-name(.))"/>\r
282 <xsl:apply-templates mode="verb" select="@*"/>\r
283 <xsl:text disable-output-escaping="yes">&gt;</xsl:text>\r
284</xsl:when>\r
285<xsl:otherwise>\r
286<xsl:element name="{local-name(.)}">\r
287 <xsl:copy-of select="@*"/>\r
288<xsl:apply-templates/>\r
289</xsl:element>\r
290</xsl:otherwise>\r
291</xsl:choose>\r
292</xsl:template>\r
293\r
294<h:p>This just ensures the mathml prefix declaration isn't copied from\r
295the source at this stage, so that the system will use the mml prefix\r
296coming from this stylesheet</h:p>\r
297<xsl:template match="h:html|html">\r
298<html>\r
299<xsl:copy-of select="@*[not(namespace-uri(.)='http://www.w3.org/2002/Math/preference')]"/>\r
300<xsl:apply-templates/>\r
301</html>\r
302</xsl:template>\r
303\r
304<h:p>We modify the head element to add code to specify a Microsoft\r
305"Behaviour" if the behaviour component is known to the system.</h:p>\r
306<h:span doc:ref="mp">Test for MathPlayer (Design Science)</h:span>\r
307<h:span doc:ref="te">Test for Techexplorer (IBM)</h:span>\r
308<h:span doc:ref="ms"><h:div>Test for Microsoft. In this case we just\r
309output a small HTML file that executes a script that will re-process\r
310the source docuument with a different stylesheet. Doing things this\r
311way avoids the need to xsl:import the second stylesheet, which would\r
312very much increase the processing overhead of running this\r
313stylesheet.</h:div></h:span>\r
314<h:span doc:ref="other">Further tests (eg for netscape/mozilla) could\r
315be added here if necessary</h:span>\r
316<xsl:template match="h:head|head">\r
317<head>\r
318\r
319<!-- new if for IE frames bug -->\r
320<xsl:if test="system-property('xsl:vendor')='Microsoft'">\r
321<xsl:if test="name(msxsl:node-set($activex)/*)=''">\r
322<object id="mmlFactory"\r
323 classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">\r
324</object>\r
325<xsl:processing-instruction name="import">\r
326 namespace="mml" implementation="#mmlFactory"\r
327</xsl:processing-instruction>\r
328</xsl:if>\r
329</xsl:if>\r
330\r
331<xsl:choose>\r
332<xsl:when doc:id="mp" test="$activex='mathplayer-dl'">\r
333 <xsl:if test="fns:isinstalled('MathPlayer.Factory.1')='false'">\r
334 <SCRIPT for="window" event="onload">\r
335 <xsl:value-of select="$mpdialog" disable-output-escaping="yes"/>\r
336 </SCRIPT>\r
337 </xsl:if>\r
338 <xsl:copy-of select="document('')/*/fns:x[@name='mathplayer']"/>\r
339</xsl:when>\r
340<xsl:when doc:id="mp" test="not($activex='techexplorer-plugin') and system-property('xsl:vendor')='Microsoft'">\r
341 <xsl:copy-of select="$activex"/>\r
342</xsl:when>\r
343<xsl:otherwise doc:id="other">\r
344</xsl:otherwise>\r
345</xsl:choose>\r
346 <xsl:apply-templates/>\r
347</head>\r
348</xsl:template>\r
349\r
350\r
351<xsl:template match="mml:math" priority="22">\r
352<xsl:choose>\r
353<xsl:when test="$activex='techexplorer-plugin'">\r
354<embed type="text/mathml" height="75" width="300">\r
355<xsl:attribute name="mmldata">\r
356<xsl:apply-templates mode="verb" select="."/>\r
357</xsl:attribute>\r
358</embed>\r
359</xsl:when>\r
360<xsl:otherwise>\r
361<xsl:element name="mml:{local-name(.)}">\r
362 <xsl:copy-of select="@*"/>\r
363<xsl:apply-templates/>\r
364</xsl:element>\r
365</xsl:otherwise>\r
366</xsl:choose>\r
367</xsl:template>\r
368\r
369\r
370<!-- squash annotation elements -->\r
371\r
372\r
373\r
374<h:p>Somewhat bizarrely in an otherwise namespace aware system,\r
375Microsoft behaviours are defined to trigger off the\r
376<h:em>prefix</h:em> not the <h:em>Namespace</h:em>. In the code above\r
377we associated a MathML rendering behaviour (if one was found) with the\r
378prefix <h:code>mml:</h:code> so here we ensure that this is the prefix\r
379that actually gets used in the output.</h:p>\r
380<xsl:template match="mml:*">\r
381<xsl:element name="mml:{local-name(.)}">\r
382 <xsl:copy-of select="@*"/>\r
383<xsl:apply-templates/>\r
384</xsl:element>\r
385</xsl:template>\r
386\r
387<h:p>Copy semantics element through in IE (so mathplayer gets to see\r
388mathplayer annotations, otherwise use first child or a presentation annotation.</h:p>\r
389<xsl:template match="mml:semantics">\r
390<xsl:choose>\r
391 <xsl:when test="system-property('xsl:vendor')='Microsoft'">\r
392 <xsl:element name="mml:{local-name(.)}">\r
393 <xsl:copy-of select="@*"/>\r
394 <xsl:apply-templates/>\r
395 </xsl:element>\r
396 </xsl:when>\r
397 <xsl:when test="mml:annotation-xml[@encoding='MathML-Presentation']">\r
398 <xsl:apply-templates select="mml:annotation-xml[@encoding='MathML-Presentation']/node()"/>\r
399 </xsl:when>\r
400 <xsl:otherwise>\r
401 <xsl:apply-templates select="*[1]"/>\r
402 </xsl:otherwise>\r
403</xsl:choose>\r
404</xsl:template>\r
405\r
406<!-- a version of my old verb.xsl -->\r
407\r
408<!-- non empty elements and other nodes. -->\r
409<xsl:template mode="verb" match="*[*]|*[text()]|*[comment()]|*[processing-instruction()]">\r
410 <xsl:value-of select="concat('&lt;',local-name(.))"/>\r
411 <xsl:apply-templates mode="verb" select="@*"/>\r
412 <xsl:text>&gt;</xsl:text>\r
413 <xsl:apply-templates mode="verb"/>\r
414 <xsl:value-of select="concat('&lt;/',local-name(.),'&gt;')"/>\r
415</xsl:template>\r
416\r
417<!-- empty elements -->\r
418<xsl:template mode="verb" match="*">\r
419 <xsl:value-of select="concat('&lt;',local-name(.))"/>\r
420 <xsl:apply-templates mode="verb" select="@*"/>\r
421 <xsl:text>/&gt;</xsl:text>\r
422</xsl:template>\r
423\r
424<!-- attributes\r
425 Output always surrounds attribute value by "\r
426 so we need to make sure no literal " appear in the value -->\r
427<xsl:template mode="verb" match="@*">\r
428 <xsl:value-of select="concat(' ',local-name(.),'=')"/>\r
429 <xsl:text>"</xsl:text>\r
430 <xsl:call-template name="string-replace">\r
431 <xsl:with-param name="from" select="'&quot;'"/>\r
432 <xsl:with-param name="to" select="'&amp;quot;'"/>\r
433 <xsl:with-param name="string" select="."/>\r
434 </xsl:call-template>\r
435 <xsl:text>"</xsl:text>\r
436</xsl:template>\r
437\r
438<!-- pis -->\r
439<xsl:template mode="verb" match="processing-instruction()"/>\r
440\r
441<!-- only works if parser passes on comment nodes -->\r
442<xsl:template mode="verb" match="comment()"/>\r
443\r
444\r
445<!-- text elements\r
446 need to replace & and < by entity references-->\r
447<xsl:template mode="verb" match="text()">\r
448 <a name="{generate-id(.)}"/>\r
449 <xsl:call-template name="string-replace">\r
450 <xsl:with-param name="to" select="'&amp;gt;'"/>\r
451 <xsl:with-param name="from" select="'&gt;'"/>\r
452 <xsl:with-param name="string">\r
453 <xsl:call-template name="string-replace">\r
454 <xsl:with-param name="to" select="'&amp;lt;'"/>\r
455 <xsl:with-param name="from" select="'&lt;'"/>\r
456 <xsl:with-param name="string">\r
457 <xsl:call-template name="string-replace">\r
458 <xsl:with-param name="to" select="'&amp;amp;'"/>\r
459 <xsl:with-param name="from" select="'&amp;'"/>\r
460 <xsl:with-param name="string" select="."/>\r
461 </xsl:call-template>\r
462 </xsl:with-param>\r
463 </xsl:call-template>\r
464 </xsl:with-param>\r
465 </xsl:call-template>\r
466</xsl:template>\r
467\r
468\r
469<!-- end verb mode -->\r
470\r
471<!-- replace all occurences of the character(s) `from'\r
472 by the string `to' in the string `string'.-->\r
473<xsl:template name="string-replace" >\r
474 <xsl:param name="string"/>\r
475 <xsl:param name="from"/>\r
476 <xsl:param name="to"/>\r
477 <xsl:choose>\r
478 <xsl:when test="contains($string,$from)">\r
479 <xsl:value-of select="substring-before($string,$from)"/>\r
480 <xsl:value-of select="$to"/>\r
481 <xsl:call-template name="string-replace">\r
482 <xsl:with-param name="string" select="substring-after($string,$from)"/>\r
483 <xsl:with-param name="from" select="$from"/>\r
484 <xsl:with-param name="to" select="$to"/>\r
485 </xsl:call-template>\r
486 </xsl:when>\r
487 <xsl:otherwise>\r
488 <xsl:value-of select="$string"/>\r
489 </xsl:otherwise>\r
490 </xsl:choose>\r
491</xsl:template>\r
492\r
493\r
494<!-- end of verb.xsl -->\r
495\r
496\r
497\r
498<h:h2>IE5XSL stylesheet</h:h2>\r
499<h:p>In a rare fit of sympathy for users of\r
500<h:em>the-language-known-as-XSL-in-IE5</h:em> this file incorporates a\r
501version of the above code designed to work in the Microsoft dialect.\r
502This is needed otherwise users of a MathML rendering behaviour would\r
503have to make a choice whether they wanted to use this stylesheet\r
504(keeping their source documents conforming XHTML+MathML) or to use\r
505the explicit Microsoft Object code, which is less portable, but would\r
506work in at least IE5.5.</h:p>\r
507\r
508<h:p>This entire section of code, down to the end of the stylesheet is\r
509contained within this ie5:if. Thus XSLT sees it as a top level element\r
510from a foreign namespace and silently ignores it. IE5XSL sees it as\r
511"if true" and so executes the code.</h:p>\r
512\r
513\r
514<h:p doc:ref="closecomment">First close the comment started at the beginning. This ensures\r
515that the bulk of the XSLT code, while being copied to the result tree\r
516by the IE5XSL engine, will not be rendered in the browser.</h:p>\r
517\r
518<h:span doc:ref="eval">Lacking attribute value templates in\r
519xsl:element, and the local-name() function, we resort to constructing\r
520the start and end tags in strings in javascript, then using\r
521no-entities attribute which is the IE5XSL equivalent of disable-output-encoding</h:span>\r
522<ie5:if test=".">\r
523\r
524<ie5:eval doc:id="closecomment" no-entities="t">'--&gt;'</ie5:eval>\r
525\r
526<ie5:apply-templates select=".">\r
527\r
528\r
529<ie5:script>\r
530 function mpisinstalled()\r
531 {\r
532 try {\r
533 var ActiveX = new ActiveXObject("MathPlayer.Factory.1");\r
534 return "true";\r
535 } catch (e) {\r
536 return "false";\r
537 }\r
538}\r
539</ie5:script>\r
540\r
541<ie5:template match="/">\r
542<ie5:apply-templates/>\r
543</ie5:template>\r
544\r
545<ie5:template match="head|h:head"/>\r
546\r
547<ie5:template match="text()">\r
548<ie5:value-of select="."/>\r
549</ie5:template>\r
550\r
551<ie5:template match="*|@*">\r
552<ie5:copy>\r
553<ie5:apply-templates select="*|text()|@*"/>\r
554</ie5:copy>\r
555</ie5:template>\r
556\r
557\r
558<ie5:template match="mml:*">\r
559<ie5:eval no-entities="t" doc:id="eval">'&lt;mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1)</ie5:eval>\r
560<ie5:for-each select="@*">\r
561<ie5:eval no-entities="t">' ' + this.nodeName</ie5:eval>="<ie5:value-of select="."/>"\r
562</ie5:for-each>\r
563<ie5:eval no-entities="t">'&gt;'</ie5:eval>\r
564<ie5:apply-templates select="*|text()"/>\r
565<ie5:eval no-entities="t">'&lt;/mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '&gt;'</ie5:eval>\r
566</ie5:template>\r
567\r
568\r
569<ie5:template match="mml:math">\r
570<ie5:if expr="mpisinstalled()=='false'">\r
571<embed type="text/mathml" height="75" width="300">\r
572<ie5:attribute name="mmldata">\r
573<ie5:eval doc:id="eval" no-entities="t">'&lt;math&gt;'</ie5:eval>\r
574<ie5:apply-templates/>\r
575<ie5:eval doc:id="eval" no-entities="t">'&lt;/math&gt;'</ie5:eval>\r
576</ie5:attribute>\r
577</embed>\r
578</ie5:if>\r
579<ie5:if expr="mpisinstalled()=='true'">\r
580<ie5:eval doc:id="eval" no-entities="t">'&lt;mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1)</ie5:eval>\r
581<ie5:for-each select="@*">\r
582<ie5:eval no-entities="t">' ' + this.nodeName</ie5:eval>="<ie5:value-of select="."/>"\r
583</ie5:for-each>\r
584<ie5:eval no-entities="t">'&gt;'</ie5:eval>\r
585<ie5:apply-templates select="*|text()"/>\r
586<ie5:eval no-entities="t">'&lt;/mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '&gt;'</ie5:eval>\r
587</ie5:if>\r
588</ie5:template>\r
589\r
590<ie5:template match="html|h:html">\r
591<html xmlns:mml="http://www.w3.org/1998/Math/MathML">\r
592<head>\r
593<ie5:if expr="mpisinstalled()=='true'">\r
594<object id="mmlFactory"\r
595 classid="clsid:32F66A20-7614-11D4-BD11-00104BD3F987">\r
596</object>\r
597<ie5:pi name="IMPORT">\r
598 namespace="mml" implementation="#mmlFactory"\r
599</ie5:pi>\r
600</ie5:if>\r
601<ie5:apply-templates select="h:head/*|head/*"/>\r
602</head>\r
603<body>\r
604<ie5:apply-templates select="body|h:body"/>\r
605</body>\r
606</html>\r
607</ie5:template>\r
608\r
609</ie5:apply-templates>\r
610\r
611\r
612</ie5:if>\r
613\r
614\r
615</xsl:stylesheet>\r