[xml] resolveEntity and SAX



I feel sure this is simple but after a day of reading code and googling I'm not getting it. 

I want to implement a resolveEntity callback on a simple SAX parser in libxml2 so I can supply a DTD. I have the following

xmlSAXHandlerPtr hdlrPtr = calloc( 1, sizeof( xmlSAXHandler ) );


hdlrPtr->startDocument = &startDocument;
hdlrPtr->endDocument = &endDocument;
hdlrPtr->resolveEntity  = &resolveEntity;


int result = xmlSAXUserParseMemory( hdlrPtr, NULL, buf, size );

my resolveEntity code is never called even when fed a document which has a SYSTEM entity in the DOCTYPE. The startDocument and endDocument callbacks are called. 

<!DOCTYPE testxml SYSTEM "TestXML.dtd">
...

Is this the wrong callback? I see the xmlParserOption enum which includes DTD loading and validation but there's nothing in the simple SAX interface which seems to use that, it appears to be a level further up, I'm just trying to use xmlSAXUserParseMemory() and calls at that level. Since the handler contains a resolveEntity function I would have expected it to be called. 

What basic misunderstanding do I have here? 


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