Hi everyone,
I am facing a problem with the following.
Basically i am using Xalan to use its XPath feature. In my program i am
passing a DOM_Document to the evaluate method along with an Xpathlocation.
In this method, On its first entry i assign this DOM_Docoment to a
Xalan_Document called theTargetDoc and return from the method.
On successive calls, i am supposed to use the Xpath and the DOM_Fragment i
pass and add these fragments (as Xalan_Docs) to their respective locations
in the theTargetDoc.
Now the problem:
On the first call it works fine and assigns it to theTargetDoc.
But on the second call its just aborts when i try to access the previous
theTargetDoc to add my new fragment.
THe code is attached below along with the location where the abort occurs.
Any help would be greatly appreciated.
Thanks,
Mohammed Zubair.
////////// Source COde
class XPathWrapperImpl
{
public:
void evaluate(DOM_Document docFragment, int cmdTypeInfor, char * XpathInfo)
{
XercesDOMSupport theDOMSupport;//DOMSupportDefault
XercesParserLiaison theParserLiaison(theDOMSupport);
XalanDocument* theDoc =
theParserLiaison.createDocument(docFragment);
if(theTargetDoc == NULL){
theTargetDoc = theDoc;
const XalanNodeList* xNodeList = theTargetDoc->getChildNodes();
int num = xNodeList->getLength();
return;
} // WORKS FINE ON FIRST CALL AND theTargetDoc is properly
//assigned and returned
//On SECOND CALL IT COMES OVER HERE...
// Initialize the XPath subsystem for traversal...
XPathInit theInit;
// configure the objects needed for XPath to work with the Xerces DOM
XPathEnvSupportDefault theEnvSupport;
XObjectFactoryDefault theXObjectFactory;
XPathExecutionContextDefault theExecutionContext(theEnvSupport,
theDOMSupport, theXObjectFactory);
XPathFactoryDefault theXPathFactory;
XPathProcessorImpl theXPathProcessor;
try
{
XalanElement* rootElem = 0;
XalanElement* payloadNode=0;
// IT ABORTS RIGHT OVER HERE AT THE SECOND CALL
rootElem = theTargetDoc->getDocumentElement();
XPath* const contextXPath = theXPathFactory.create();
theXPathProcessor.initXPath(*contextXPath,TranscodeFromLocalCodePage(XpathInfo),ElementPrefixResolverProxy(rootElem,
theEnvSupport, theDOMSupport),theEnvSupport);
switch(cmdTypeInfor)
{
case 0://add
break;
case 1://del
break;
case 2://rep
break;
case 3://res
break;
default://nop
cerr << "NOT A VALID COMMAND: PLEASE CHECK THE SYNTAX" << endl;
break;
}
}
catch(const XMLException&)
{
cerr << "Caught XMLExecption..." << endl;
throw;
}
}
DOM_Document getConvDOMDocfromXalanDoc()
{
XercesDOMSupport theDOMSupport;//DOMSupportDefault
XercesParserLiaison theParserLiaison(theDOMSupport);
DOM_Document domout = theParserLiaison.mapXercesDocument(theTargetDoc);
return domout;
}
void Init()
{
theTargetDoc = NULL;
}
private:
XalanDocument* theTargetDoc;
char * previousContextPath;
};
////////////////////////////////////////////////////
// The public XPathWrapper methods just delegate to our impl class
XPathWrapper::XPathWrapper() :
pImpl(new XPathWrapperImpl())
{
}
XPathWrapper::~XPathWrapper()
{
delete pImpl;
}
void XPathWrapper::evaluate(DOM_Document docFragment, int cmdTypeInfor, char
* XpathInfo)
{
pImpl->evaluate(docFragment, cmdTypeInfor, XpathInfo);
}
DOM_Document XPathWrapper::getConvDOMDocfromXalanDoc()
{
DOM_Document domDoc = pImpl->getConvDOMDocfromXalanDoc();
return domDoc;
}
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.