(Excerpt from "The MathML Handbook" by Pavi Sandhu)
Mozilla is the open-source version of the Netscape browser. Version 1.0 of Mozilla was released in June 2002 and supports native display of MathML 2.0 presentation elements, on Windows and Unix/Linux. MathML support for Macintosh was added starting with Mozilla 1.1. Netscape 7.0, released in September 2002, uses the same rendering engine as Mozilla 1.0 and also supports native display of MathML on Windows and Linux only. If you include a reference to the Universal MathML stylesheet, you can also display content MathML on recent versions of Mozilla/Netscape.
Creating XHTML documents
Mozilla cannot render MathML included in an HTML file. To be properly displayed, the MathML markup must be embedded in an XHTML document. XHTML is a reformulation of HTML to make it consistent with the rules of XML syntax. An XHTML document has the same tags and attributes as an HTML document and can therefore be displayed in any standard Web browser. But there are some important differences between XHTML and HTML arising from the fact that an XHTML document must be a well-formed and valid XML document.
Some of the important features of XHTML documents are:
- All tag names, attribute names, and attribute values must be written in lower case. For example, <H2 ALIGN="Center">...</H2> is not allowed but <h2 align="center">...</h2> is.
- All non-empty elements must have a closing tag. For example, <p>Some text is not allowed but <p>Some text</p> is.
- All empty elements must have a trailing slash. For example, <hr> is not allowed but <hr/> is.
- No two elements should overlap. For example, <p>Here is some <b><i>styled text.</b></i></p> is not allowed but <p>Here is some <b><i>styled text</i></b></p>.
- All attribute values must be quoted. For example, <table align=left> is not allowed but <table align="left"> is.
- Attribute value pairs must be written in full. For example, <td nowrap> is not allowed but <td nowrap="nowrap"> is.
- The root element must be an html element, with the XHTML namespace specified, as in <html xmlns="http://www.w3.org/1999/xhtml">.
Making all these changes to an existing HTML document takes a great deal of time and labor. You can greatly simplify this task by using a special utility called "TIDY", written specifically for this purpose by Dave Raggett. TIDY is a C program that takes an HTML document as input and returns an XHTML document as output, automatically making all the necessary changes and substitutions described above. The program can fix most common mistakes in an HTML document. However, if there are mistakes it cannot fix, but it issues a warning so you can fix them yourself. You can download a copy of TIDY from Clean up your Web pages with HTML TIDY.
Mozilla also requires each XHTML document to have an explicit DOCTYPE declaration that references the XHTML DTD. The W3C has supplied three separate DTDs for XHTML, called the strict, transitional, and frameset versions. For XHTML documents that contain MathML, you can use any of these three DTDs. However, the best choice is to use the following declaration, which refers to a combined DTD that merges the DTD for XHTML with a modified DTD for MathML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
Note that even if you include a reference to an external MathML DTD, Mozilla still refers to a local copy of the DTD installed in its cache. In other words, the DTD declaration is required but it is ignored.
The following example shows a simple document that can be displayed in Mozilla; it contains an MathML equation. The document must be valid and well-formed XHTML, and the filename must end with the extension .xml. This is to ensure that the server specifies the MIME type of the file as text/xml when sending the file to the browser. Note also the use of the DOCTYPE declaration to declare the DTDs for XHTML and MathML, and the namespace declaration on both the html element and the math element.
Example: An XHTML+MathML document suitable for display by Mozilla.
<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>MathML Example</title></head> <body> <p>Here is a simple equation.</p> <p> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> <msup><mi>x</mi><mn>2</mn></msup> <mo>-</mo> <mrow> <mn>2</mn><mo>⁢</mo><mi>x</mi> </mrow> <mo>+</mo><mn>1</mn> </mrow> </math> </p> </body> </html>
The following figure shows the above document as displayed in Mozilla. If you right-click on the equation, a pop-up menu that contains the command View MathML Source appears. Choosing this command opens another window that contains the MathML markup for the equation. You can copy the markup from this window and paste it into another application, if desired. Of course, you can also view the MathML markup embedded in the source for the XHTML document by choosing the View → Page Source menu command.
Figure: An XHTML document that contains MathML markup, as displayed by Mozilla.
Installing and customizing fonts
An important issue in displaying MathML in a browser is that the appropriate fonts for mathematical symbols and other special characters must be available. The two main add-ons for rendering MathML, MathPlayer and techexplorer, both come with their own set of mathematical fonts, and these are installed automatically when you install the software. Mozilla, however, does not include any special fonts for displaying mathematics. Hence, to properly view MathML using Mozilla or Netscape, you must install some additional fonts yourself. Otherwise, some mathematical symbols will not render properly.
One popular set of mathematical fonts are the Computer Modern fonts, which are typically part of any TeX or LaTeX distribution. These fonts are maintained by the AMS and are available for free download from their Web site.
To install the Computer Modern fonts, you must copy them onto your machine and then place them in the appropriate location for your operating system. Here are the instructions for installing these fonts on Windows NT/2000/XP:
- Copy the font files (called CMEX10, CMSY10, CMM10, and CMR10) on to your machine.
- These fonts are stored in the form of compressed archives. Use a program like WinZip to extract the files from the archives.
- Open the Fonts control panel using the Windows Start menu.
- In the File menu of the Fonts control panel, choose Install New Font.
- In the dialog that appears, specify the location of the font files on your machine and click OK.
The Computer Modern fonts are then installed on your machine and will be automatically used by Mozilla, if required.
You can tell Mozilla to use one font in preference to another. When you view a page that contains MathML, the View → Use Style submenu is automatically updated to show the following three choices, each corresponding to a specific set of mathematical fonts:
- Basic Page Style
The Basic Page Style setting uses the default fonts present on the system. By switching to TeX or Mathematica, you can force Mozilla to use the Computer Modern or Mathematica fonts, respectively, if these are installed on your system.
You can also customize Mozilla 's font preferences at a much lower level by setting up your own font-encoding tables. These allow you to associate particular fonts to be used for particular characters. For more information on how to do this, see Encoding MathFonts for Mozilla.
|<< back||next >>|
Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America