Our module rnc_validate.py exports this interface.
RelaxException
An exception class that inherits from Python's
standard Exception class. This exception will be
raised when an XML file is found not to be valid
against the given Relax NG schema. The str() function, applied to an instance of
this exception, returns a textual description of
the validity error.
RelaxValidator(schemaPath)
This class constructor takes one argument, a path
name to a schema in either .rnc or .rng
format. Assuming that the situation meets all the
assumptions enumerated in Section 14.1, “Design of the rnc_validate module”, it returns a new RelaxValidator instance that can be used
to validate XML files against that schema.
If anything goes wrong, the constructor raises a
ValueError exception. This can
happen for several reasons, for example: failure to
read the schema; failure to write the .rng
file if translating from .rnc format; if the
.rng file is not well-formed or not a valid
Relax NG schema.
RV.validate(tree)
For a RelaxValidator instance , this
method takes as its argument an RVElementTree instance
containing an XML document. If that document is
valid against the schema, this method returns None. If there is a validation problem,
it raises RelaxException.