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