Skip NavigationDesign Science: How Science Communicates
Products Solutions Store Support Reference Company View Cart
 
 

Creating MathML Web Pages

You have a number of options for creating MathML web pages. Design Science's MathType product contains MathML authoring capabilities, and several other vendors also provide MathML authoring tools. Web programmers also have the option of generating MathML web pages programmatically using the technical information below. 

Authoring with MathType

There are two ways to work with MathML using our MathType product:

From a Microsoft Word document:

If you have a Microsoft Word document containing MathType and/or Equation Editor equations, you can generate a web page using MathType's MathPage feature. Just choose the "XHTML+MathML" or "MathPlayer (IE behavior)" target in the MathPage dialog. The "MathPlayer (IE behavior)" target creates a standard HTML page viewable by Internet Explorer with MathPlayer. To create XHTML pages that are also viewable in Firefox and Mozilla, choose the "XHTML+MathML" target. See Making Your Pages Work with Firefox for more information about the differences between HTML and XHTML pages.

With your favorite HTML editor:

If you normally author web pages using an HTML editor, such as Adobe's Dreamweaver or Microsoft's Expression Web, you can use MathType to create equations one-by-one and paste them into the web page you are editing. First, go to MathType's Translator facility and choose the translator named "MathML 2.0 (m namespace)". Then, when you copy an equation from MathType's editing window, it will be automatically translated to MathML. Just bring your HTML editor to the front, place the insertion point where you want the equation and paste.

You will also need to make sure the head section of your HTML page contains the proper MathPlayer declaration statements. The easiest way to ensure your page is set up correctly is to start with one of the templates provided below in the Anatomy of a MathPlayer-enabled Web Page section.

Remember, we're authoring for IE+MathPlayer, but you can also use this technique to create XHTML pages that are viewable in Firefox and Mozilla as well as Internet Explorer. In this case, you will need to be sure your HTML editor can generate XHTML. Recent versions of Microsoft FrontPage or Expression Web and Adobe Dreamweaver all have this capability. In addition, you will also need to set your MathType translator to "MathML 2.0 (namespace attr)" and use different declarations in the head section of your page. As with HTML pages, the easiest way to ensure your page is set up correctly is to start with the appropriate template provided below in the Anatomy of a MathPlayer-enabled Web Page section.

Authoring with WebEQ

The WebEQ Developers Suite is no longer available and is being replaced with our MathFlow Software Development Kit (SDK). MathFlow™ is our family of products providing editing, display, and accessibility of mathematical notation for websites, applications and services. For more information about MathFlow please visit the MathFlow product pages. Existing WebEQ customers who wish to migrate to our new MathFlow Components, can find out about doing so here.

Other Authoring Tools

There are a number of other editors and converters available to help you author MathML Web pages. See the MathML Software list maintained by the World Wide Web Consortium (W3C).

Making your pages work with Firefox and Mozilla

Beginning with MathPlayer 2.1 you'll find added support for XHTML+MathML documents. Earlier versions of MathPlayer could only display MathML embedded in HTML documents. This caused interoperability problems with the Firefox and Mozilla browsers which only have support for MathML in XHTML documents. XHTML is a newer, XML-based version of HTML with much stricter syntax rules.

Browsers mostly rely on the MIME type of a document to determine whether to treat it as HTML or XHTML. The MIME type is set by the web server and sent along as part of the data in the HTTP response. While MathPlayer can render MathML in both HTML and XHTML pages, unfortunately Firefox and Mozilla can only display MathML in XHTML document. Thus, for maximum interoperability, you will want to generate XHTML pages. For a brief summary of the differences between HTML and XHTML, see Authoring MathML for Mozilla.

To support MathML in XHTML, MathPlayer 2.1 and later monitors incoming XML documents. When it detects an XHTML+MathML document, it automatically processes it to add the necessary MathPlayer declarations to the head of the document and to properly format any embedded MathML markup for display with MathPlayer. For MathPlayer's automatic processing of XHTML+MathML documents to be triggered for a page, it must satisfy the following conditions:

  1. The document must have a complete, valid XHTML+MathML DOCTYPE declaration, OR the document must declare the MathML namespace on the <html> element. In either case, the declaration must be contained within the first 2000 characters of the document.
  2. There can be no XSL stylesheet directive within the first 2000 characters of the page. If the author has specified XSL processing, automatic processing by MathPlayer will interfere.
  3. Documents served from a web server should be served with the MIME type
    • 'application/xhtml+xml' 

    IETF (Internet Engineering Task Force ), the standards organization in charge of MIME types, has issued new rules that make application/xhtml+xml the preferred MIME type for XHTML pages and that deprecate the use of text/xml. However, for backward compatibility, MathPlayer will continue to support XHTML documents served by a web server with MIME types 

    • 'text/xml' 
    • 'text/xml; charset=utf-8',
    • 'text/xml; charset=iso-8859-1'

    Note however, on some systems, MathPlayer processing may fail for these MIME types due to low-level conflicts in the handling of text/xml documents. Such conflicts were an important factor in IETF's decision to deprecate text/xml.

    For documents viewed from the local file system, and not through a web server, documents should be given the extension .xht rather than .xml to insure proper processing by MathPlayer.

