Version: 1.2.0.5.dev0

stix.base Module

Classes

class stix.base.Entity

Base class for all classes in the STIX API.

find(id_)

Searches the children of a Entity implementation for an object with an id_ property that matches id_.

to_xml(include_namespaces=True, include_schemalocs=False, ns_dict=None, schemaloc_dict=None, pretty=True, auto_namespace=True, encoding='utf-8')

Serializes a Entity instance to an XML string.

The default character encoding is utf-8 and can be set via the encoding parameter. If encoding is None, a string (unicode in Python 2, str in Python 3) is returned.

Parameters:
  • auto_namespace – Automatically discover and export XML namespaces for a STIX Entity instance.
  • include_namespaces – Export namespace definitions in the output XML. Default is True.
  • include_schemalocs – Export xsi:schemaLocation attribute in the output document. This will attempt to associate namespaces declared in the STIX document with schema locations. If a namespace cannot be resolved to a schemaLocation, a Python warning will be raised. Schemalocations will only be exported if include_namespaces is also True.
  • ns_dict – Dictionary of XML definitions (namespace is key, alias is value) to include in the exported document. This must be passed in if auto_namespace is False.
  • schemaloc_dict – Dictionary of XML namespace: schema location mappings to include in the exported document. These will only be included if auto_namespace is False.
  • pretty – Pretty-print the XML.
  • encoding – The output character encoding. Default is utf-8. If encoding is set to None, a string (unicode in Python 2, str in Python 3) is returned.
Returns:

An XML string for this Entity instance. Default character encoding is utf-8.

class stix.base.EntityList(*args)

Bases: mixbox.entities.EntityList, stix.base.Entity