'<!--' in mpdialog mode, we just write out some JavaScript to display dialog to the reader asking whether they want to install MathPlayer Depending on the response we get, we then instantiate an XSL processor and reprocess the doc, passing $secondpass according to the reader response. Using d-o-e is fairly horrible, but this code is only for IE anyway, and we need to force HTML semantics in this case. var cookieName = "MathPlayerInstall="; function MPInstall(){ var showDialog=true; var c = document.cookie; var i = c.indexOf(cookieName); if (i >= 0) { if ( c.substr(i + cookieName.length, 1) >= 2) { showDialog=false; } } if (showDialog) { MPDialog(); c = document.cookie; i = c.indexOf(cookieName); } if (i >= 0) return c.substr(i + cookieName.length, 1); else return null; } function MPDialog() { var vArgs=""; var sFeatures="dialogWidth:410px;dialogHeight:190px;help:off;status:no"; var text = ""; text += "javascript:document.write('" text += '<script>' text += 'function fnClose(v) { ' text += 'var exp = new Date();' text += 'var thirtyDays = exp.getTime() + (30 * 24 * 60 * 60 * 1000);' text += 'exp.setTime(thirtyDays);' text += 'var cookieProps = ";expires=" + exp.toGMTString();' text += 'if (document.forms[0].dontask.checked) v+=2;' text += 'document.cookie="' + cookieName + '"+v+cookieProps;' text += 'window.close();' text += '}' text += '</' + 'script>' text += '<head><title>Install MathPlayer?</title></head>' text += '<body bgcolor="#D4D0C8"><form>' text += '<table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>' text += '<tr><td align=left>This page requires Design Science\\\'s MathPlayer&trade;.<br>' text += 'Do you want to download and install MathPlayer?</td></tr>'; text += '<tr><td align=center><input type="checkbox" name="dontask">' text += 'Don\\\'t ask me again</td></tr>' text += '<tr><td align=center><input id=yes type="button" value=" Yes "' text += ' onClick="fnClose(1)">&nbsp;&nbsp;&nbsp;' text += '<input type="button" value=" No " onClick="fnClose(0)"></td></tr>' text += '</table></form>'; text += '</body>' text += "')" window.showModalDialog( text , vArgs, sFeatures ); } function WaitDialog() { var vArgs=""; var sFeatures="dialogWidth:510px;dialogHeight:150px;help:off;status:no"; var text = ""; text += "javascript:document.write('" text += '<script>' text += 'window.onload=fnLoad;' text += 'function fnLoad() {document.forms[0].yes.focus();}' text += 'function fnClose(v) { ' text += 'window.returnValue=v;' text += 'window.close();' text += '}' text += '</' + 'script>' text += '<head><title>Wait for Installation?</title></head>' text += '<body bgcolor="#D4D0C8" onload="fnLoad()"><form><' text += 'table cellpadding=10 style="font-family:Arial;font-size:10pt" border=0 width=100%>' text += '<tr><td align=left>Click OK once MathPlayer is installed ' text += 'to refresh the page.<br>' text += 'Click Cancel to view the page immediately without MathPlayer.</td></tr>'; text += '<tr><td align=center><input id=yes type="button" ' text += 'value=" OK " onClick="fnClose(1)">&nbsp;&nbsp;&nbsp;' text += '<input type="button" value="Cancel" onClick="fnClose(0)"></td></tr>' text += '</table></form>'; text += '</body>' text += "')" return window.showModalDialog( text , vArgs, sFeatures ); } var result = MPInstall(); var action = "fallthrough"; if (result == 1 || result == 3) { window.open("http://www.dessci.com/webmath/mathplayer"); var wait = WaitDialog(); if ( wait == 1) { action = "install"; document.location.reload(); } } if (action == "fallthrough") { var xsl = new ActiveXObject("Microsoft.FreeThreadedXMLDOM"); xsl.async = false; xsl.validateOnParse = false; xsl.load("pmathmlcss.xsl"); var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate.3.0"); xslTemplate.stylesheet=xsl.documentElement; var xslProc = xslTemplate.createProcessor(); xslProc.input = document.XMLDocument; xslProc.transform(); var str = xslProc.output; var repl = "replace"; if (window.navigator.appVersion.match(/Windows NT 5.1/)) { repl = ""; } var newDoc = document.open("text/html", repl); newDoc.write(str); document.close(); } mathplayer-dl techexplorer-plugin techexplorer-plugin mathplayer-dl IE5 hacks This code will be ignored by an XSLT engine as a top level element in a foreign namespace. It will be executed by an IE5XSL engine and insert <!-- into the output stream, ie the start of a comment. This will comment out all the XSLT code which will be copied to the output. A similar clause below will close this comment, it is then followed by the IE5XSL templates to be executed. This trick is due to Jonathan Marsh of Microsoft, and used in the stylesheet for the XPath 2 data model draft. XSLT stylesheet MSXSL script block The following script block implements an extension function that tests whether a specified ActiveX component is known to the client. This is used below to test for the existence of MathML rendering components. function isinstalled(ax) { try { var ActiveX = new ActiveXObject(ax); return "true"; } catch (e) { return "false"; } } The main bulk of this stylesheet is an identity transformation so... XHTML elements are copied sans prefix (XHTML is default namespace here, so these elements will still be in XHTML namespace IE's treatment of XHTML as HTML needs a little help here... > This just ensures the mathml prefix declaration isn't copied from the source at this stage, so that the system will use the mml prefix coming from this stylesheet We modify the head element to add code to specify a Microsoft "Behaviour" if the behaviour component is known to the system. Test for MathPlayer (Design Science) Test for Techexplorer (IBM) Test for Microsoft. In this case we just output a small HTML file that executes a script that will re-process the source docuument with a different stylesheet. Doing things this way avoids the need to xsl:import the second stylesheet, which would very much increase the processing overhead of running this stylesheet. Further tests (eg for netscape/mozilla) could be added here if necessary namespace="mml" implementation="#mmlFactory" Somewhat bizarrely in an otherwise namespace aware system, Microsoft behaviours are defined to trigger off the prefix not the Namespace. In the code above we associated a MathML rendering behaviour (if one was found) with the prefix mml: so here we ensure that this is the prefix that actually gets used in the output. Copy semantics element through in IE (so mathplayer gets to see mathplayer annotations, otherwise use first child or a presentation annotation. > /> " " IE5XSL stylesheet In a rare fit of sympathy for users of the-language-known-as-XSL-in-IE5 this file incorporates a version of the above code designed to work in the Microsoft dialect. This is needed otherwise users of a MathML rendering behaviour would have to make a choice whether they wanted to use this stylesheet (keeping their source documents conforming XHTML+MathML) or to use the explicit Microsoft Object code, which is less portable, but would work in at least IE5.5. This entire section of code, down to the end of the stylesheet is contained within this ie5:if. Thus XSLT sees it as a top level element from a foreign namespace and silently ignores it. IE5XSL sees it as "if true" and so executes the code. First close the comment started at the beginning. This ensures that the bulk of the XSLT code, while being copied to the result tree by the IE5XSL engine, will not be rendered in the browser. Lacking attribute value templates in xsl:element, and the local-name() function, we resort to constructing the start and end tags in strings in javascript, then using no-entities attribute which is the IE5XSL equivalent of disable-output-encoding '-->' function mpisinstalled() { try { var ActiveX = new ActiveXObject("MathPlayer.Factory.1"); return "true"; } catch (e) { return "false"; } } '<mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) ' ' + this.nodeName="" '>' '</mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '>' '<math>' '</math>' '<mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) ' ' + this.nodeName="" '>' '</mml:' + this.nodeName.substring(this.nodeName.indexOf(":")+1) + '>' namespace="mml" implementation="#mmlFactory"