Framemaker, MathML, LyX & DocBook
History
When Adobe decided to discontinue FrameMaker on the Mac I had to look for a substitute. Unfortunately there is nothing similar like FrameMaker sofar (see http://www.infopage.net/fmforosx/possalts.html for possible alternatives); Luckily before abandoning OS X, Adobe had bundled SGML with the standard Frame product and at least I could export all my documents as XML … if it were not for the equations.
When using the built-in XML-export facilities, FrameMaker equations are exported as graphics making any further editing of them impossible.
One of the strengths of FrameMaker is that it is extensible and that it's fairly open. From the beginning (so I think) FrameMaker supported the MIF format (Maker Interchange Format), a complete (including the equations) textual description of your document. It's not very hard to convert a MIF-file into a well-formed XML-file which you can then convert further with stylesheets. But since XML-export is now standard there is no need anymore for going via the MIF-file… if it were not for the equations.
But you can also write extensions for FrameMaker yourself, using the FDK (Framemaker Development Kit). In particular you can write a Module wich will export your document as XML the way you like it.
For describing its equations FrameMaker uses so-called Mathfullform expressions, which is well-described in the documentation. Here is an example of such an expression:
'equal[cross[char[nabla],char[e,0,0,0,1,0]],minus[function[(*l109226ll109226ll109226l*)oppartial[char[t]],char[b,0,0,0,1,0]]]]'
... apparently it's not intended to be read and handled by humans, but everything is there and you can easily convert it into XML and then into MathML.
FrameMaker Module
I wrote a plugin (using the FrameMaker FDK7.0 and "Codewarrior Pro 5" under "Classic") which converts the Mathfullform expression into an equivalent well-formed XML-expression.The Mathfullform example shown above is exported as:
<EQUATION mathff="equal[cross[char[nabla],char[e,0,0,0,1,0]],minus[function[(*l109226ll109226ll109226l*)oppartial[char[t]],char[b,0,0,0,1,0]]]]">
<MathFF>
<equal>
<cross>
<char>
<atom>nabla</atom>
</char>
<char>
<atom>e</atom>
<atom>0</atom>
<atom>0</atom>
<atom>0</atom>
<atom>1</atom>
<atom>0</atom>
</char>
</cross>
<minus>
<function l_left_space="109226">
<oppartial>
<char>
<atom>t</atom>
</char>
</oppartial>
<char>
<atom>b</atom>
<atom>0</atom>
<atom>0</atom>
<atom>0</atom>
<atom>1</atom>
<atom>0</atom>
</char>
</function>
</minus>
</equal>
</MathFF>
</EQUATION>
The original Mathfullform-expression is also exported as an attribute. [One could also export the attribute only and then do the conversion to XML externally.] This conversion is rather straightforward, using a stack.
It should be obvious that before you can export as XML you should turn the FrameMaker document into a structured document. In addition since in the next step I convert the equations to content-MathML as much as possible there are some restrictions to the form of the FrameMaker equations. In particular functions should be defined as such (instead of using a pair of parentheses).
In order to use this module you'll need the FrameMaker Developement Kit. I've found that the fdk writing functions are limited with respect to the length of the string and for some large equations the complete converted string is too long. Therefore shorter segments are written to the xml-file (mff2xml.cp). The conversion is initiated in the wrtevent.c file which I modified from the /samples/struct example included with the fdk.
If you want to do the transformation outside of FrameMaker, perhaps starting from the MIF-file then the following routine can be used (mff2xml_ext.cp).
Stylesheets
I now have a complete XML-file, including the equations. Using an xslt stylesheet (mff2mml.xsl) (and e.g. Saxon, I use now version 8) the equations can now be turned into MathML. I tried to use content markup as much as possible but some constructs can only be handled with presentation markup. Using content markup has the drawback that the mathfullform equations should reflect the content correctly. E.g. functions should have been introduced in FrameMaker with the proper function-construct and not with parentheses. Similarly a superscript and a power are different. The stylesheet is also not complete: not all mathfullform-constructs are handled.
With a second stylesheet the intermediate XML-file (with MathML-equations) is transformed into a LaTeX-file, which can be read by LyX. This step depends on the structure of the (FrameMaker) document. For transforming the MathML-equations the xsltml stylesheets are used but with some modifications. The latter are defined in a separate file (myxsltml.xsl).
Once in LyX you can easily convert the document to e.g. DocBook-format by changing the document class and exporting. However there are still some problems with the DocBook-file generated by LyX. (E.g. the "<" in equations is not escaped.)
It's also fairly easy to transform the initial XML-file directly into DocBook+MathML using the higher mentionned mff2mml.xsl stylesheet and again a custom stylesheet for transforming the framemaker-structure directly into DocBook-elements. The resulting document can then be transformed to LaTeX with e.g. Dblatex, which also uses xsltml for transforming the MathML elements (to be tested).
If you have to start from an unstructured FrameMaker document, you could as well structure it directly as DocBook.

