a 'mooh' point

clearly an IBM drone

Now I get it - ODF and MathML

(see updated content below) 

Some time ago I wrote an article about ODF and usage of mathematical content by MathML. One of the quirks I couldn't get my head around was why the XML-file containing the MathML-document had to be named "content.xml". I used the phrasing

This was a bit more tricky, since somehow it seems that the mathical formula can only be contained in a file called "content.xml" - otherwise OpenOffice.org simply shuts down.

Well ... the answer came to me almost in a dream - or at least in the evening in one of those semi-awake-states. Basically the answer lies in the answer I never got on my question on which parts in an ODF-poackage are mandatory and if there are any parts with pre-defined names. The ODF-specification  section 9.3.3 says for embedding objects:

  • The xlink:href attribute links to the object representation, as follows:
    • For objects that have an XML representation, the link references the sub package of the object. The object is contained within this sub page exactly as it would as it is a document of its own.
    • For objects that do not have an XML representation, the link references a sub stream of the package that contains the binary representation of the object.

Now, in ODF MathML clearly has an XML-representation and MathML is also a "real" "OpenDocument representation". So a MathML is stored as a "sub package" within the ODF-package itself. And that brings me back to my original question.  You see, even though a piece of MathML is not a OpenDocument file per se, it still has to be embedded as an entire ODF-package (without the ZIP-structure). Section 2.1 clearly states this as

A document root element is the primary element of a document in OpenDocument format. It contains the entire document. All types of documents, for example, text documents, spreadsheets, and drawing documents use the same types of document root elements. The OpenDocument format supports the following two ways of document representation: 

  • As a single XML document.
  • As a collection of several subdocuments within a package (see section 17), each of which stores part of the complete document. Each subdocument has a different document root andsstores a particular aspect of the XML document. For example, one subdocument contains the style information and another subdocument contains the content of the document. All types of documents, for example, text and spreadsheet documents, use the same document and subdocuments definitions.

And since an ODF-package requires the main part to be called "content.xml" the MathML-file needs to be called "content.xml" as well. There is also no manifest file in the sub-package to tell the name of the package part - hence the requirement to have a fixed part name for the main part.  I wish this information was more clearly described in ODF and not simply implied in the text.

... did I mention that I prefer the relationship-model of OPC?


(update  2008-05-16)

A bit down in the comment track of this post I promised to make an ODT-file with MathML embedded inline as opposed to the "regular" OOo-way of embedding it as a seperate object. Today I finally got around to doing it. It was actually really easy - I just took the embedded MathML-object from the ODF-package and pasted in into the correct location in the content.xml-file. A good thing is that with this approach you don't have to worry about specifying a DOCTYPE (the OOo-dependancy), so I would say this is highly recommendable. The XML looks like this:

        = <math:mo>(</math:mo>

When opened in OOo (2.4 DA) the result looks like this:


Only remaining quirk is the missing "equals-sign", but I haven't had time to dig into those details yet.

If anyone can help and contribute here, that would be great.


Comments (6) -

In theory, you should be able to embed the math:math inline. The ODF standard indicates math:math is an allowed child of draw:object. But of course, theory is different than reality.

Hi Tusk,

Yes - but the aim of this small article was simply to pass on the reasoning about how to name package parts in an ODF-package - especially when using MathML as embedded objects.



Also - using MathML should theoretically be a no-brainer. I will try to make a test-document within a few days.

An update:

I have updated the article with an ODF-file with MathML embedded directly inline in the file content.xml .


Hi jlundstocholm,

Thanks a lot for the technique you explain above. It works prefectly (at least with OOo 2.3 for Linux): I was able to automatically generate an ODF document with MathML equations in it.

Note that it also works without the svg:* attributes. This way, you do not have to determine/guess the size of the equation beforehand.

"Only remaining quirk is the missing "equals-sign", but I haven't had time to dig into those details yet."

It is probably just caused by the missing math:mo tag around the equal sign.

All the best,

Hi jlundstocholm,

What I tried last month does not seem to work with OOo 2.4 any more. If you are interested, I posted a message on this subject on a OOo forum:

Comments are closed