The design of MathML

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

Creating a markup language to faithfully render mathematical notation is an extremely complex problem, for several reasons. First, unlike text, mathematics has a two-dimensional structure. This means that the markup language has to indicate information about the relative positioning of characters along both the horizontal and vertical axes.

Second, mathematics makes use of a very large number of special characters and symbols, each of which has a precise meaning depending on the context. Any language for representing mathematics must therefore find a way to deal with several thousand special characters and the fonts that represent them.

Third, mathematical notation relies upon a large number of typesetting conventions that have evolved over centuries of use. For example, variables that denote numbers are usually displayed in an italic font that is different from the usual italic text font. Also, the spacing around operators, such as + and =, is different from that of text, to reflect conventions about operator precedence.

There are many other conventions, such as the rules for choosing the size of parentheses and the proper alignment of subscripts and superscripts, as well as more specialized conventions used in specific sub-fields of mathematics. Any markup language that seeks to represent mathematical notation faithfully must respect all these conventions.

These conventions of mathematical notation are relevant both in authoring the markup and rendering it. The markup must be sufficiently detailed to store complete information about the two-dimensional structure of a formula. At the same time, the rendering application must be aware of all rules and conventions for translating the markup back into the corresponding visual representation.

MathML solves the first problem, namely how to encode the information about mathematical notation. The tasks of rendering the notation or interpreting its mathematical meaning are left to supporting software such as a browser plug-in, an equation editor, or a computer algebra system. MathML specifies guidelines for how specific elements should be rendered but, in general, rendering applications are free to use their own rules as long as the basic conventions of mathematical typesetting are observed.

The W3C's Math Working Group gave itself several challenging design goals in developing the specifications for MathML:

  • MathML should encode both mathematical notation and mathematical meaning.
  • MathML should be readable by humans but simple enough for software to generate and process.
  • MathML should be extensible.
  • MathML should provide a convenient medium for exchanging mathematical content between diverse software applications such as computer algebra systems and equation editors.
  • MathML should integrate well with the existing Web environment.
  • It should be possible to embed MathML in HTML markup so that it is accessible to browsers, search engines, and other Web applications that manipulate HTML.
  • It should be possible to render MathML embedded in HTML in current Web browsers.
  • It should be easy to convert between MathML and existing mathematical markup languages such as TEX.
  • It should be possible to easily modify existing authoring tools to generate MathML.
  • It should be easy to render MathML in multiple media such as print, Braille, and speech.

When MathML’s creators made it an application of XML, most of these design goals were achieved. XML is an extremely flexible and powerful language, ideally suited for creating structured documents that can be used across multiple platforms. Owing to the rapid growth in the popularity of XML in the last few years, many tools for processing and rendering XML documents are available. These include: editors and parsers for creating and validating XML documents, application programming interface (API) libraries — like Simple API for XML (SAX) and Document Object Model (DOM) — for manipulating XML, stylesheet mechanisms (like CSS and XSLT) for controlling the display and formatting of XML, as well as support for displaying XML documents in Web browsers. These tools can be used to develop applications for editing, importing, exporting, rendering, and processing MathML. Hence, developers of MathML applications do not have to start from scratch.

The only downside of making MathML an XML application is that XML syntax is extremely verbose. The MathML markup for even a simple one-line equation can extend for over half a page. As a result, MathML is difficult and error prone to edit by hand. However, this is not a serious problem since MathML’s creators did not intend for humans to author MathML directly. Rather, most people are expected to use software applications such as equation editors to generate MathML. There are several what-you-see-is-what-you-get (WYSIWYG) equation editors that support MathML as an output format. Typically, you can create a formula by clicking a series of buttons on a palette and then, using an appropriate menu command, convert the formula to MathML for pasting into an HTML document.

MathML is designed to serve as the bottom layer in a two-layer architecture. The top layer consists of software applications that the user directly interacts with (such as equation editors, Web browsers, or computer algebra systems). These applications provide a convenient interface for creating and displaying MathML, while automatically translating the user input into the low-level MathML markup. This arrangement is convenient because the user is insulated from the details of the low-level markup. At the same time, software behind the scenes can easily handle the conversion, since MathML is well suited for automated processing.

Although MathML markup is difficult to author by hand, it is still relatively easy to read and understand. Users with a basic familiarity with the syntax can open a MathML document in a text editor to examine or debug the markup, even if they choose not to author it directly for large-scale applications. In this way, MathML strikes a good balance between the demands of automated processing and human legibility.

This situation is analogous to that with HTML, which can be created by hand. However, the majority of professional Web developers use specialized Web authoring applications to generate the HTML. This allows developers to concentrate on creating the content and shifts the task of generating the underlying markup to the software. However, as with HTML, it is still worthwhile to understand the syntax of MathML so you can debug and modify documents by hand if the need arises.


<< 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