Thursday, May 3, 2007


Was fiddling around with MathML this night and just could not get it to work correctly for the servers I have access to. I can make my own html files on both klaki and my school and tried both of them (see here and here for the results) and both of them gave out the wrong Content-Type so that firefox did not recognise them as xml files and displayed them wrongly. My solution was to put a .htaccess file in the directory with the files where the content was just

AddType application/xhtml+xml xhtml xht

This tells the apache web server that each file with the extension xhtml or xht should be sent out with the Content-Type application/xhtml+xml.

For those who have no idea what I am talking about then with each web page that you fetch from the net then there is a little header that you dont see and in that header there is a line of the form

Content-Type text/html

if the file is a normal html file. This line tells the web browser what kind of file he is looking at and then the web browser decides what to do with the file based on this information. Firefox relies solely on this line but IE looks into the content of the file and tries to guess what kind of file it is. So if this Content-Type is wrong for a xhtml file then Firefox does not display it correctly which was happening to me so I had to make the servers on those machines send out the right Content-Type so that my browser would know what to do with them. Since I dont have administration right to neither of those servers then I had to do it on my own work space. Apache server has this .htaccess file that overrides the default server configuration (if that is allowed by the administrators that is).

Pretty nifty ayhh?

I like this mathml idea, this could lead out to better math publishing on the net, with the use of SVG and mathml then science authors would not need to publish using pdf anymore and the user would not have to have a pdf viewer on his computer :-)

Unfortunately then IE does not provide support for mathml yet, but there are plugins available for it that can let you view such files. Firefox has builtin support for mathml.

1 comment:

Birgir said...

Another way is to use PHP:

header("Content-type: application/xhtml+xml");
print('<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
"" [
<!ENTITY mathml "">
<html xmlns="" xml:lang="en">
<math xmlns="&mathml;">