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



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

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:

-----
libxml2.lineNumbersDefault(1)
#
# 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

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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