Version: 2.1.4
sdv.validators.stix.schema Module¶
- class sdv.validators.stix.schema.STIXSchemaValidator(schema_dir=None)[source]¶
Bases: sdv.validators.base.BaseSchemaValidator
- validate(doc, version=None, schemaloc=False)[source]¶
Performs XML Schema validation against a STIX document.
When validating against the set of bundled schemas, a STIX version number must be declared for the input doc. If a user does not pass in a version parameter, an attempt will be made to collect the version from the input doc.
Note
If schemaloc is True or this class was initialized with a schema_dir, no version checking or verification will occur.
Parameters: - doc – The STIX document. This can be a filename, file-like object, etree._Element, or etree._ElementTree instance.
- version – The version of the STIX document. If None an attempt will be made to extract the version from doc.
- schemaloc – If True, the xsi:schemaLocation attribute on doc will be used to drive the validation.
Returns: An instance of XmlValidationResults.
Raises: - UnknownSTIXVersionError – If version is None and doc does not contain STIX version information.
- InvalidSTIXVersionError – If version is an invalid STIX version or doc contains an invalid STIX version number.
- ValidationError – If the class was not initialized with a schema directory and schemaloc is False.
- XMLSchemaImportError – If an error occurs while processing the schemas required for validation.
- XMLSchemaIncludeError – If an error occurs while processing xs:include directives.
- ValidationError – If there are any issues parsing doc.