RE: Gaining access to the return code of XML_Parse ()

Thank you for these suggestions. I did run into some difficulties trying to
implement them, however. Basically, you were suggesting using the XML_Parser
object as a means to evaluate the return code.

Although I do have access to this object in the XML parser callback
functions, if it encounters an error during the parse, the "normal"
callbacks are not called. For example, the startElement handler will NOT be
called if an error in the document is encountered. None of the application
callbacks will be called which does not give the application an opportunity
to call XML_GetErrorCode().

I also tried your suggestion of evaluating the XML_Parser object inside the
termination handler. Unfortunately - unless I'm doing something wrong - the
object is free'd (HTXML_free()) before the termination handler is called. (I
also tried using HT_FILTER_FIRST in HTNet_addAfter(), but HTXML_free() is
still called first).

As you can tell, I am very much a novice with libwww and I really appreciate
the suggestions. Let me know if I missed something.

Thanks,

WWZ

-----Original Message-----
From: www-lib-request@w3.org [mailto:www-lib-request@w3.org]On Behalf Of
Jeff Adams
Sent: Wednesday, January 31, 2001 11:00 AM
To: www-lib@w3.org
Subject: Re: Gaining access to the return code of XML_Parse ()


"Wayne W. Ziebarth" wrote:
>
> Unfortunately, this does not help. If I use the expat library directly and
> call XML_Parse(), I can easily evaluate if it passed or failed. However,
> when used as part of libwww, it isn't called directly by my application
and
> I can't see how to get its return value when the HTEventList_loop() exits.
>
> Thanks anyway,
>
> WWZ

Hi,
Looking at the functions available from xmlparse.h
the following might work (though I have not tried it)...

Since you are using expat in the libwww framework,
when you go to setup your handlers you have access to
XML_Parser xmlparser.
When you are setting up your handlers you can also call
XML_UseParserAsHandlerArg(XML_Parser parser).

This way you will have the XML_Parser instance you are using in all your
xml callbacks. You can then within these methods check
XML_GetErrorCode to see if an error occurred.

But an even simpler method might be to hold on to a reference
to the XML_Parser instance when your HTXMLCallback_registerNew
is called and then in your terminate_hander for the eventloop you
can check the XML_Parser for an error. You could even set the XML_Parser
instance
as the param element of the callback too, instead of using a global var,
by specifying
the XML_Parser instance when you add your terminate_handler callback
using
 HTNet_addAfter(terminate_handler, NULL, xmlParser, HT_ALL,
HT_FILTER_LAST)

Not sure if any of these suggestions help

Jeff

Received on Wednesday, 31 January 2001 15:23:22 UTC