]]>
String sessionID = request.getRequestedSessionId();
HttpSession mySession = null;
if(sessionID != null) {
mySession = (HttpSession) request.getSession();
}
// Recalls the name of the document ?? do it in a different manner??
String DocumentName = "myDocument";
// Recalls the document
Document myDocument;
Object docObject = mySession.getAttribute( DocumentName );
if (docObject instanceof Document)
{
myDocument = (Document) docObject;
}
else
{
myDocument = null;
}
NodeList listOMA = myDocument.getElementsByTagName("*");
int len=listOMA.getLength();
//out.println("##"+len);
int i;
Node CurrentNode=null;
for ( i=0; i<len ; i++ ){
Node myNode = listOMA.item(i);
NamedNodeMap attributes = myNode.getAttributes();
if (attributes!=null) {
Node attr=attributes.getNamedItem("current");
if (attr != null ){
if(attr.getNodeValue()=="1") {
CurrentNode=myNode;
break;
}
}
}
}
if (CurrentNode==null)
out.println("Current Node is null"+i);
else
out.println("The Current Node is "+CurrentNode);
//out.println("")
//Node CurrentNodeParent = CurrentNode.getParentNode();
Node CurrentNodeParent = CurrentNode;
NodeList listChildren = CurrentNodeParent.getChildNodes();
int j, k, index1 = -1, index2=-1, ll = listChildren.getLength();
String theRule="";
Node OMSNode = null;
Node fChild1 = null, fChild2 = null;
for (j=0;j<ll;j++){
out.println("**"+j+listChildren.item(j).getNodeName());
if ( "OMS".equals(listChildren.item(j).getNodeName()) ){
OMSNode = listChildren.item(j);
index1 = j;
NamedNodeMap OMSAttr = OMSNode.getAttributes();
if (OMSAttr != null){
Node ruleAttr = OMSAttr.getNamedItem("name");
if (ruleAttr != null){
theRule = ruleAttr.getNodeValue();
}
}
}
if ( !("OMS".equals(listChildren.item(j).getNodeName())) ){
fChild1 = listChildren.item(j);
index2 = j;
//break;
}
}
for (k=0; k<ll;k++){
if ((k!=index1) && (k!=index2)){
fChild2 = listChildren.item(k);
}
}
out.println("OMSNode"+OMSNode);
out.println("The rule "+theRule);
//NodeList listChildren = CurrentNodeParent.getChildNodes();
//Node fChild1 = listChildren.item(1);
//Node fChild2 = listChildren.item(2);
OMDOMReader dom1Reader = new OMDOMReader( fChild1 );
OMObject m1Object = dom1Reader.readObject();
OMDOMReader dom2Reader = new OMDOMReader( fChild2 );
OMObject m2Object = dom2Reader.readObject();
OpenMath
Native
m1Object
OpenMath
Native
m2Object
theRule
The product rule is (g*h)'=g'*h+g*h', where
g= and h=
Can you compute the derivative of g*h now?
Error: I don't recognize the rule!