Scientific WorkPlace 4 and MathML

Scientific WorkPlace 4 and MathML

This paper gives some background information on MathML and describes how MathML can be used from the Scientific WorkPlace family of products.

A Brief Description of MathML

Until very recently, the mathematics in web pages was frequently encoded as graphics (a .gif, .jpg or .png image). With MathML, the situation is changing.

MathML, short for Mathematical Markup Language, is a World Wide Web Consortium (W3C) Recommendation for encoding mathematical content on the web. MathML 1.01 has been a Recommendation since April, 1998 with the 1.01 revision dated July 7, 1999. MathML 2.0 was approved as a Recommendation early in 2001.

Thus MathML is the counterpart to HTML, Hypertext Markup Language, in which most web content is encoded. MathML is to mathematical content as HTML is to text. MathML includes elements for encoding both the Presentation and Content of mathematics. In general terms, the idea is that Presentation elements enable math to be rendered sensibly, while Content elements encode the meaning of the math sufficiently to allow computational systems to interact with it. (This is a very rough description, however. Content elements do have rendering, and Presentation elements do convey meaning; and targeted applications include more than computational and rendering systems.)

For a much fuller description of the aims and status of MathML, see the web site of the W3C Math Working Group.

Viewing MathML: the State of the Art

Currently (2002), support for MathML is still limited. Your favorite browser isn't likely to display a formula which is marked up with MathML.

However, there are plug-in viewers available that allow you to see MathML displayed in your browser. There are also full browsers available which can handle MathML mixed with HTML and often with other markup languages as well. Computational systems such as Mathematica and Maple can in some cases already "speak MathML". (Each system has its advantages, and several can currently be obtained free of charge. You should expect, however, that most readers will elect to use their traditional browsers, perhaps together with one of the plug-ins).

For a good list of what's available, see the list on the W3C Math Working Group home page.

Here's a short description of some of the plug-in and browser options.

WebEQ and MathType from Design Science

WebEQ Math Viewer is among the best of the early MathML plug-in renderers. You can freely download the viewer from the Design Science website.

Several strategies can be used to embed MathML in an HTML document so that it can be viewed via WebEQ, depending on your age and type of browser. In browsers that support Microsoft's Behaviors (such as versions 5.0 and later of Internet Explorer), the math markup can be mixed in directly with the surrounding text. In other browsers, the use of <APPLET> or <OBJECT> HTML elements is generally required.

techexplorer from IBM

IBM has released a new version of their techexplorer plug-in, which provides substantial support for viewing MathML. Again, the Introductory Edition can be freely downloaded from the techexplorer website. When you install it under Windows, you can elect to make it the default application associated with the .mml file extension used for MathML files. (You may want to uncheck the box that makes it the default application for .tex files, however! That would override the Scientific WorkPlace/NoteBook association.)

Viewing MathML in an HTML document using techexplorer generally requires <OBJECT> or <EMBED> elements. The Professional Edition has support for using Behaviors in IE 5.5.

Amaya from the W3C

The W3C supports development of Amaya, an editing and browsing tool that supports MathML as well as other markup languages. It can be downloaded from the Amaya website.

Using Amaya, MathML can be freely embedded in surrounding text; in fact, if the relevant namespaces are properly declared, HTML, MathML, and SVG (Scalable Vector Graphics markup) can be arbitrarily mixed. However, scripting in the document will not work.

MathPlayer from Design Science

MathPlayer is a new plug-in renderer from Design Science. You can freely download a beta test version of the viewer from the Design Science website. It works in IE 5.5 and higher on Windows.

We have found very good quality using MathPlayer and are eagerly awaiting its official release. See below for information on how to view SWP-generated files with MathPlayer.

Mozilla

Mozilla is the open-source community involved in NetScape development. Like Amaya, the latest version of the Mozilla browser is capable of displaying any mixture of MathML and HTML (actually, XHTML); significant work has been done on MathML support in Mozilla.

The Mozilla browser can be downloaded from their website.

Netscape 7, which uses Mozilla internally, is expected to contain MathML support on certain platforms, including Windows.

Using MacKichan MathML Support in SWP 4.0

MacKichan Software has been involved with the development of MathML since 1998. We have high hopes for the future of this technology, and intend to incorporate far-reaching support for it in the future development of our products.

