Version: 2.5.0
sdv.validators.stix.profile Module¶
-
class
sdv.validators.stix.profile.STIXProfileValidator(profile_fn)[source]¶ Bases:
sdv.validators.schematron.SchematronValidatorPerforms STIX Profile validation.
Parameters: profile_fn – The filename of a .xlsxSTIX Profile document.-
validate(doc)[source]¶ Validates an XML instance document against a STIX profile.
Parameters: doc – The STIX document. This can be a filename, file-like object, etree._Element, oretree._ElementTreeinstance.Returns: An instance of ProfileValidationResults.Raises: ValidationError– If there are any issues parsing doc.
-
-
class
sdv.validators.stix.profile.ProfileValidationResults(is_valid, doc=None, svrl_report=None)[source]¶ Bases:
sdv.validators.schematron.SchematronValidationResultsRepresents STIX profile validation results. This is returned from the
STIXProfileValidator.validate()method.Parameters: - is_vaild –
Trueif the document was valid andFalseotherwise. - doc – The document that was validated. This is an instance of lxml._Element.
- svrl_report – The SVRL report. This is an instance of
lxml.isoschematron.Schematron.validation_report
-
errors¶ A list of
ProfileErrorinstances representing errors found in the svrl_report.
-
as_dict()¶ 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.
- is_vaild –
-
class
sdv.validators.stix.profile.ProfileError(doc, error)[source]¶ Bases:
sdv.validators.schematron.SchematronErrorRepresents STIX profile validation error.
Parameters: - doc – The instance document which was validated and produced this error.
- error – The
svrl:failed-assertorsvrl:successful-reportetree._Elementinstance.
-
message¶ The STIX Profile validation error message.
-
as_dict()¶ 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.