(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?
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:
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.