In version 4.0 of the Scientific WorkPlace family of products, you can export documents as HTML with the math exported as MathML Presentation elements instead of graphic images.

Our early design goal was to script the document so that it could be viewed in most browsers (especially Internet Explorer or NetScape Navigator), using as many different plug-ins as possible and compatible with the most prevalent versions of the browsers. The rationale was that, in preparing documents containing math for viewing on the web, you'd of course like them to be as generally accessible as possible. Unfortunately, this has turned out to be a very difficult, if not intractable, problem.

At this point, this goal hasn't been achievable and we're expecting the environment to change rather slowly. To view the HTML + MathML documents currently requires the ActiveX control from the Professional Edition of techexplorer. Because the ActiveX control uses Behaviors, you must use Internet Explorer 5.5 or higher.

We have found that the combination of IE 5.5 and techexplorer gives high quality MathML rendering and allows us to embed the MathML in the HTML file.

Viewing SWP Files in MathPlayer

Viewing the HTML + MathML files generated by Scientific WorkPlace using MathPlayer is simply a matter of changing the CLASSID that Scientific WorkPlace uses in the HTML file. Open the file htmlout.cfg in your Scientific WorkPlace installation folder using an ASCII editor. Change the lines

 <OBJECT ID="mmlFactory" CLASSID="clsid:0E76D59A-C088-11D4-9920-002035EFB1A4"></OBJECT>
 <?IMPORT namespace="mml" implementation="#mmlFactory" />

to read

 <OBJECT ID="mathplayer" CLASSID="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"></OBJECT>
 <?IMPORT NAMESPACE="mml" IMPLEMENTATION="#mathplayer" />

and re-export your document.

Viewing SWP Files in Mozilla

You can also view the HTML + MathML files generated by Scientific WorkPlace using Mozilla. Presumably, similar steps would also work with Amaya. The steps below are a bit complicated, but the results you get using Mozilla will be quite good.

Switching from HTML to XHTML

Mozilla recognizes MathML only in XHTML files. Although this is perfectly reasonable it unfortunately makes for a messy conversion.

  1. Change the filename extension from .htm to .xml.

  2. Convert all the tag names in your file from uppercase to lowercase.

  3. Convert all the attribute names in your file from uppercase to lowercase. Note that this only applies to the text since all the MathML content is already in lowercase.

  4. Change the top four lines of the file to read as follows:

    <?xml version="1.0"?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"

    "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"

    xmlns:mml="http://www.w3.org/1998/Math/MathML">

    <head>

  5. Fix the content of the <head> section so that it's well-formed XHTML.

    1. Delete the (behaviors) lines

      <OBJECT ID="mmlFactory" CLASSID="clsid:0E76D59A-C088-11D4-9920-002035EFB1A4"></OBJECT>

      <?IMPORT namespace="mml" implementation="#mmlFactory" />

    2. Complete the tags for the remaining items. For example:

      <link href="testdata.css" rel="stylesheet" type="text/css"></link>

      <meta name="REVISED" content="Monday, August 27, 2001 20:30:15"></meta>

      etc.

  6. Edit your CSS file, changing all the uppercase tag names to lowercase. (This is really tedious. You might do it once and then re-use your new CSS file.)

The file should now load in Mozilla. If you want to put this file on a web server, you may need to configure your web server to handle XML/XHTML files.

Tweaking your Colors

Mozilla conforms to MathML 1.01 (with some 2.0 additions). You can also use CSS to style your mathematics. It's simplest to do this in the <style> tag in the <head> section of your file. For example, add the line

    math {color: red}

before the </style> line to make all your mathematics red.

Converting Files the Easy Way

We have written a Perl script that converts SWP-generated files to Mozilla-compatible files. It removes the reference to the CSS file and may not work with all constructs, but is still very useful. You must have Perl installed and should be handy with command prompts. You can download it the script from here.

Editing MathML

Of course, we recommend using Scientific WorkPlace/Scientific Word/Scientific Notebook to edit your mathematics, then exporting your file to MathML. Unfortunately, there is as yet no way to import MathML into these products.

We do have an experimental MathML editor that runs inside Mozilla, which you can read about here.


This document created by Scientific WorkPlace 4.1.