Version: 2.5.0
sdv.validators.schematron Module¶
-
class
sdv.validators.schematron.SchematronValidator(schematron, phase=None)[source]¶ Performs schematron validation against an XML instance document.
Parameters: schematron – A Schematron document. This can be a filename, file-like object, etree._Element, oretree._ElementTreeinstance.-
validate(doc)[source]¶ Validates an XML instance document doc using Schematron rules.
Parameters: doc – An XML instance document. This can be a filename, file-like object, etree._Elementoretree._ElementTreeinstance.Returns: An instance of SchematronValidationResults.Raises: ValidationError– If there are any issues parsing doc.
-
-
class
sdv.validators.schematron.SchematronValidationResults(is_valid, doc=None, svrl_report=None)[source]¶ Bases:
sdv.validators.base.ValidationResultsUsed to hold results of a Schematron validation process.
Parameters: - is_valid – The boolean validation result.
- doc – The document which produced these validation results.
- svrl_report – The etree._ElementTree SVRL report produced during the validation run.
-
errors¶ A list of
SchematronErrorinstances representing errors found in the svrl_report.
-
is_valid¶ Returns
Trueif the validation was successful andFalseotherwise.
-
as_dict()[source]¶ A dictionary representation of the
SchematronValidationResultsinstance.- Keys:
'result': The validation results. Values can beTrueorFalse.'errors': A list of validation error dictionaries. The keys are'message'and'line'.
Returns: A dictionary representation of an instance of this class.
-
as_json()¶ Returns a JSON representation of this class instance.
-
is_valid Returns
Trueif the validation attempt was successful andFalseotherwise.
-
class
sdv.validators.schematron.SchematronError(doc, error)[source]¶ Bases:
sdv.validators.base.ValidationErrorRepresents an error found in a SVRL report.
Parameters: - doc – The instance document which was validated and produced this error.
- error – The
svrl:failed-assertorsvrl:successful-reportetree._Elementinstance.
-
message¶ The validation error message.
-
as_dict()[source]¶ Returns a dictionary representation.
- Keys:
'message': The error message'line': The line number associated with the error
-
as_json()¶ Returns a JSON representation of this class instance.
-
line¶ Returns the line number in the input document associated with this error.
This property is lazily evaluated, meaning the line number isn’t known until the first time this property is accessed. Each subsequent call will return the cached line number.