Object Library > Workshop > Schedule > MathML
The Extensible Markup Language (XML) is a meta-language, that is, a language for creating specialized markup languages for special purposes. Thus, XML is the mother of all markup languages. It is not a language itself, but rather is a framework, or set of rules, for creating standardized, compatible markup languages. XML is an extremely important standard, and XML applications are now becoming ubiquitous. Here are a few examples:
Just like HTML, XML documents are pure text, with the data marked up with tags of two basic types:
<tag></tag>
. This is a binary tag,
with an opening and closing part.<tag />
. This is unary tag.MathML is an XML application for encoding mathematics. Islands of MathML can be embedded in an ordinary HTML web page to display mathematics in correct notation. MathML is now a widely accepted standard, and is supported by many different applications, including
The potential of MathML is enormous. A mathematical expression encoded in MathML could be
MathML comes in two basic forms:
In Presentation MathML, the mathematical notation is marked up so that the expression is rendered in a specific way. This is much like TeX. By contrast, in Content MathML, the underlying structure and objects of the mathematical expression are marked up. The way that the expression is rendered is controlled by a style sheet.
Although MathML is not intended to be written by hand, a basic understanding of the structure is important for anyone using MathML. In the sections below, we discuss some of the basic markup. First, each mathematical expression in the document is an island of MathML, enclosed in the <math></math> tag. This tag has a display attribute. Setting the attribute to "block" causes the expression to be centered; otherwise the expression is inline.
MathML can be displayed using Internet Explorer 6.0 on Windows with the free MathPlayer plug-in or in Netscape Navigator 7.0 with MathML enabled and the appropriate fonts installed. In either case, additional markup must be added to the HTML code.
First add an attribute to the HTML tag:
<html xmlns:m="http://www.w3.org/1998/Math/MathML">
Next, add the following in the <head></head>
tag:
<object ID="MathPlayer" CLASSID="clsid:32F66A20-7614-11D4-BD11-00104BD3F987"></object>
<?import NAMESPACE="m" IMPLEMENTATION="#MathPlayer"?><xml:namespace prefix="m" />
<style> m:math {behavior: url(mml.htc)} </style>
Finally, each MathML tag has the prefix m:
First the files must be saved with the extension .xml, instead of .htm or .html. The following files, available from the MathML site at the World Wide Web Consortium should be saved to the server:
The first two lines should be as follows, where href points to the URL of mathml.xls
<?xml-stylesheet type="text/xsl" href="mathml.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml">
Finally, each island of MathML in the document begins with
<math xmlns="http://www.w3.org/1998/Math/MathML">
Variables and names are enclosed in the <mi></mi>
tag. By default, a single
character is rendered in italics, while multiple characters are rendered in
regular style.
<mi>x</mi>
<mi>sin</mi>
Numbers are enclosed in the <mn></mn>
tag.
<mn>2</mn>
<mn>3.1415926</mn>
Operators are enclosed in the <mo></mo>
. The usual arithmetic operators are
examples, but parentheses and other fences are also treated as operators.
<mo>+</mo>
<mo>-</mo>
<mo>⁢<mo>
<mo>(</mo>
<mo>)</mo>
<mo>,</mo>
Subexpressions are grouped using the <mrow></mrow>
tag.
<math>
<mrow><mn>5</mn><mo>(</mo><mi>x</mi><mo>+</mo><mi>y</mi><mo>)</mo></mrow>
</math>
Subscripts are defined using the <msub></msub>
tag.
<math>
<msub><mi>X</mi><mrow><mi>n</mn><mo>+</mo><mn>1</mn></mrow></msub>
</math>
Superscripts are defined using the <msup></msup>
tag.
<math>
<msup><mi>X</mi><mrow><mi>n</mn><mo>+</mo><mn>1</mn></mrow></msup>
</math>
Fractions are defined using the <mfrac></mfrac>
tag
<math>
<mfrac>
<mrow><msup><mi>x</mi><mn>2</mn> </msup>
<mo>−</mo><mn>1</mn> </mrow>
<mrow><msup><mi>x</mi><mn>2</mn> </msup>
<mo>+</mo><mn>1</mn> </mrow>
<mfrac>
</math>
<math>
<mrow>
<mo>(</mo>
<mfrac linethickness="0">
<mi>n</mi>
<mi>k</mi>
</mfrac>
<mo>)</mo>
</mrow>
</math>
<math>
<mrow>
<munderover>
<mo>∫</mo>
<mi>a</mi>
<mi>b</mi>
</munderover>
<mrow>
<mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mi>d</mi><mi>x</mi>
</mrow>
</mrow>
</math>
<m:math display="block">
<mrow>
<msub>
<mover accent='true'>
<mi>X</mi>
<mo>¯</mo>
</m:mover>
<mi>n</mi>
</msub>
<mo>=</mo>
<munderover>
<mo>∑</mo>
<mrow>
<mi>i</mi><m:mo>=</mo><mn>1</mn>
</mrow>
<mi>n</mi>
</munderover>
<mrow>
<msub>
<mi>X</mi>
<mi>i</mi>
</msub>
</mrow>
</mrow>
</math>
Variables and names are enclosed in the <ci></ci>
tag. By default, a single
character is rendered in italics, while multiple characters are rendered in
regular style.
<ci>x</ci>
<ci>var</ci>
Numbers are enclosed in the <cn></cn>
tag.
<cn>2</cn>
<cn>3.1415926</cn>
Operators are enclosed in a tag of the form <apply><operator /></apply>
.
<apply><plus /></apply>
<apply><minus /></apply>
<apply><times /></apply>
<apply><divide /></apply>
<apply><power /></apply>
<apply><selector /></apply>
<apply><eq /></apply>
<apply><lt /></apply>
<apply><leq /></apply>
Functions are defined with the <apply></apply>
tag. The first included
element is the function name, and the remaining included elements are the
variables.
Special functions have their own tags. They include
<apply><sin /></apply>
<apply><cos /></apply>
<apply<tan /></apply>
<apply><ln /></apply>
<apply><exp /></apply>
<apply><max /></apply>
<apply><min /></apply>
<math display="block">
<apply><divide />
<apply><plus />
<apply><power />
<ci>x</ci>
<cn>2</cn>
</apply>
<cn>1</cn>
</apply>
<apply><minus />
<apply><power />
<ci>x</ci>
<cn>2</cn>
</apply>
<cn>1</cn>
</apply>
</apply>
</math>
<math display="block">
<apply><m:eq />
<apply>
<ci>f</ci>
<ci>x</ci>
</apply>
<apply><times />
<ci>x</ci>
<apply><sin />
<apply><divide />
<cn>1</cn>
<ci>x</ci>
</apply>
</apply>
</apply>
</apply>
</math>
Object Library > Workshop > Schedule > MathML | Comments