Hi,
I have tried so many ways to convert a XalanNode to a DOMNode but I get
stuck at some point or the other. First I was getting error in the
constructor of XercesDocumentWrapper, so I switched to obtaining a
wrapper via XercesParserLiaison.
Now it's giving me XercesDOMWrapperException at the last line in the mapNode function. The documentation says:
If the node not owned by this document, the function will throw XalanDOMException with the code WRONG_DOCUMENT_ERR.
But I have already used the createDocument function. Doesn't that suffice?
Could somebody please look into my code and point out where am I wrong?
My Code:
(dom_document_ is an instance of DOMDocument created through DOMBuilder using Xerces.)
XalanNode* const result = evaluator.selectSingleNode(
dom_support_,
xalan_document_,
XalanDOMString(xpath).c_str(),
prefix_resolver);
XercesParserLiaison xerces_parser_liaison;
XercesDocumentWrapper *document_wrapper =
xerces_parser_liaison.mapDocumentToWrapper(xerces_parser_liaison.createDocument(dom_document_,
true, true, true));
assert (document_wrapper != 0);
//Iterate through the node list
size_t nodelist_len = result.getLength();
if (nodelist_len <= 0) {
return -1;
}
else if (nodelist_len == 1) {
if(IsBadWritePtr (outnode, sizeof(outnode))) {
return -1;
}
cout<<result->getNodeName();
DOMNode *xernode = (DOMNode*)(document_wrapper->mapNode(result));
Thanks,
Smeeta