Version: 2.5.0
sdv.validators.stix.profile
Module¶
-
class
sdv.validators.stix.profile.
STIXProfileValidator
(profile_fn)[source]¶ Bases:
sdv.validators.schematron.SchematronValidator
Performs STIX Profile validation.
Parameters: profile_fn – The filename of a .xlsx
STIX 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._ElementTree
instance.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.SchematronValidationResults
Represents STIX profile validation results. This is returned from the
STIXProfileValidator.validate()
method.Parameters: - is_vaild –
True
if the document was valid andFalse
otherwise. - 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
ProfileError
instances representing errors found in the svrl_report.
-
as_dict
()¶ A dictionary representation of the
SchematronValidationResults
instance.- Keys:
'result'
: The validation results. Values can beTrue
orFalse
.'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
True
if the validation attempt was successful andFalse
otherwise.
- is_vaild –
-
class
sdv.validators.stix.profile.
ProfileError
(doc, error)[source]¶ Bases:
sdv.validators.schematron.SchematronError
Represents STIX profile validation error.
Parameters: - doc – The instance document which was validated and produced this error.
- error – The
svrl:failed-assert
orsvrl:successful-report
etree._Element
instance.
-
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.