stix.common.structured_text Module


class stix.common.structured_text.StructuredText(value=None, ordinality=None)

Bases: stix.base.Entity

Used for storing descriptive text elements.


An id for the text element, typically used for controlled structure xpath selectors.


The text value of this object.


The format of the text. For example, html5.


Returns a UTF-8 encoded string representation of the value.


Returns a unicode string representation of the value.


Converts this object into a dictionary representation.


If no properies or attributes are set other than value, this will return a string.


Convert to a GenerateDS binding object.

Subclasses can override this function.

Returns:An instance of this Entity’s _binding_class with properties set from this Entity.
class stix.common.structured_text.StructuredTextList(*args)

Bases: stix.base.TypedCollection,

A sequence type used to store StructureText objects.

Parameters:*args – A variable-length argument list which can contain single StructuredText objects or sequences of objects.

Removes the item with a given ordinality.

Parameters:key – An ordinality value.
Raises:KeyError – If the key does not match the ordinality for any object in the collection.

Returns the StructuredText object with a matching ordinality.

Parameters:key – An ordinality value.
Raises:KeyError – If key does not match the ordinality of any StructuredText object.

Returns an iterator for the collection sorted by ordinality.


Adds the StructuredText value to the collection.

If value is not a StructuredText object, an attempt will be made to convert it to one.


If value does not have an ordinality set, one will be assigned. If value has an ordinality which matches one already in the collection, value will replace the existing item.

Parameters:value – A StructuredText object.

Inserts value into the collection.

If value has an ordinality which conflicts with an existing value, the existing value (and any contiguous values) will have their ordinality values incremented by one.


Returns the “+1” of the highest ordinality in the collection.


Removes the value from the collection.


Assigns sequential ordinality values to each of the sorted StructuredText objects, starting with 1 and ending at len(self).


Returns a copy of the collection of internal StructuredText objects, sorted by their ordinality.


Returns a list of dictionary representations of the contained objects.

An attempt is made to flatten out the returned list when there is only one item in the collection. This is to support backwards compatibility with previous versions of python-stix.

  • If the list repr has more than one item, return the list.
  • If there is only one item, inspect it.
    • If the item is not a dictionary, return it.
    • If its ordinality key has a corresponding value of 1, remove it from the dictionary since it’s assumed if there is only one item.
    • After removing ordinality, if the only key left is value, just return the value of value (a string).

Returns a binding object list for the StructuredTextList.

If the list has a length of 1, and its member has an ordinality of 1, the ordinality will be unset.


Adds each item of iterable to the collection.


Any existing objects with conflicting ordinality values will be overwritten.

Parameters:iterable – An iterable collection of StructuredText objects to add to this collection.