Date: prev next · Thread: first prev next last


hi Vivien,

On 17/01/2024 18:26, vivien guillet wrote:
Hello

I cannot find the correct way to add mathml to an odt document using
odftoolkit.

I create a TextPElement / DrawFrameElement / DrawObjectElement container
with the MathML element in it this way:

TextPElement p = odt.getContentRoot().newTextPElement();
DrawFrameElement drawFrame = p.newDrawFrameElement();
DrawObjectElement drawObject= drawFrame.newDrawObjectElement();
MathMathElement math = drawObjectElement.newMathMathElement();

Then the actual mathml nodes in the object

OdfElement semantics = odt.getContentDom().createElement("semantics");
math.appendChild(semantics);

and so on using standard dom operations...

When I open the resulting odt, the object is empty.

Now if I hand-edit the odt zip content.xml file to add an
xmlns="http://www.w3.org/1998/Math/MathML"; attribute to the <math:math>
tag, everything displays just fine.

creating the math element using
OdfElement math =
odt.getContentDom().createElementNS("http://www.w3.org/1998/Math/MathML","math:math";);
yields the same (non working) result

working and non-working documents are in attachements.

unfortunately the mailing list doesn't appear to allow attachments...

perhaps try to copy the "draw:object" elment out of the non-working content.xml and send that inline, then we can have a look?

So my question is : what would be the correct way to add mathml inside a
document (with the correct mathml namespace attribute) ?

not only the math node must be in the math namespace but all of the descendants like "semantics" too - i think that's the most likely explanation: create every element with the namespace.

Any help would be appreciated !

V.


--
To unsubscribe e-mail to: dev+unsubscribe@odftoolkit.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.odftoolkit.org/dev/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.