See Server Setup and Configuration for more details on setting MIME types.

The universal math style sheet

Using an XSL stylesheet is another method for creating MathML web pages that are interoperable between Internet Explorer and MathPlayer, Firefox and Mozilla. Before MathPlayer 2.1 added direct support for XHTML, this was the only method to create interoperable web pages and is still in common use. The W3C provides a universal XSL Math stylesheet, along with instructions for its use.

MathPlayer 2.1 and later are backward compatible with the Universal Math Style Sheet. As noted above, XHTML+MathML pages that contain a link to a stylesheet will not be processed by MathPlayer, and will continue to function as they did with earlier versions of MathPlayer. Since XSL stylesheets lead to slower display and are somewhat tricky to use, we do not recommend the use of the W3C Math style sheet for new pages.

Anatomy of a MathPlayer-enabled Web Page

If you want to create a web page by hand, the following outlines what needs to be in an HTML or XHTML page for MathPlayer to work in Internet Explorer. For a more detailed discussion of the meaning and syntax of the relevant declaration statements in both formats, see Introduction to Using MathML.

For HTML:

<HTML XMLNS:m="http://www.w3.org/1998/Math/MathML">
<HEAD>
   <OBJECT
      ID=MathPlayer
      CLASSID="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"
   >
   </OBJECT>
   <?IMPORT NAMESPACE="m" IMPLEMENTATION="#MathPlayer" ?>
</HEAD>
<BODY>
...
<p>Here is some math:
   <m:math>
      <m:msup>
         <m:mi>x</m:mi>
         <m:mn>2</m:mn>
      </m:msup>
      <m:mo>+</m:mo>
      <m:mn>9</m:mn>
      <m:mi>x</m:mi>
      <m:mo>+</m:mo>
      <m:mn>9</m:mn>
      <m:mo>=</m:mo>
      <m:mn>0</m:mn>
   </m:math>
</p>
</BODY></HTML>

Here are some details:

  • The XMLNS:m attribute in the HTML tag establishes that any element name in the document prefixed by "m" refers to MathML 2.0.
  • In the HEAD element:
    • The OBJECT element attaches the "MathPlayer" ID to the MathPlayer software itself.
      • The CLASSID names MathPlayer's unique GUID that tells Internet Explorer (via the Windows Registry) where MathPlayer is installed on the local computer.
    • The IMPORT processing instruction says that elements whose namespace is indicated by the "m" prefix are to be displayed using the software whose ID is "MathPlayer".
  • Internet Explorer requires that MathML (or any XML fragment) embedded in the HTML document have each element name preceded by a namespace prefix -- "m" in this case.

The above HTML code is available as an HTML Page Template. To get your own copy of this file, right-click on the link in the previous sentence and choose the Save Target As command.

WARNING: The file menu Save and Save As commands will not properly save the file. Internet Explorer will remove the processing instruction. This is a known bug in Internet Explorer.

For XHTML

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
               "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>

...

<p>Here is some math:</p>

  <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
    <mi>g</mi>
    <mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow>
    <mo>=</mo>
    <mrow>
      <mfrac>
        <mi>&alpha;</mi>
        <mi>x</mi>
        </mfrac>
      <mo>+</mo>
      <mfrac>
        <mn>1</mn>
        <mn>2</mn>
      </mfrac>
    </mrow>
  </math>

</body>
</html>

Here are some details:

  • XHTML files must begin with an <?xml ... ?> processing instruction
  • The page must contain a valid XHTML+MathML DOCTYPE declaration before the start of the document markup as shown.
  • In XTHML all tag names are lower case.
  • The <html> element and each <math> element must have a namespace attribute (xmlns) with the values shown.

The above code is available as a XML Page Template. To get your own copy of this file, right-click on the link in the previous sentence and choose Save Target As. Doing View Source on the actual page will only get you what MathPlayer transforms the page into.

- top of page -
Copyright © 1996-2014 Design Science. All rights reserved. | Privacy statement