Cores when using XercesDOMParser::getSrcOffset() ------------------------------------------------
Key: XERCESC-1364 URL: http://issues.apache.org/jira/browse/XERCESC-1364 Project: Xerces-C++ Type: Bug Components: DOM Versions: 2.6.0 Environment: Solaris 2.8, Ultra 5, gcc 3.3.2 Reporter: Bob Freitas I want to do some additional checking on the info in the XML document, so naturally I am going to need to communicate to the end-user. I was planning on using the getSrcOffset() method to get an idea of where I was parsing in the XML. Unfortunately, the getSrcOffset() just cores when I try to use it. Here is more or less what I am doing in my code. I had to cut and paste from a bunch of different objects to get it in one place. I tried to include everything pertinent: // in the header file xercesc::XercesDOMParser* parser; xercesc::DOMDocument* doc; DOMParseErrorHandler* saxErrorHandler; // home grown object typedef vector<xercesc::DOMNode*> ElementCollection; // basic flow of program, only in mine spread over multiple objects parser = new xercesc::XercesDOMParser(); saxErrorHandler = new DOMParseErrorHandler(); parser->setErrorHandler(saxErrorHandler); parser->setCalculateSrcOfs(true); ... do a bunch of my own stuff const char* fileName; // gets received as a parameter try { parser->parse( fileName ); } catch (const xercesc::XMLException& e) { ... do a whole bunch of catches and stuff here } doc = parser->getDocument(); xercesc::DOMElement* root = doc->getDocumentElement(); ElementCollection eleColl; if ( !getChildren(doc, root, &eleColl) ) { return DOM_TREE_NO_READ; // defined in a separate enum } ElementCollection::iterator nodeIter; ElementCollection::iterator nodeIterEnd = eleColl.end(); for(nodeIter = eleColl.begin(); nodeIter != nodeIterEnd; ++nodeIter) { xercesc::DOMNode* node = *nodeIter; xercesc::DOMElement* ele = (xercesc::DOMElement*)node; const XMLCh* nodeName = ele->getNodeName(); ... look for my XML tags of interest and process them unsigned int offset = parser->getSrcOffset(); // cores on the above statement, see below for gdb trace } bool getChildren(xercesc::DOMDocument* doc, xercesc::DOMElement* parent, ElementCollection* eleColl) { if ( doc == NULL ) { Log(ERROR, ("Unable to read DOM tree, doc is empty"); return false; } if ( parent == NULL ) { Log(ERROR, (char*)"Unable to read DOM tree, parent element is empty"); return false; } assert( eleColl != NULL ); xercesc::DOMTreeWalker* walker = doc->createTreeWalker(parent, xercesc::DOMNodeFilter::SHOW_ELEMENT, NULL, true); if ( walker == NULL ) { Log(ERROR, (char*)"Unable to read DOM tree, error creating tree walker"); return false; } xercesc::DOMNode* node; if ( ( node=walker->firstChild() ) != NULL ) { while ( node != NULL ) { eleColl->push_back(node); node = walker->nextSibling(); } } if ( walker != NULL ) { walker->release(); } return true; } ------------------------------------ gdb trace after core: (gdb) bt 10 #0 xercesc_2_6::XMLString::replicate(char const*, xercesc_2_6::MemoryManager*) (toRep=0xfef44320 "XMLReader.cpp", manager=0x82100008) at XMLString.cpp:511 #1 0xfee0dabc in xercesc_2_6::XMLException::XMLException(char const*, unsigned, xercesc_2_6::MemoryManager*) (this=0x6f8d0, srcFile=0xfef44320 "XMLReader.cpp", srcLine=400, memoryManager=0x82100008) at XMLException.cpp:146 #2 0xfee14288 in xercesc_2_6::XMLReader::getSrcOffset() const (this=0x6f8d0) at /tmp/xerces-c-src_2_6_0/include/xercesc/util/RuntimeException.hpp:30 Current language: auto; currently c++ (gdb) quit -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]