MathML (.mml)

Background & Context

    • MIME type: text/mathml, application/mathml+xml
    • MathML mathematical markup language.
    • Used for integrating mathematical formulas in web documents.
    • Rendering of embedded MathML is supported by a number of browsers and browser additions.
    • Specifies the presentation and the semantic content of mathematical formulas.
    • XML-based format.
    • Based on a draft that was derived from the Wolfram typesetting language.
    • Introduced in 1999 and updated in 2003 by the W3C math working group.

Import & Export

  • Import["file.mml"] imports a MathML file and returns a box expression.
  • Export["file.mml",expr] exports an arbitrary expression to MathML.
  • Import["file.mml"] reads the MathML presentation elements from a file and converts them to the corresponding Wolfram Language box expression.
  • Import["file.mml","Expression"] converts MathML to a Wolfram Language expression using TraditionalForm interpretation rules.
  • Export["file.mml",expr] converts a box expression or an arbitrary Wolfram Language expression to MathML.
  • When exporting an arbitrary mathematical expression, its presentation and its context are represented in the resulting MathML.
  • Import["file.mml",elem] imports the specified element from a MathML file.
  • Import["file.mml",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file", "MathML"] or Import["file",{"MathML",elem,}].
  • Export["file.mml",expr, elem] creates a MathML file by treating expr as specifying element elem.
  • Export["file.mml",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["file.mml",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.mml",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • The export format can be explicitly specified in the form Export["file",expr,"MathML"] or Export["file",expr,{"MathML",elems}].
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Boxes"MathML typeset as a Wolfram Language box expression
    "Expression"arbitrary Wolfram Language expression
    "HeldExpression"unevaluated expression
    "XMLObject"MathML as a symbolic XML expression
    "XMLElement"nested XMLElement objects
  • Import and Export use the "Boxes" element by default.

Options

  • Export options:
  • "Annotations"{}which annotations to include
    "Presentation"Truewhether to export MathML presentation elements
    "Content"Falsewhether to export MathML content elements
  • The setting for "Annotations" is a list which may include any number of the choices "DocumentHeader", "XMLDeclaration", and "DOCTYPEDeclaration".

Examples

Basic Examples  (2)

Exporting an arbitrary mathematical expression by default generates presentation MathML:

This creates combined presentation and content MathML:

This generates pure content MathML:

Define and display a Wolfram Language box expression:

Convert it to presentation MathML:

Convert the previous output to a box expression and display it:

Import automatically recognizes the MathML format:

Show the available Import elements:

Convert MathML to an evaluated expression:

Import MathML as a symbolic XML expression: