Word equations to Oxygen equation editor

Post here questions and problems related to editing and publishing DITA content.
dLeipold123+
Posts: 1
Joined: Wed Aug 12, 2020 3:43 pm

Word equations to Oxygen equation editor

Post by dLeipold123+ »

I have an extremely large document to convert from Word to Oxygen DITA. One of the biggest problems is equations, and there are thousands of them.

I found a way to export the equation to from word MathML and get this:
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/offic ... <mml:mtext> </mml:mtext><mml:mo>=</mml:mo><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>C</mml:mi></mml:mrow><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>A</mml:mi></mml:mrow><mml:mrow><mml:mi>p</mml:mi><mml:mi>i</mml:mi><mml:mi>p</mml:mi><mml:mi>e</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:msqrt><mml:mfrac><mml:mrow><mml:mn>2</mml:mn></mml:mrow><mml:mrow><mml:mo>(</mml:mo><mml:msub><mml:mrow><mml:mi>P</mml:mi></mml:mrow><mml:mrow><mml:mi>a</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:mo>-</mml:mo><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>P</mml:mi></mml:mrow><mml:mrow><mml:mi>p</mml:mi><mml:mi>s</mml:mi></mml:mrow></mml:msub><mml:mo>)</mml:mo><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>v</mml:mi></mml:mrow><mml:mrow><mml:mi>w</mml:mi><mml:mo>,</mml:mo><mml:mi>a</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mfrac></mml:msqrt></mml:math>

I insert that into the equation editor and get this:
<p>MathML inline: <equation-inline>
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/offic ... /2006/math">
<mml:mi>W</mml:mi><mml:mtext> 
</mml:mtext><mml:mo>=</mml:mo><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>C</mml:mi></mml:mrow><mml:mrow><mml:mi>d</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>A</mml:mi></mml:mrow><mml:mrow><mml:mi>p</mml:mi><mml:mi>i</mml:mi><mml:mi>p</mml:mi><mml:mi>e</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:msqrt><mml:mfrac><mml:mrow><mml:mn>2</mml:mn><mml:mtext> </mml:mtext><mml:mfenced open="[" close="]" separators="|"><mml:mrow><mml:msub><mml:mrow><mml:mi>P</mml:mi></mml:mrow><mml:mrow><mml:mi>a</mml:mi></mml:mrow></mml:msub><mml:mtext> </mml:mtext><mml:mo>-</mml:mo><mml:mtext> </mml:mtext><mml:msub><mml:mrow><mml:mi>P</mml:mi></mml:mrow><mml:mrow><mml:mi>p</mml:mi><mml:mi>s</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mfenced></mml:mrow><mml:mrow><mml:msub><mml:mrow><mml:mi>v</mml:mi></mml:mrow><mml:mrow><mml:mi>w</mml:mi><mml:mo>,</mml:mo><mml:mi>a</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:mfrac></mml:msqrt></mml:math>
</equation-inline></p>

It looks fine in Author, but has element errors that MMM:Ml must be declared. It will not transform using the DITA Map PDF - based on HTML & CSS scenario.

I have gotten to the point where I just do not know how to fix this. I realize that the syntax isn't the same as:

<m:math display='inline'>
<m:semantics>
<m:mrow>
<m:msqrt>
...
But with thousands of these, I need the quickest way possible to get these equations in a format that can transform. I thought I had it because it finally looked right in Author, but I need to no how to add the correct element type to get it to transform.

Sorry if this topic has been addressed before. I didn't find it.

Thanks,

Debbi
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Word equations to Oxygen equation editor

Post by Radu »

Hi Debbi,

Besides changing the "mml:" prefix to "m:" you also need to add a "<mathml>" wrapper element around the entire equation, so you need some scripting to convert this:

Code: Select all

<equation-inline>
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/offic ... /2006/math">
                <mml:mi>W</mml:mi>...</mml:math>
        </equation-inline>
to this:

Code: Select all

<equation-inline>
       <mathml>
            <m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
                <m:mi>W</m:mi>......</m:math>
        </mathml></equation-inline>
Oxygen has support for custom XML refactoring actions based on XSLT stylesheets which can be used to fixup and change content from multiple files:

https://www.oxygenxml.com/doc/versions/ ... tools.html

We have a free GitHub project which can be downloaded as a zip containing lots of refactoring examples:

https://github.com/oxygenxml/dita-refactoring-examples

I just added a new folder there with a custom refactoring action which should fix your problem:

https://github.com/oxygenxml/dita-refac ... A%20topics

So if you download that entire project and unzip it on disk, in the Oxygen Preferences=>"XML / XML Refactoring" page you can point to the 34 Change Prefix in MathML Equation for DITA topics folder.
Save the preferences, then go to the Oxygen main menu Tools->"XML Refactoring" and it should display there a new action named "Change MathML Prefix". You can select that action and apply it on a set of files. You can also use the "Preview" to double check that it does what you want.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply