Sunday 20 December 2009

XSLT for Presentation MathML in a Browser

Back in 2002 at the MathML Conference I presented a stylesheet, pmathml.xsl, that detected the browser being used and inserted whatever was necessary to enable MathML on that platform. The stylesheet is distributed, along with the slides from the conference presentation, from the W3C Math/XSL area.

The stylesheet is showing its age, in particular a large part of its complexity is due to the fact that that it encodes two completely separate languages in one file, XSLT, and the ‘wd-xslt’ language used in IE5. IE 5 is not an important platform these days, and for some years MathPlayer has been able to act as a MIME Filter in Internet Explorer, and so automatically insert the needed object references into the document without using an XSL stylesheet. However the XSL stylesheet mechanism still has uses, and may be adapted to other browsers. An updated version of this stylesheet has been in use for the NAG Library documentation.

I have placed an updated version of pmathml.xsl on google code. This loses all the wd-xsl code so requires IE6 or later, but it detects Opera and Safari and in that case inserts some extra elements to make it more likely that the documents meets the conditions of the MathML profile for CSS, and links to some CSS to render the resulting elements. The CSS is a combination of some old CSS of mine and George Chavchanidze's CSS developed as part of the MathML profile for CSS.

Unfortunately xlink links no longer work in Firefox 3, and so this version uses some javascript to give link behaviour to any element with an xlink:href attribute. Since it is doing this it also enables links for unprefixed href attributes, in anticipation of MathML3's href attribute for linking.

I hope to extend this to enhance MathML3 support, rendering the new MathML3 features as far as possible in existing browsers. The current check in is mainly to form a baseline in google code before adding any new MathML3 features.


tony525 said...

this is an interesting topic, we would love to see you again at XML Prague ... still time to make a submission at

Satish BD said...

Ah.. Nice to see pmathml being resurructed. But I am unable to find it in GoogleCode trunk. Has it been uploaded already ?

David Carlisle said...

The google code link above should work?

Anonymous said...

I am trying to open the following local file in Firefox and it doesn't show the formula correctly. My web connection is OK. When I try to open web pages that use mathml they show the formulas correctly. Do you have any idea of why the problem appears just with local files?



HTML file ("<" and ">" replaced by "[" and "]"):

[?xml version="1.0"?]
[?xml-stylesheet type="text/xsl" href=""?]

[html xmlns=""]



[math display="block" xmlns=""]


David Carlisle said...

If your local file has extension .html then by default it will be parsed as html not xml and mathml will not be enabled (until firefox starts supporting html5 in full)

As your example is presentation MathML Firefox should not need any stylesheet at all in order to display it, so check that is working first.

If you do want to use a stylesheet (to enable other browsers or to use content mathml from firefox) security restrictions on the various browsers usually mean it is better to refer to a local copy of the stylesheet rather than reference an external site.