Re: [gdome] Callback for Handling Error Messages



Hello John,

On Sat, 2004-08-21 at 23:19, John J. Boyer wrote:
> Is there a way to define a callback that would be passed erhor 
> messages,instead of having them printed on stderr? I am using 
> gdome_di_createDocumentFromUHI.

Gdome2 does not provide such a callback mechanism. My suggestion would
be to use libxml2 error callbacks to customize parsing behavior (by
linking gdome2 you're implicitly linking libxml2 as well). I have never
looked at libxml2's API for this: if the callbacks are stored globally
then it's easy, but if the callbacks are associated with each instance
of the libxml2 parser then there might be a problem as the parser is
hidden behind the gdome_di_createDocumentFromUHI method. In the latter,
unfortunate case, I see three workarounds (the first two of which need
an API extension):
1) expose the error callback API at the Gdome2 level as well
2) add a Gdome2 parsing method that accepts an already packaged parser
(which might have the error callbacks set by the user in advance)
3) parse the document with the pure libxml2 API + your callbacks and
then promote the xmlDoc* document you get to a Gdome2 document via the
(hidden but existent) gdome_xml_doc_mkref method (see
gdome-xml-document.c file)

Persoanlly I'm not very keen on (1) as this is a largely
non-standardized area which I'd prefer to keep as small as possible. As
bad as it may seem, I'd go for (3) or even (2) if it's possible to
initialize a parser structure in advance and pass it to the Gdome2
method (but then there would be little advantage if compared to (3),
which has the plus that it's immediately available at the cost of the
exposure of the hidden Gdome2 method).

As I have very little knowledge on this particular subject I might have
overlooked other solutions or tricks. Comments are welcome.

Cheers,
--luca




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