You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Smeeta Jalan <sm...@gmail.com> on 2006/04/28 17:34:30 UTC

XercesDOMWrapperException

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<http://xml.apache.org/xalan-c/apiDocs/classXalanDOMException.html>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