MathML Content2Presentation Transformation (MathMLc2p)
There are two ways of enconding mathematical data using MathML:
- Content markup is concerned with the semantics of mathematics
- Presentation markup is concerned with the rendering of mathematics
The MathML Content2Presentation Transformation (MathMLc2p), written in XSLT, is able to translate content markup expressions into presentation markup expressions automatically.
MathMLc2p is now maintained by the members of project JEuclid. The latest version of the stylesheet can be downloaded from their repository. Previous versions are available from the corresponding entry in the history log. The latest version is made available under the Apache license; earlier versions were distributed under the MIT license. Many improvements on early versions have been contributed by Brent Hendricks and Josh Bode.
A tracker dedicated to MathMLc2p is available on the JEuclid Web site.
What you should know about this stylesheet
There is no guarantee that the stylesheet covers all the needs. I implemented it a few years ago while working for Xerox Research Centre Europe and INRIA Rhône-Alpes. I am no longer officially working on MathMLc2p, but I am still available to answer questions and maybe fix a few bugs (depending on their difficulty). Contributions to MathMLc2p are still welcome.
The current version is based on the 13 November 2000 MathML 2.0 Candidate Recommendation. As a consequence, it is not intended for use with MathML 1.x
Entity references have been replaced by mchar entities, but entity references in the source document are still supported as long as they are defined somewhere. Content tags defined by presentation tags are supported, as well as XML annotations encoded in MathML-Presentation or MathML-Content.
Since mchar elements are not part of the spec any more, I switched back to standard entity references.
What it does not do
The transformation takes content markup and outputs presentation markup according to the default rendering given in Chapter 4. It does not try to enhance the rendering by adding additional information like spacing attributes, nor does it split an expression if it's too long, since this kind of thing is rendering software/device dependent.
How to use it
You need an XML parser and an XSLT engine, such as J. Clark's XP+XT written in Java.
The MathMLc2p stylesheet's filename is mathmlc2p.xsl
The command line, for James Clark's XT, when used in conjunction with XP is:
"java -Dcom.jclark.xsl.sax.parser=com.jclark.xml.sax.CommentDriver com.jclark.xsl.sax.Driver input.xml mathmlc2p.xsl output"
The stylesheet is set to generate an output XML file without XML declaration.
Known bugs
- Latest version has been tested successfully against all examples provided in the Content section of the MathML test suite.
- Problem with fn tags in some cases (too many commas when there are several arguments).
Possible improvements
- Better handling of compose and inverse
- Detect more cases in which vectors have to be rendered vertically instead of horizontally. Right now, only vectors which are multiplied by a matrix and which are on the right of this matrix are rendered vertically. I have chosen horizontal rendering as default because, according to the draft, vectors can be used as the list of arguments of a function (see Chapter 4:tendsto)
Related links
Amaya: W3C's HTML browser/editor, capable of rendering MathML presentation markup (used to test MathMLc2P's output)
History
Latest version (Download)
- Maintained by JEuclid project members
Version 2007-05-22 (Download)
- Removed useless namespace prefix bindings in output (contributed by Josh Bode)
Version 2007-04-24 (Download)
- Moved an xsl:param declaration that made MSXML unhappy (contributed by Josh Bode)
Version 2005-07-19 (Download)
- Distributed under the open-source MIT license.
- The following improvements (also available as patches) have been contributed by Brent Hendricks from Connexions:
- Removed explicit child:: in most cases since that is the default axis
- Use self:: tests instead of name() since name() does not match only local names in most XSLT processors
- Use abbreviated notation [x] for [position()=x]
- Support for type="e-notation" (4.4.1)
- Improved support for markup inside ci/cn (4.4.1) (vector special case)
- Use {{ escape instead of xsl:element in piecewise and widen mspace (4.4.2)
- Extra <mrow> in divide to ensure <mfrac> has only two children (4.4.3)
- Missing self-exclusions in min and max apply-templates (4.4.3)
- Added missing templates for qualifiers: lowlimit, uplimit, bvar, degree (4.4.5) and logbase (4.4.8)
- Extra <mrow> in mean to ensure <mover> has only two children (4.4.9)
- More support for domainofapplication (4.4.2) in min, max, sum, and product
- Use {{ escape instead of xsl:element in set (4.4.6)
- Extra spacing in matrix
- Fixed unicode chars for integers, reals, rationals, naturals, complex, prime
Version 2000-12-14 (Download)
- Added ( ) around -1 in inverse.
- Removed differential d from int when the integral is defined by domainofapplication.
- Replaced <munderover> by <msubsup> and <munder> by <msub> in integrals (int).
- <apply><diff/><ci>f</ci></apply> is now rendered as f'
Version 2000-12-04
- Added support for new elements : cartesianproduct.
- Fixed some rule specificity conflicts.
- Minor bug fixes wrt bvar element in diff and partialdiff.
- Fixed bug wrt namespace problem using the name() function
Version 2000-11-24
- Added support for new elements : domain, codomain, image, piecewise, floor, ceiling, factorof, momentabout.
- Replaced mchars by standard entity references.
- Minor bug fixes
Version 2000-06-14
- Added support for the MathML namespace "http://www.w3.org/1998/Math/MathML". Examples have been updated accordingly.
Version 2000-06-13
- Removed redundant element mrow (child of math)
- Added support for element mtext in source
- Added support for deprecated element reln
- Fixed bug in elements forall and exists
- All math elements are processed, no matter there depth in the XML source document
Version 2000-04-14
- First version made public