Hi,
I am working with Xerces 2.1 and Xalan 1.4. I have written a
function,findNodes(), for evaluating XPath expressions. It takes a ptr to a
DOM_Node(the context node), the XPath exprssion in string format and a ptr
to a vector of DOM_Nodes. Basically, i create a XercesDocumentBridge in the
function, map the DOM_Node to a XalanNode using the bridge, and evaluate the
XPath expression.

The problem that i am facing is that when I call the findNodes() function a
couple of times, it works fine. But it fails the third time I call it.
However, when I remove the 2nd call to findNodes(), the 3rd call strangely
succeeds.

Can someone give me pointers as to why this is happening ?? Am i going wrong
somewhere in the function ? 

I have given the code in detail below....



THE CODE:
****************************************************************************
*************
findNodes(DOM_Node* theContextNode, string paramXPathExpr,vector<DOM_Node>
*paramVect)
{
        DOM_Document* theOwnerDoc = new DOM_Document();
        *theOwnerDoc = theContextNode->getOwnerDocument();
        XercesDocumentBridge *theXDBridge  = new
XercesDocumentBridge(*theOwnerDoc,false,false);
        //map Xerces node of type DOM_Node to Xalan node
        XalanNode* xalContextNode = theXDBridge->mapNode(*theContextNode);
        //Evaluate the XPath Expr
          char *buff = new char[500];
        memset(buff,0,500);
        paramXPathExpr.copy(buff, paramXPathExpr.length());
          //theEvaluator is a member variable of the class of which
findNodes() is a member         //function
        NodeRefList nodeList = theEvaluator->selectNodeList(theDOMSupport,
                                                            xalContextNode,
 
XalanDOMString(buff).c_str(),
 
theXDBridge->getDocumentElement());

        //Insert the nodes from the NodeList into the vector
        for(int i = 0; i < nodeList.getLength(); i++)
        {
                //Map the node to DOM_Node
                DOM_Node theNode = theXDBridge->mapNode(nodeList.item(i));
                paramVect->push_back(theNode);
        }


        delete xalContextNode;
        delete theXDBridge;
        delete theOwnerDoc;
          delete buff;  

}
****************************************************************************
**************

<<attachment: winmail.dat>>

Reply via email to