my goal is transfrom omml to mathml. and i do a lot of search, get the steps below:
1:get the math Dom, and to Node
2:use Transformer to mathml by OMML2MML.XSL
But I stunk in the first step.
this is my code. It throw exception in line 2:JAXBContext.newInstance.
could anyone tell me how to fix , or other ways to my goal.
thanks in andvance
- Code: Select all
CTOMath ctoMath = (CTOMath)((JAXBElement) o).getValue();
JAXBContext context = JAXBContext.newInstance(CTOMath.class, ObjectFactory.class, org.docx4j.wml.ObjectFactory.class);
DOMResult res = new DOMResult();
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(ctoMath, res);
System.out.println(res.getNode().getNodeName());
Transformer transformer = TransformerFactory.newInstance().newTransformer(new javax.xml.transform.stream.StreamSource("/Users/trymore/Downloads/OMML2MML.XSL"));
DOMSource ds = new DOMSource(res.getNode());
StringWriter writer = new StringWriter();
StreamResult sr = new StreamResult(writer);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
//convert ooml to mathml
transformer.transform(ds,sr);
String mmlString=writer.toString();
- Code: Select all
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
There's no ObjectFactory with an @XmlElementDecl for the element {http://schemas.microsoft.com/office/word/2012/wordml}dataBinding.
this problem is related to the following location:
at protected java.util.List org.docx4j.wml.SdtPr.rPrOrAliasOrLock
at org.docx4j.wml.SdtPr
at protected org.docx4j.wml.SdtPr org.docx4j.wml.SdtBlock.sdtPr
at org.docx4j.wml.SdtBlock
at protected java.util.List org.docx4j.wml.Comments$Comment.content
at org.docx4j.wml.Comments$Comment
at protected java.util.List org.docx4j.wml.Comments.comment
at org.docx4j.wml.Comments
at public org.docx4j.wml.Comments org.docx4j.wml.ObjectFactory.createComments()
at org.docx4j.wml.ObjectFactory
at protected java.util.List org.docx4j.wml.CTRPrChange$RPr.egrPrBase
at org.docx4j.wml.CTRPrChange$RPr
at protected org.docx4j.wml.CTRPrChange$RPr org.docx4j.wml.CTRPrChange.rPr
at org.docx4j.wml.CTRPrChange
at protected org.docx4j.wml.CTRPrChange org.docx4j.wml.RPrAbstract.rPrChange
at org.docx4j.wml.RPr
at protected org.docx4j.wml.RPr org.docx4j.math.CTCtrlPr.rPr
at org.docx4j.math.CTCtrlPr
at protected org.docx4j.math.CTCtrlPr org.docx4j.math.CTFPr.ctrlPr
at org.docx4j.math.CTFPr
at protected org.docx4j.math.CTFPr org.docx4j.math.CTF.fPr
at org.docx4j.math.CTF
at public org.docx4j.math.CTF org.docx4j.math.ObjectFactory.createCTF()
at org.docx4j.math.ObjectFactory
at protected java.util.List org.docx4j.math.CTOMath.egoMathElements
at org.docx4j.math.CTOMath