[xml] FW: SAXHandler is not reset



Hello,

 

Not sure if the email below reached the xml gnome org mailing list so in case it didn’t I forward it again.

 

Sorry if this is duplicate message.

 

And looking forward for the help.

 

Regards.

Alexei Snisarenko.


From: Alexei Snisarenko [mailto:alexei snisarenko gmail com]
Sent: Thursday, May 05, 2005 4:17 PM
To: 'xml gnome org'
Subject: SAXHandler is not reset

 

Hello,

 

I have faced a problem that once I assigned an explicit SAXHandler using xmlCreatePushParseCtxt() the handler is then used during all parse calls.

Even (as I guess) when it should be reset. Particularly when I call xmlParseMemory the my explicit handler is used instead of default handler.

 

The question is what should I do to reset the handler and make xmlParseMemory use the default one?

 

Here is my code:

 

void startElement( void *Ctx, const xmlChar *Name, const xmlChar **Atts ) {

  std::cerr << "XXX DEBUG is called " << __LINE__ << std::endl;

}

 

xmlSAXHandler SAXHandlerStructt = {

    NULL, //internalSubset,

    NULL, //isStandalone,

    NULL, //hasInternalSubset,

    NULL, //hasExternalSubset,

    NULL, //resolveEntity,

    NULL, //getEntity,

    NULL, //entityDecl,

    NULL, //notationDecl,

    NULL, //attributeDecl,

    NULL, //elementDecl,

    NULL, //unparsedEntityDecl,

    NULL, //setDocumentLocator,

    NULL, //startDocument,

    NULL,

    startElement,

    NULL, // endElement,

    NULL, //reference,

    NULL, // characters,

    NULL, //ignorableWhitespace,

    NULL, //processingInstruction,

    NULL, //comment,

    NULL, //warning,

    NULL, //error,

    NULL, //fatalError,

    NULL, //getParameterEntity,

    NULL //cdataBlock

};

 

xmlSAXHandlerPtr SAXHandlerr = &SAXHandlerStructt;

 

 

    xmlParserCtxtPtr ctxt;

    char sctx='s';

    char ch='<';

    ctxt = xmlCreatePushParserCtxt( SAXHandlerr, &sctx, &ch, 1, NULL );

 

    xmlFreeParserCtxt( ctxt );

 

    xmlCleanupParser();

 

    doc = xmlParseMemory(…); // From inside of this function my own startElement is called!!

 

Please help me. What do I do wrong?

Documentation states that everything should reset once xmlInitParser() is called and xmlCleanupParser() is called.

But the handler is still not reset even if I issue xmlCleanupParser call before the xmlParseMemory.

 

I’m confused.

 

Thank you in advance.

Alexei Snisarenko.



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