使用 JScience 解析 mathml 文档

发布于 2024-09-08 23:09:56 字数 3209 浏览 5 评论 0原文

我试图使用 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 文档的代码示例,那就太好了。

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

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();
}
}

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

Also, does any one have any idea how to use MathMLApplyElementImpl, MathMLDocumentImpl or any other classes from JSci.mathml package?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖伴 2024-09-15 23:09:56

关于您的精确错误,似乎类 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 之类的东西)

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.

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.

First, can you open the JScience jar to ensure that JSci.maths.fields.Ring$Member does exists ?

If not the case, do you use multiple class loaders in the same application ? (things like OSGi)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文