Handling errors: DOMError, DOMObject, DOMLocator

Frans Englich frans.englich at telia.com
Fri Feb 25 21:38:31 GMT 2005


On Sunday 20 February 2005 20:14, Rob Buis wrote:
> Hi Frans,
>
> On Sun, Feb 20, 2005 at 06:29:56PM +0000, Frans Englich wrote:
> > Hello,
> >
> > Many XML applications needs to do error reporting with the physical file
> > as background. E.g, they reach a certain point and need to report
> > something that was wrong on a certain line.
> >
> > DOMError and DOMLocator exists, and after having read the DOM 3 core
> > spec, I still don't understand how I should use them. When I've found an
> > error, how do I create a DOMError, and how do I "pass it on" to the host
> > code(somehow the DOMImplementation since it should test it against
> > DOMErrorHandler)?
>
> Well, the configuration in the document seems to store the current
> error handler. So you can override that to get to your host code.
>
> > I'm also wondering about the DOMObject member of DOMError, which
> > currently is commented out. AFAICT, the DOMObject is supposed to be a
> > base class which data specific to the DOMError object is cast to. How is
> > this supposed to be solved? Should all classes inherit from DOMObject? :)
>
> I am not sure about that one. Seems like a void * kind of thing, or
> a generic placeholder. We'll probably find out how to represent them
> when we know why they are used/need them :)
>
> > In short: how do one do error reporting?
>
> Have a look at my commit introducing DOMErrorHandler.
> To make it possible from user code, maybe I'll implement
> DOMConfiguration soon...

Ok, then I'll use a dummy DOMErrorHandler for now. Another thing which needs 
consideration(AFAICT) is how to create DOMLocators from Nodes. E.g, many 
implementations needs to do error reporting while pointing to a certain line 
and column.

libxml2 keeps a line number member in their node struct, and KDOM's document 
builder could perhaps do the same? This would be non-DOM, since DOM doesn't 
provide a mechanism for deriving line/column number from a Node, AFAICT.

> To make it possible from user code, maybe I'll implement
> DOMConfiguration soon...

(It will be interesting to see what data type DOMConfiguration::getParameter 
will return since there's no common base class. Also, it looks like 
KDOM::Parser should not inherit/provide an DOMErrorHandler, but instead call 
the handler retrievable via DOMConfiguration, when available.)


Cheers,

		Frans




More information about the kfm-devel mailing list