Parsing a math document using JScience

I tried to parse a math document using JScience but failed. The following is a snippet 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 an error, so I couldn’t do anything else. The following is an example of a 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, are there any ideas how to use MathMLApplyElementImpl, MathMLDocumentImpl or any other classes from the JSci.mathml package?

It would be great if you could give a code example on how to parse a mathml document.

Any idea would be highly appreciated. Thanks

0
source share
1 answer

Combining the exact error, it seems that the JSci.maths.fields.Ring$Member class does not exist, which raises the ClassNotFoundException method in the JSci.io.MathMLParser.translateToJSciObjects method.

Let's take a look at this source code. In MathMLParser, the most notable use of Ring.Member is the return value. But it can be found in many places. And since Ring.Member is in JSci.maths.fields , which seems to be in the same JAR as MathMLParser, I think your problem is much more complicated than a simple ClassNotFoundException.

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

If this is not the case, are you using multiple class loaders in one application? (things like OSGi)

+2
source

Source: https://habr.com/ru/post/1403550/


All Articles