gpt4 book ai didi

java - 使用 JScience 解析 mathml 文档

转载 作者:行者123 更新时间:2023-12-02 08:31:46 24 4
gpt4 key购买 nike

我尝试使用 JScience 解析 mathml 文档,但没有成功。以下是我的一段代码。

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:

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 包中的任何其他类吗?

如果您能提供一些有关如何解析 mathml 文档的代码示例,那就太好了。

任何想法都将受到高度赞赏。 谢谢

最佳答案

关于您的精确错误,似乎类 JSci.maths.fields.Ring$Member 不存在,它在方法 JSci.io.MathMLParser.translateToJSciObjects< 中抛出 ClassNotFoundException.

让我们看看这个源代码。在 MathMLParser 中,Ring.Member 最显着的用法是作为返回值。但它可以在很多地方找到。而且,由于 Ring.Member 位于 JSci.maths.fields 中,它似乎与 MathMLParser 位于同一个 JAR 中,因此我猜您的问题比简单的 ClassNotFoundException 复杂得多。

首先,您可以打开 JScience jar 来确保 JSci.maths.fields.Ring$Member 确实存在吗?

如果不是这种情况,您是否在同一个应用程序中使用多个类加载器? (比如 OSGi)

关于java - 使用 JScience 解析 mathml 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3184010/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com