Version: 2.1.5

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, or etree._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_vaildTrue if the document was valid and False 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 be True or False.
  • '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 and False otherwise.

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 or svrl: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.