[libxml++] Multiple documents with one DomParser
- From: John Chronakis <linux vmpsoft com>
- To: libxmlplusplus-general lists sourceforge net
- Subject: [libxml++] Multiple documents with one DomParser
- Date: Sun, 27 Feb 2005 17:42:14 +0200
Hello,
In my project I am parsing a number of xml documents, each one validated
against a different inline dtd.
I using only one parser and I am not freeing anything between calls to
parse_memory().
My program crashes when exiting at the destructor of DomParser (see the
backtrace),
which means I am doing something wrong.
--- The backtrace of the core dump is the following
----------------------------------------------------
#0 0x40cb5af4 in mallopt () from /lib/tls/libc.so.6
#1 0x40cb4a4b in free () from /lib/tls/libc.so.6
#2 0x407e694c in xmlRegFreeRegexp () from /usr/lib/libxml2.so.2
#3 0x407a2c78 in xmlSnprintfElementContent () from /usr/lib/libxml2.so.2
#4 0x40797b40 in xmlHashFree () from /usr/lib/libxml2.so.2
#5 0x407a30c9 in xmlFreeElementTable () from /usr/lib/libxml2.so.2
#6 0x407903fe in xmlFreeDtd () from /usr/lib/libxml2.so.2
#7 0x407905d7 in xmlFreeDoc () from /usr/lib/libxml2.so.2
#8 0x40746c13 in xmlpp::Document::~Document () from
/usr/lib/libxml++-2.6.so.1
#9 0x4074bdbb in xmlpp::DomParser::release_underlying () from
/usr/lib/libxml++-2.6.so.1
#10 0x4074ae40 in xmlpp::DomParser::~DomParser () from
/usr/lib/libxml++-2.6.so.1
#11 0x080dfc81 in ~EnvLoader (this=0xbfffe5f4) at ldrScene.h:24
#12 0x08082313 in ~EnvDynSimulation (this=0xbfffdff0) at
EnvDynSimulation.cpp:24
#13 0x08103d00 in main (argc=6, argv=0xbffffb54) at eds.cpp:28
--------------------------------------------------------------------------------------------------------
Can I use one parser to parse all of them or do I need one parser per
document?
If one parser is enough, do I need to free any resources between parses?
System is: debian sarge (2.6.8-1-k7), libxml++2.6 (2.6.1-2)
Thanx
John Chronakis
PS: Here is the code I use and a few words, if they help
I want dtds hardcoded, and I couldnt find a method to force DomParser to
use dtd from a char buffer.
So, I am loading the (plain ascii) xml file into a char buffer, then
adding the dtd inline (<doctype... [dtdcontent]>)
and calling the parser like this:
...
try
{
//mp_parser: pointer to my DomParser
//docstring: the document with the inline dtd
mp_parser->set_validate();
mp_parser->set_substitute_entities();
// Parse the document
mp_parser->parse_memory(docstring);
if(*mp_parser)
{
const xmlpp::Node* pNode =
mp_parser->get_document()->get_root_node();
this->parse(pNode);
// this has a method parse that does the real parsing
// delete mp_parser->get_document() !!!Crashes!!!
}
}
...
I call this sniplet a number of times, and I do not free anything
between calls.
When I tried to delete the document, it crashed.
Everything works fine for the lifetime of my program, but when I finaly
exit from it, I get a segfault.
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]