Next / Previous / Contents / TCC Help System / NM Tech homepage

15.2. Interface to the rnc_validate module

Our module exports this interface.


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.


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 15.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.


For a RelaxValidator instance RV, this method takes as its argument an ElementTree 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.