I’m looking for a C/C++ library that can convert MathML to infix and infix to MathML, eg given:
<?xml version="1.0" encoding="UTF-8"?>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<cn type="integer"> 2 </cn>
<ci> x </ci>
</apply>
</math>
the library will convert the mathml to 2*x. Or given x+sin (t) I get the following mathml
<?xml version="1.0" encoding="UTF-8"?>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<plus/>
<ci> x </ci>
<apply>
<sin/>
<ci> t </ci>
</apply>
</apply>
</math>
I know how to write such a library but would rather not reinvent the wheel if possible. Can’t be in Java as I must be able to link the library to non-managed code.
I’ve never used it myself, but it looks as though libSBML might serve your purposes:
http://www.google.co.uk/search?q=libsbml+convert+mathml+infix
http://sbml.org/Software/libSBML/docs/cpp-api/libsbml-features.html
On this page:
http://sbml.org/Software/libSBML/docs/cpp-api/
It says:
“The libSBML formula parser has been carefully engineered so that transformations from MathML to infix string notation and back is possible with a minimum of disruption to the structure of the mathematical expression.”
And has an example of what you’re trying to do…