Hi:
I am using Jsci package to parse mathml (Convert mathml to JSci
objects). This works fine for the mathml document that has only one
set of <apply> tags. I have explained taking two math expressions below:
For example: x^2
Its mathml form:
"<apply>
<power/>
<ci>x</ci>
<cn type='integer'>2</cn>
</apply>
</annotation-xml>
</semantics>
</math>"
and: exp(x^2)
Its mathml form:
"<apply>
<power/>
<exponentiale/>
<apply>
<power/>
<ci>x</ci>
<cn type='integer'>2</cn>
</apply>
</apply>
</annotation-xml>
</semantics>
</math>"
The x^2 expression is parsed well and good. But when it comes to
exp(x^2) expression it parses only the inner most <apply> tagged math
form. So in second form only x^2 is parsed. The exponential
information is lost.
Could someone help me in using the right functions to parse the
complete mathml form??
I have posted the code below ( Thanks to herbert for the help!!!)
Thanks in advance
Pavan
public static void main(String[] args) throws
SAXNotRecognizedException, SAXNotSupportedException {
MathMLParser parser = new MathMLParser();
try {
parser.parse("D:\\Purdue_project\\ProjectsFrom14thJuly20061.40PM\\PharmaInformat\
ics\\test.xml");
//System.out.println("This is the parser.toString() output" +
parser.toString());
//System.out.println("This is the translate.toString() output" +
parser.translateToJSciObjects());
} catch (Exception e) {
System.out.println(e.getMessage());
}
Object parseList[] = parser.translateToJSciObjects();
Object list[] = parser.translateToJSciCode();
System.out.println("This is the length of the list "+ list.length);
System.out.println("This is the length of the Parse list "+
parseList.length);
for(int i=0;i<list.length;i++){
System.out.println("This is in list " + list[i].toString());
}
for (int i = 0; i < parseList.length; i++) {
JSci.io.MathMLExpression test = (JSci.io.MathMLExpression)
parseList[i];
System.out.println("This is test.evaluate()" +test.evaluate());
System.out.println("This is test.getOperation() "
+test.getOperation());
System.out.println("This is test.getArgument()
"+test.getArgument(1).toString());
System.out.println("This is test.getClass() "+test.getClass());
System.out.println("This is test.length() "+test.length());
System.out.println("This is test.toString() "+test.toString());
System.out.println("This is hashCode " +test.hashCode());
}
}