WIRIS editor and content MathML

This feature is available from WIRIS editor release 3.5 or superior. For this article we assume you are familiar with content MathML and presentation MathML.

WIRIS editor works natively with presentation MathML because it captures all the design features that authors might need.

WIRIS editor can also input and output content MathML. Formulas can be imported/exported to content MathML provided they are well formed according to a WIRIS editor build-in grammar.

For example, are valid formulas

«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«mfrac»«mn»1«/mn»«mn»2«/mn»«/mfrac»«mo»§nbsp;«/mo»«mo»§nbsp;«/mo»«mo»§nbsp;«/mo»«mn»3«/mn»«mo»+«/mo»«mn»2«/mn»«/math»

whereas the following are not

Content MathML is related to evaluation of formulas. Check the WIRIS editor decimal evaluation.

Enabling syntax checker

First of all, it is worth to enable the syntax checker in order to prevent users to write wrong formulas. The syntax checker highlights any formula that is not well formed and, thus, cannot be converted to content MathML.

The 3+ is not a well formed formula according to WIRIS editor.

Remember that you can embed WIRIS editor to any Web page. To enable the syntax checking, when initializing WIRIS editor,

editor = com.wiris.jsEditor.JsEditor.newInstance({'checkSyntax': 'true'});

or any time after the editor is created

editor.setParams({'checkSyntax': 'true'})

Setting content MathML to the editor

The Web based WIRIS editor accepts directly both presentation MathML and content MathML. The different render engines also accepts content MathML (for example, when generating PNG images).

Getting content MathML

WIRIS editor user interface (JavaScript) can only output presentation MathML. To obtain content MathML, a Web service or a direct call using Java or .NET is required to do the conversion from presentation MathML to content MathML.

Getting content MathML with Web service

A call to the Web service with both GET and POST methods are possible. In general it is preferable the POST method in order to avoid size limitations. The call has the form:

www.wiris.net/demo/editor/mathml2content?mml=presentation-mathml

where presentation-mathml is the presentation MathML. For example,

www.wiris.net/demo/editor/mathml2content?mml=<math><mn>1</mn><mo>-</mo><mn>2</mn></math>

Getting content MathML with a direct call with Java or .NET

To use this method you will need a license to download and run the WIRIS editor - server components. Available for Java and .NET.

The source code in Java:

PublicServicesInterface ps = PublicServices.getInstance();
Properties p = new Properties();
String content = ps.mathml2content(
   "<math><mn>1</mn><mo>+</mo><mn>2</mn></math>",p);

For c#:

PublicServicesInterface ps = PublicServices.getInstance();
Dictionary<string,string> d = new Dictionary<string,string>();
string content = ps.mathml2content(
   "<math><mn>1</mn><mo>+</mo><mn>2</mn></math>",d);

You will need to add the WIRISeditor.jar in the classpath (or the WIRISeditor.dll for .NET).

Converting from content MathML to presentation MathML

The Web based editor accepts content MathML, so in most scenarios you will not need to convert from content MathML to presentation MathML.

In case you need so, you can use the service or the method called content2mathml in a similar way to when converting to content MathML.

http://www.wiris.net/demo/editor/content2mathml?mml=<math><apply><minus/><cn>1</cn><cn>2</cn></apply></math>