RE: [xml] Error handling with the XmlReader API



In .NET, that's easy, they have exceptions...

  That could probably be emulated around the existing entry points.

Yes, at the python level.

What's your opinion on this?
Would you see a callback interface 
or something like getLastError()?

   Well the C reader implementation uses a parser context. the same
code for the general case can probably be reused nearly as-is except
for the freeing part. Or a completely different approach can 
be attempted
(and exception would be fine).

Actually, I was first thinking of a way to expose an xmlreader error
handling API at the C level. Then I could add it at the python level.
Today, it's not possible, because the xmlParserCtxt is not exposed
(and even if it was, it would not be very clean to use it for that
purpose, IMHO).

How about?

typedef void (*xmlTextReaderErrorFunc)(xmlTextReaderPtr ctx, const char *msg);
int xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, xmlTextReaderErrorFunc f)

Or?

const char *xmlTextReaderGetLastError(xmlTextReaderPtr reader);
void xmlTextReaderClearLastError(xmlTextReaderPtr reader);

-sbi




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