Parsing document de MathML utilisant JScience
Question
Je tente d'analyser le document en utilisant MathML JScience mais n'a pas réussi. Ce qui suit est mon morceau de 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();
}
}
Je suis erreur d'ici, donc je ne pouvais pas faire autre chose. Voici la 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
En outre, l'un n'ont aucune idée comment utiliser MathMLApplyElementImpl, MathMLDocumentImpl ou d'autres classes de package JSci.mathml?
Il sera grand si vous pouvez fournir un exemple de code sur la façon d'analyser le document de MathML.
Toute idée sera très appréciée. Merci
La solution
Cocnerning votre bug précis, il semble que le JSci.maths.fields.Ring$Member
de classe n'existe pas, ce qui jette un ClassNotFoundException dans la méthode JSci.io.MathMLParser.translateToJSciObjects
.
Permet d'aller voir ce code source.
En MathMLParser, le plus notable de l'utilisation Ring.Member
est comme une valeur de retour. Mais il se trouve à de nombreux endroits.
Et, étant donné que Ring.Member est JSci.maths.fields
, qui semble être dans le même JAR que MathMLParser, je suppose que votre problème est beaucoup plus compliqué qu'un simple ClassNotFoundException.
Tout d'abord, pouvez-vous ouvrir le pot JScience pour faire en sorte que JSci.maths.fields.Ring$Member
n'existe?
Dans le cas contraire, utilisez-vous les chargeurs de classes multiples dans la même application? (Des choses comme OSGi)