Hi,
I am trying to build a DOMDocument from a DOMNode using getOwnerDocument.
When I want to build the XalanDocument associated to the DOMDocument, the method XercesParserLiaison ::createDocument returns
pure virtual method called

Thanks for your help
Simon

Here is the used code:
/************************************/
int foo(std::string a_st_key_name, DOMNode *paDomElement, DOMNode **paKeyElement)
{
   XALAN_USING_STD(cerr)
   XALAN_USING_STD(cout)
   XALAN_USING_STD(endl)

   int        theResult = 0;
std::string st_xpath_to_find = "descendant-or-self:" + a_st_key_name + "[position() = last()]";

       XALAN_USING_XALAN(XSLException)

       try
       {
           XALAN_USING_XERCES(XMLPlatformUtils)

           XALAN_USING_XALAN(XPathEvaluator)


           XPathEvaluator::initialize();

           {
               XALAN_USING_XERCES(LocalFileInputSource)

               XALAN_USING_XALAN(XalanDocument)
               XALAN_USING_XALAN(XalanDocumentPrefixResolver)
               XALAN_USING_XALAN(XalanDOMString)
               XALAN_USING_XALAN(XalanNode)
               XALAN_USING_XALAN(XalanDOMChar)
               XALAN_USING_XALAN(XalanSourceTreeInit)
               XALAN_USING_XALAN(XalanSourceTreeDOMSupport)
               XALAN_USING_XALAN(XalanSourceTreeParserLiaison)
               XALAN_USING_XALAN(XObjectPtr)

               XercesDOMSupport        theDOMSupport;
               XercesParserLiaison    theLiaison(theDOMSupport);
               // theLiaison.setBuildWrapperNodes(true);
               // theLiaison.setBuildMaps(true);

DOMDocument *the_dom_document = paDomElement->getOwnerDocument();
               assert(the_dom_document != 0);

XalanDocument *theDocument = theLiaison.createDocument(the_dom_document, true, true, true);
               assert(theDocument != 0);

XercesDocumentWrapper *docWrapper = theLiaison.mapDocumentToWrapper(theDocument);

               XPathEvaluator    theEvaluator;

               // OK, let's find the context node...
               XalanNode* theContextNode =
                       theEvaluator.selectSingleNode(
                           theDOMSupport,
                           theDocument,
                           (XalanDOMChar *)(st_xpath_to_find.c_str()));

               if (theContextNode == 0)
               {
cerr << "Warning -- No nodes matched the location path \""
                        << st_xpath_to_find
                        << "\"."
                        << endl
                        << "Execution cannot continue..."
                        << endl
                        << endl;
               }
               else
               {
const DOMNode *a_paKeyElement = docWrapper->mapNode(theContextNode);
                   *paKeyElement = const_cast<DOMNode*>(a_paKeyElement);
               }
           }

           XPathEvaluator::terminate();

       }
       catch(const XSLException&   theException)
       {
           cerr << "XSL exception: "
                << theException.getMessage()
                << endl;

           theResult = -1;
       }
       catch(...)
       {
           cerr << "Generic exception caught!" << endl;

           theResult = -1;
       }

   return theResult;
}

/**********************************/
gdb output:

#5  0x410d1954 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
#6  0x410d1991 in std::terminate () from /usr/lib/libstdc++.so.5
#7  0x410d1ec8 in __cxa_pure_virtual () from /usr/lib/libstdc++.so.5
#8 0x40d1567e in xalanc_1_10::XercesDocumentWrapper::XercesDocumentWrapper ()
  from /usr/local/lib/libxalan-c.so.110
#9  0x40d15964 in xalanc_1_10::XercesDocumentWrapper::create ()
  from /usr/local/lib/libxalan-c.so.110
#10 0x40d1ff2d in xalanc_1_10::XercesParserLiaison::doCreateDocument ()
  from /usr/local/lib/libxalan-c.so.110
#11 0x40d20c02 in xalanc_1_10::XercesParserLiaison::createDocument ()
  from /usr/local/lib/libxalan-c.so.110
#12 0x4028da63 in foo (this=0xbf7ff174,
[EMAIL PROTECTED], paDomElement=0x80a68a8, paKeyElement=0xbf7feff4)
   at ExportableObject.cpp:146

Reply via email to