We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Converted XML has decimal numbers in 3 MathML elements

When decimal numbers in OfficeMath equations are converted into MathML, each decimal number is expressed in 3 different MathML elements. e.g.

A decimal number 0.75 is converted into the following. Some rendering JS library will put a small space between the dot (’.’) and the decimal digits (75), making a weird looking number.

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>0</mn><mo>.</mo><mn>75</mn></math>

A more concise and semantic correct version would be as follows.

<math xmlns="http://www.w3.org/1998/Math/MathML"><mn>0.75</mn></math>

It would be nice to fix this.

Here is the Java code for the conversion:

public class AsposeDecimalTest extends DocumentVisitor {
    public static void main(String[] args) throws Exception {
        try (InputStream inputStream = AsposeDecimalTest.class.getResourceAsStream("/AsposeDecimalTest.docx")) {
            Document doc = new Document(inputStream);
            doc.accept(new AsposeDecimalTest());

    public int visitOfficeMathStart(OfficeMath officeMath) {
        HtmlSaveOptions options = new HtmlSaveOptions();
        try {
            String mml = officeMath.toString(options);
            System.out.println("processed equation " + mml);
        } catch (Exception e) {
            throw new RuntimeException(e);

        return VisitorAction.SKIP_THIS_NODE;

AsposeDecimalTest.zip (9.6 KB)

This is word doc with a decimal number in OfficeMath Equation


For the sake of any corrections in Aspose.Words for Java API, we have logged this problem in our issue tracking system with ID WORDSNET-22789. We will further look into the details of this problem and will keep you updated here on the status of linked issue. We apologize for your inconvenience.

1 Like