使用JScience解析mathml文档 [英] Parsing mathml document using JScience
问题描述
我试图使用JScience解析mathml文档,但未成功.以下是我的代码.
I was trying to parse mathml document using JScience but was not succeed. Following is my piece of code.
import JSci.io.*;
import JSci.mathml.*;
.
.
public class ParsingMathML(){
try {
....
//inputFile is an xml file containing mathml code
InputSource file = new InputSource(new FileReader(inputFile));
MathMLParser parser = new MathMLParser();
parser.parse(file);
Object[] parseList = parser.translateToJSciObjects();
}catch (Exception e) {
e.printStackTrace();
}
}
我从这里得到了错误,所以我无能为力了.以下是StackTrace:
I got error from here, so I could not do anything further. Following is the StackTrace:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: JSci/maths/fields/Ring$Member
at JSci.io.MathMLParser.translateToJSciObjects(Unknown Source)
at JSci.io.MathMLParser.translateToJSciObjects(Unknown Source)
at mathML.ProcessMathML.processFile(ParsingMathML.java:109)
at mathML.ProcessMathML.actionPerformed(ParsingMathML.java:72)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: JSci.maths.fields.Ring$Member
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 31 more
还有,有人知道如何使用MathMLApplyElementImpl,MathMLDocumentImpl或JSci.mathml包中的任何其他类吗?
Also, does any one have any idea how to use MathMLApplyElementImpl, MathMLDocumentImpl or any other classes from JSci.mathml package?
如果您可以提供一些有关如何解析mathml文档的代码示例,那就太好了.
It will be great if you can provide some example of code on how to parse mathml document.
任何想法都会受到高度赞赏. 谢谢
Any idea will be highly appreciated. Thanks
推荐答案
正在解决您的确切错误,看来类JSci.maths.fields.Ring$Member
不存在,它在方法JSci.io.MathMLParser.translateToJSciObjects
中引发了ClassNotFoundException.
Cocnerning your precise bug, it seems the class JSci.maths.fields.Ring$Member
does not exists, which throws a ClassNotFoundException in the method JSci.io.MathMLParser.translateToJSciObjects
.
让我们看一下此源代码.
在MathMLParser中,Ring.Member
的最显着用法是作为返回值.但是可以在很多地方找到它.
而且,由于Ring.Member位于JSci.maths.fields
中,它似乎与MathMLParser处于同一JAR中,所以我想您的问题要比简单的ClassNotFoundException复杂得多.
Lets go see this source code.
In MathMLParser, the most notable usage of Ring.Member
is as a return value. But it can be found at numerous locations.
And, since Ring.Member is in JSci.maths.fields
, which seems to be in the same JAR than MathMLParser, I guess your problem is far more complicated than a simple ClassNotFoundException.
首先,您可以打开JScience jar来确保JSci.maths.fields.Ring$Member
存在吗?
First, can you open the JScience jar to ensure that JSci.maths.fields.Ring$Member
does exists ?
如果不是这样,您是否在同一应用程序中使用多个类加载器? (诸如OSGi之类的东西)
If not the case, do you use multiple class loaders in the same application ? (things like OSGi)
这篇关于使用JScience解析mathml文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!