[xml] False document empty errors while doing SAX2 with ParseChunk



Hi.

I set up a parser context rather straightforward

    memset(&fctx->handler, 0, sizeof(xmlSAXHandler));
    //xmlSAX2InitDefaultSAXHandler(&fctx->handler, 0);
    /*
     * Set handlers
     */
#define CALLBACK(fn,hdl) fctx->handler.fn = hdl
    CALLBACK(startDocument, xml2_bucket_create_xml_decl);
    CALLBACK(comment, xml2_bucket_create_comment);
    CALLBACK(startElementNs, xml2_bucket_create_start);
    CALLBACK(endElementNs, xml2_bucket_create_end);
    CALLBACK(ignorableWhitespace, xml2_bucket_create_white);
    CALLBACK(cdataBlock, xml2_bucket_create_cdata);
    CALLBACK(characters, xml2_bucket_create_character);
    CALLBACK(processingInstruction, xml2_bucket_create_proc_instr);
    CALLBACK(warning, xml2_sax_warning);
    CALLBACK(error, xml2_sax_error);
    // mark as SAX2
    fctx->handler.initialized = XML_SAX2_MAGIC;

    /* set up the parser */
    fctx->sz_parsed = 0;

    xmlParserCtxt *parser = xmlCreatePushParserCtxt(&fctx->handler,
                                                    fctx,NULL,0,NULL);

with fctx of type

typedef struct
{
    xmlParserCtxt parser;
....

When I then do 

    xmlParserErrors err = xmlParseChunk(&fctx->parser, buf, len, 0);

the first call succeeds and the sax events are generated.

The second call however gives me an error 4 - Document is empty. I know
from the trace log this is not true.

Any hints what is going wrong (or shall I simply continue searching for
memory corruption)?

Thanx,
Joachim





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]