MathSBML

MathSBML Home Page MathSBML Site Map

The MathSBML Model Builder: MathMLtoInfix, InfixtoMathML


These functions convert between Content-MathML and Infix Expressions

The argument to MathMLtoInfix is a string containing MathML.

The argument to InfixtoMathML is any Mathematica Expression.

Note: These functions will produce content MathML. There is not guarantee that the MathML will be restricted to the subset of MathML allowed in SBML.

New in version 2.1.4.

Examples

The expression:
	InfixToMathML[(a+Sin(x)b)/c-5]
returns the string
	<math xmlns='http://www.w3.org/1998/Math/MathML'>
	 <apply>
	  <plus/>
	  <apply>
	   <times/>
	   <apply>
	    <plus/>
	    <ci>a</ci>
	    <apply>
	     <times/>
	     <ci>b</ci>
	     <sin/>
	     <ci>x</ci>
	    </apply>
	   </apply>
	   <apply>
	    <power/>
	    <ci>c</ci>
	    <cn type='integer'>-1</cn>
	   </apply>
	  </apply>
	  <cn type='integer'>-5</cn>
	 </apply>
	</math>
The expression
     MathMLtoInfix[
     "<math xmlns='http://www.w3.org/1998/Math/MathML'>
      <apply>
        <plus/>
        <ci>a</ci>
        <apply>
           <times/>
           <ci>b</ci>
           <apply>
             <power/>
             <ci>c</ci>
             <cn >-1</cn>
           </apply>
       </apply>
     </apply>
     </math>\"]
will return the expression
	a+b/c
Alternatively, one can read the MathML expression from a text file into a string s, e.g., as
	s = Import["foo.doc","text"]; 
	MathMLtoInfix[s]
to obtain the infix expressions. Any file name or file type can be used, so long as the second argument to Import is "text".



Go to the top of this page