Page 1 of 1

latex string format of mathematical equation

PostPosted: Wed Sep 30, 2015 10:58 pm
by usharanicnp
hi to all,

I am developing a desktop application which deals word documents. so need to display math formulas in jframe.
To do that, i need latex string format of math equation. can docx4j provides latex string format of math formula ??
pls help me out of this problem...

thank you.. :?

Re: latex string format of mathematical equation

PostPosted: Fri Oct 02, 2015 6:51 pm
by jason
You could try omml to mathml to latex.

For omml to mathml, see further http://stackoverflow.com/questions/2570 ... -word-docx

For mathml to latex, Google provides plenty of info.

Let us know how you go...

Re: latex string format of mathematical equation

PostPosted: Wed Oct 07, 2015 9:57 pm
by usharanicnp
hi to all,

i am not understanding how to use "OMML2MML.XSL" (how to include in my java program) :roll:
pls share some code snippet.....

thank you in advance.

Re: latex string format of mathematical equation

PostPosted: Thu Oct 08, 2015 7:11 pm
by jason
docx4j's XmlUtils contains:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
    public static void transform(org.w3c.dom.Document doc,
                javax.xml.transform.Templates template,
                          Map<String, Object> transformParameters,
                          javax.xml.transform.Result result) throws Docx4JException
   
    public static void transform(javax.xml.transform.Source source,
                                          javax.xml.transform.Templates template,
                                          Map<String, Object> transformParameters,
                                          javax.xml.transform.Result result) throws Docx4JException

    public static Templates getTransformerTemplate(
                          javax.xml.transform.Source xsltSource) throws TransformerConfigurationException

 
Parsed in 0.028 seconds, using GeSHi 1.0.8.4


You can study how docx4j uses these for its XHTML and XSL FO output.

But basically, you make a Templates object out of OMML2MML.XSL

And you'd marshall your OMML to org.w3c.dom.Document or create javax.xml.transform.Source from it.

Then invoke transform. javax.xml.transform is standard java stuff, so questions about that are best asked on StackOverflow etc.

Re: latex string format of mathematical equation

PostPosted: Thu Oct 08, 2015 8:50 pm
by usharanicnp
hi,

i have used the below code

TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer(new javax.xml.transform.stream.StreamSource("res1/input/OMML2MML.xsl"));

my mmlstring output is :

<?xml version="1.0" encoding="UTF-8"?><mml:msup xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mml:mrow>
<mml:mfenced separators="|">
<mml:mrow>
<mml:mi>x</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi>a</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:mrow>
<mml:mrow>
<mml:mi>n</mml:mi>
</mml:mrow>
</mml:msup><mml:mo xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">=</mml:mo><mml:mrow xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mml:msubsup>
<mml:mo stretchy="true">?</mml:mo>
<mml:mrow>
<mml:mi>k</mml:mi>
<mml:mo>=</mml:mo>
<mml:mn>0</mml:mn>
</mml:mrow>
<mml:mrow>
<mml:mi>n</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mrow>
<mml:mfenced separators="|">
<mml:mrow>
<mml:mfrac linethickness="0pt">
<mml:mrow>
<mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi>k</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:mfenced>
<mml:msup>
<mml:mrow>
<mml:mi>x</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi>k</mml:mi>
</mml:mrow>
</mml:msup>
<mml:msup>
<mml:mrow>
<mml:mi>a</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi>n</mml:mi>
<mml:mo>-</mml:mo>
<mml:mi>k</mml:mi>
</mml:mrow>
</mml:msup>
</mml:mrow>
</mml:mrow>


i found mathml to latex conversion (java library). to do that mathml should be given below

<math>
<mtext>*******</mtext>
</math>

how can i convert omml to w3c supported mathml. pls help me.....

thanks in advance