Re: [xml] Python bindings and RELAX NG error reporting

On Thu, Jul 10, 2003 at 05:48:37PM +0200, Martijn Faassen wrote:

I've been playing with RELAX NG recently; pretty nice. I then wrote 
a python script to be able to do the validation from Python, following
the relaxng example in the tests directory of the Python bindings.
I noticed that upon validation failure an error is reported directly
to stdout. In a Python program that isn't really desirable, so I wonder
whether it is possible to suppress this or if this indicates a problem?

  Hi Martijn,

You can do something like:

# Error and warnng callbacks
def callback(ctx, str):
    global log
    log.write("%s%s" % (ctx, str))
libxml2.registerErrorHandler(callback, "")

to catch all libxml2 messages.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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