#!/usr/bin/env python
# -*- coding: utf-8 -*- 

#
# Generated Wed Nov 14 12:51:28 2012 by generateDS.py version 2.7c.
#

import sys
import getopt
import re as re_

import cybox.bindings.cybox_core_1_0 as cybox_core_binding
import cybox.bindings.cybox_common_types_1_0 as cybox_common_binding
import stix.bindings.stix_indicator_1_1 as stix_indicator_binding
import stix.bindings.stix_common_0_2 as stix_common_binding
import stix.bindings.stix_ttp_0_6 as stix_ttp_binding
#import stix.bindings.stix_threat_actor_0_5_1 as stix_threat_actor_binding
import stix.bindings.stix_incident_0_3_1 as stix_incident_binding
import stix.bindings.data_marking_0_5 as data_marking_binding

etree_ = None
Verbose_import_ = False
(   XMLParser_import_none, XMLParser_import_lxml,
    XMLParser_import_elementtree
    ) = range(3)
XMLParser_import_library = None
try:
    # lxml
    from lxml import etree as etree_
    XMLParser_import_library = XMLParser_import_lxml
    if Verbose_import_:
        print("running with lxml.etree")
except ImportError:
    try:
        # cElementTree from Python 2.5+
        import xml.etree.cElementTree as etree_
        XMLParser_import_library = XMLParser_import_elementtree
        if Verbose_import_:
            print("running with cElementTree on Python 2.5+")
    except ImportError:
        try:
            # ElementTree from Python 2.5+
            import xml.etree.ElementTree as etree_
            XMLParser_import_library = XMLParser_import_elementtree
            if Verbose_import_:
                print("running with ElementTree on Python 2.5+")
        except ImportError:
            try:
                # normal cElementTree install
                import cElementTree as etree_
                XMLParser_import_library = XMLParser_import_elementtree
                if Verbose_import_:
                    print("running with cElementTree")
            except ImportError:
                try:
                    # normal ElementTree install
                    import elementtree.ElementTree as etree_
                    XMLParser_import_library = XMLParser_import_elementtree
                    if Verbose_import_:
                        print("running with ElementTree")
                except ImportError:
                    raise ImportError("Failed to import ElementTree from any known place")

def parsexml_(*args, **kwargs):
    if (XMLParser_import_library == XMLParser_import_lxml and
        'parser' not in kwargs):
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        kwargs['parser'] = etree_.ETCompatXMLParser()
    doc = etree_.parse(*args, **kwargs)
    return doc

#
# User methods
#
# Calls to the methods in these classes are generated by generateDS.py.
# You can replace these methods by re-implementing the following class
#   in a module named generatedssuper.py.

try:
    from generatedssuper import GeneratedsSuper
except ImportError, exp:

    class GeneratedsSuper(object):
        def gds_format_string(self, input_data, input_name=''):
            return input_data
        def gds_validate_string(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer(self, input_data, input_name=''):
            return '%d' % input_data
        def gds_validate_integer(self, input_data, node, input_name=''):
            return input_data
        def gds_format_integer_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_integer_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of integers')
            return input_data
        def gds_format_float(self, input_data, input_name=''):
            return '%f' % input_data
        def gds_validate_float(self, input_data, node, input_name=''):
            return input_data
        def gds_format_float_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_float_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of floats')
            return input_data
        def gds_format_double(self, input_data, input_name=''):
            return '%e' % input_data
        def gds_validate_double(self, input_data, node, input_name=''):
            return input_data
        def gds_format_double_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_double_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    fvalue = float(value)
                except (TypeError, ValueError), exp:
                    raise_parse_error(node, 'Requires sequence of doubles')
            return input_data
        def gds_format_boolean(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean(self, input_data, node, input_name=''):
            return input_data
        def gds_format_boolean_list(self, input_data, input_name=''):
            return '%s' % input_data
        def gds_validate_boolean_list(self, input_data, node, input_name=''):
            values = input_data.split()
            for value in values:
                if value not in ('true', '1', 'false', '0', ):
                    raise_parse_error(node, 'Requires sequence of booleans ("true", "1", "false", "0")')
            return input_data
        def gds_str_lower(self, instring):
            return instring.lower()
        def get_path_(self, node):
            path_list = []
            self.get_path_list_(node, path_list)
            path_list.reverse()
            path = '/'.join(path_list)
            return path
        Tag_strip_pattern_ = re_.compile(r'\{.*\}')
        def get_path_list_(self, node, path_list):
            if node is None:
                return
            tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
            if tag:
                path_list.append(tag)
            self.get_path_list_(node.getparent(), path_list)
        def get_class_obj_(self, node, default_class=None):
            class_obj1 = default_class
            if 'xsi' in node.nsmap:
                classname = node.get('{%s}type' % node.nsmap['xsi'])
                if classname is not None:
                    names = classname.split(':')
                    if len(names) == 2:
                        classname = names[1]
                    class_obj2 = globals().get(classname)
                    if class_obj2 is not None:
                        class_obj1 = class_obj2
            return class_obj1
        def gds_build_any(self, node, type_name=None):
            return None


#
# If you have installed IPython you can uncomment and use the following.
# IPython is available from http://ipython.scipy.org/.
#

## from IPython.Shell import IPShellEmbed
## args = ''
## ipshell = IPShellEmbed(args,
##     banner = 'Dropping into IPython',
##     exit_msg = 'Leaving Interpreter, back to program.')

# Then use the following line where and when you want to drop into the
# IPython shell:
#    ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')

#
# Globals
#

ExternalEncoding = 'ascii'
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')

#
# Support/utility functions.
#

def showIndent(outfile, level, pretty_print=True):
    if pretty_print:
        for idx in range(level):
            outfile.write('    ')

def quote_xml(inStr):
    if not inStr:
        return ''
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    return s1

def quote_attrib(inStr):
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s1 = s1.replace('&', '&amp;')
    s1 = s1.replace('<', '&lt;')
    s1 = s1.replace('>', '&gt;')
    if '"' in s1:
        if "'" in s1:
            s1 = '"%s"' % s1.replace('"', "&quot;")
        else:
            s1 = "'%s'" % s1
    else:
        s1 = '"%s"' % s1
    return s1

def quote_python(inStr):
    s1 = inStr
    if s1.find("'") == -1:
        if s1.find('\n') == -1:
            return "'%s'" % s1
        else:
            return "'''%s'''" % s1
    else:
        if s1.find('"') != -1:
            s1 = s1.replace('"', '\\"')
        if s1.find('\n') == -1:
            return '"%s"' % s1
        else:
            return '"""%s"""' % s1

def get_all_text_(node):
    if node.text is not None:
        text = node.text
    else:
        text = ''
    for child in node:
        if child.tail is not None:
            text += child.tail
    return text

def find_attr_value_(attr_name, node):
    attrs = node.attrib
    attr_parts = attr_name.split(':')
    value = None
    if len(attr_parts) == 1:
        value = attrs.get(attr_name)
    elif len(attr_parts) == 2:
        prefix, name = attr_parts
        namespace = node.nsmap.get(prefix)
        if namespace is not None:
            value = attrs.get('{%s}%s' % (namespace, name, ))
    return value


class GDSParseError(Exception):
    pass

def raise_parse_error(node, msg):
    if XMLParser_import_library == XMLParser_import_lxml:
        msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
    else:
        msg = '%s (element %s)' % (msg, node.tag, )
    raise GDSParseError(msg)


class MixedContainer:
    # Constants for category:
    CategoryNone = 0
    CategoryText = 1
    CategorySimple = 2
    CategoryComplex = 3
    # Constants for content_type:
    TypeNone = 0
    TypeText = 1
    TypeString = 2
    TypeInteger = 3
    TypeFloat = 4
    TypeDecimal = 5
    TypeDouble = 6
    TypeBoolean = 7
    def __init__(self, category, content_type, name, value):
        self.category = category
        self.content_type = content_type
        self.name = name
        self.value = value
    def getCategory(self):
        return self.category
    def getContenttype(self, content_type):
        return self.content_type
    def getValue(self):
        return self.value
    def getName(self):
        return self.name
    def export(self, outfile, level, name, namespace, pretty_print=True):
        if self.category == MixedContainer.CategoryText:
            # Prevent exporting empty content as empty lines.
            if self.value.strip(): 
                outfile.write(self.value)
        elif self.category == MixedContainer.CategorySimple:
            self.exportSimple(outfile, level, name)
        else:    # category == MixedContainer.CategoryComplex
            self.value.export(outfile, level, namespace, name, pretty_print)
    def exportSimple(self, outfile, level, name):
        if self.content_type == MixedContainer.TypeString:
            outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeInteger or \
                self.content_type == MixedContainer.TypeBoolean:
            outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeFloat or \
                self.content_type == MixedContainer.TypeDecimal:
            outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
        elif self.content_type == MixedContainer.TypeDouble:
            outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
    def exportLiteral(self, outfile, level, name):
        if self.category == MixedContainer.CategoryText:
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
                (self.category, self.content_type, self.name, self.value))
        elif self.category == MixedContainer.CategorySimple:
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s", "%s"),\n' % \
                (self.category, self.content_type, self.name, self.value))
        else:    # category == MixedContainer.CategoryComplex
            showIndent(outfile, level)
            outfile.write('model_.MixedContainer(%d, %d, "%s",\n' % \
                (self.category, self.content_type, self.name,))
            self.value.exportLiteral(outfile, level + 1)
            showIndent(outfile, level)
            outfile.write(')\n')


class MemberSpec_(object):
    def __init__(self, name='', data_type='', container=0):
        self.name = name
        self.data_type = data_type
        self.container = container
    def set_name(self, name): self.name = name
    def get_name(self): return self.name
    def set_data_type(self, data_type): self.data_type = data_type
    def get_data_type_chain(self): return self.data_type
    def get_data_type(self):
        if isinstance(self.data_type, list):
            if len(self.data_type) > 0:
                return self.data_type[-1]
            else:
                return 'xs:string'
        else:
            return self.data_type
    def set_container(self, container): self.container = container
    def get_container(self): return self.container

def _cast(typ, value):
    if typ is None or value is None:
        return value
    return typ(value)

#
# Data representation classes.
#

class CampaignType(GeneratedsSuper):
    """The CampaignType characterizes a single cyber threat
    Campaign.Specifies a globally unique identifier for this cyber
    threat Campaign.Specifies a globally unique identifier for a
    cyber threat Campaign specified elsewhere.Specifies the relevant
    STIX-Campaign schema version for this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, Names=None, Intent=None, RelatedTTPs=None, RelatedIncidents=None, RelatedIndicators=None, Attribution=None, AssociatedCampaigns=None, Confidence=None, Activity=None, InformationSource=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Names = Names
        self.Intent = Intent
        self.RelatedTTPs = RelatedTTPs
        self.RelatedIncidents = RelatedIncidents
        self.RelatedIndicators = RelatedIndicators
        if Attribution is None:
            self.Attribution = []
        else:
            self.Attribution = Attribution
        self.AssociatedCampaigns = AssociatedCampaigns
        self.Confidence = Confidence
        if Activity is None:
            self.Activity = []
        else:
            self.Activity = Activity
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if CampaignType.subclass:
            return CampaignType.subclass(*args_, **kwargs_)
        else:
            return CampaignType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Names(self): return self.Names
    def set_Names(self, Names): self.Names = Names
    def get_Intent(self): return self.Intent
    def set_Intent(self, Intent): self.Intent = Intent
    def get_RelatedTTPs(self): return self.RelatedTTPs
    def set_RelatedTTPs(self, RelatedTTPs): self.RelatedTTPs = RelatedTTPs
    def get_RelatedIncidents(self): return self.RelatedIncidents
    def set_RelatedIncidents(self, RelatedIncidents): self.RelatedIncidents = RelatedIncidents
    def get_RelatedIndicators(self): return self.RelatedIndicators
    def set_RelatedIndicators(self, RelatedIndicators): self.RelatedIndicators = RelatedIndicators
    def get_Attribution(self): return self.Attribution
    def set_Attribution(self, Attribution): self.Attribution = Attribution
    def add_Attribution(self, value): self.Attribution.append(value)
    def insert_Attribution(self, index, value): self.Attribution[index] = value
    def get_AssociatedCampaigns(self): return self.AssociatedCampaigns
    def set_AssociatedCampaigns(self, AssociatedCampaigns): self.AssociatedCampaigns = AssociatedCampaigns
    def get_Confidence(self): return self.Confidence
    def set_Confidence(self, Confidence): self.Confidence = Confidence
    def get_Activity(self): return self.Activity
    def set_Activity(self, Activity): self.Activity = Activity
    def add_Activity(self, value): self.Activity.append(value)
    def insert_Activity(self, index, value): self.Activity[index] = value
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='campaign:', name_='CampaignType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='CampaignType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='CampaignType'):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='CampaignType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Names is not None:
            self.Names.export(outfile, level, 'campaign:', name_='Names', pretty_print=pretty_print)
        if self.Intent is not None:
            self.Intent.export(outfile, level, 'campaign:', name_='Intent', pretty_print=pretty_print)
        if self.RelatedTTPs is not None:
            self.RelatedTTPs.export(outfile, level, 'campaign:', name_='RelatedTTPs', pretty_print=pretty_print)
        if self.RelatedIncidents is not None:
            self.RelatedIncidents.export(outfile, level, 'campaign:', name_='RelatedIncidents', pretty_print=pretty_print)
        if self.RelatedIndicators is not None:
            self.RelatedIndicators.export(outfile, level, 'campaign:', name_='RelatedIndicators', pretty_print=pretty_print)
        for Attribution_ in self.Attribution:
            Attribution_.export(outfile, level, 'campaign:', name_='Attribution', pretty_print=pretty_print)
        if self.AssociatedCampaigns is not None:
            self.AssociatedCampaigns.export(outfile, level, 'campaign:', name_='AssociatedCampaigns', pretty_print=pretty_print)
        if self.Confidence is not None:
            self.Confidence.export(outfile, level, 'campaign:', name_='Confidence', pretty_print=pretty_print)
        for Activity_ in self.get_Activity():
            Activity_.export(outfile, level, 'campaign:', name_='Activity', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'campaign:', name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Names is not None or
            self.Intent is not None or
            self.RelatedTTPs is not None or
            self.RelatedIncidents is not None or
            self.RelatedIndicators is not None or
            self.Attribution or
            self.AssociatedCampaigns is not None or
            self.Confidence is not None or
            self.Activity or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='CampaignType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.Names is not None:
            showIndent(outfile, level)
            outfile.write('Names=model_.NamesType(\n')
            self.Names.exportLiteral(outfile, level, name_='Names')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Intent is not None:
            showIndent(outfile, level)
            outfile.write('Intent=model_.stix_common_binding.IntentType(\n')
            self.Intent.exportLiteral(outfile, level, name_='Intent')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedTTPs is not None:
            showIndent(outfile, level)
            outfile.write('RelatedTTPs=model_.RelatedTTPsType(\n')
            self.RelatedTTPs.exportLiteral(outfile, level, name_='RelatedTTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedIncidents is not None:
            showIndent(outfile, level)
            outfile.write('RelatedIncidents=model_.RelatedIncidentsType(\n')
            self.RelatedIncidents.exportLiteral(outfile, level, name_='RelatedIncidents')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.RelatedIndicators is not None:
            showIndent(outfile, level)
            outfile.write('RelatedIndicators=model_.RelatedIndicatorsType(\n')
            self.RelatedIndicators.exportLiteral(outfile, level, name_='RelatedIndicators')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Attribution=[\n')
        level += 1
        for Attribution_ in self.Attribution:
            showIndent(outfile, level)
            outfile.write('model_.AttributionType(\n')
            Attribution_.exportLiteral(outfile, level, name_='AttributionType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.AssociatedCampaigns is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedCampaigns=model_.AssociatedCampaignsType(\n')
            self.AssociatedCampaigns.exportLiteral(outfile, level, name_='AssociatedCampaigns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Confidence is not None:
            showIndent(outfile, level)
            outfile.write('Confidence=model_.stix_common_binding.ConfidenceType(\n')
            self.Confidence.exportLiteral(outfile, level, name_='Confidence')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Activity=[\n')
        level += 1
        for Activity_ in self.Activity:
            showIndent(outfile, level)
            outfile.write('model_.stix_common_binding.ActivityType(\n')
            Activity_.exportLiteral(outfile, level, name_='stix_common_binding.ActivityType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Names':
            obj_ = NamesType.factory()
            obj_.build(child_)
            self.set_Names(obj_)
        elif nodeName_ == 'Intent':
            obj_ = stix_common_binding.IntentType.factory()
            obj_.build(child_)
            self.set_Intent(obj_)
        elif nodeName_ == 'RelatedTTPs':
            obj_ = RelatedTTPsType.factory()
            obj_.build(child_)
            self.set_RelatedTTPs(obj_)
        elif nodeName_ == 'RelatedIncidents':
            obj_ = RelatedIncidentsType.factory()
            obj_.build(child_)
            self.set_RelatedIncidents(obj_)
        elif nodeName_ == 'RelatedIndicators':
            obj_ = RelatedIndicatorsType.factory()
            obj_.build(child_)
            self.set_RelatedIndicators(obj_)
        elif nodeName_ == 'Attribution':
            obj_ = AttributionType.factory()
            obj_.build(child_)
            self.Attribution.append(obj_)
        elif nodeName_ == 'AssociatedCampaigns':
            obj_ = AssociatedCampaignsType.factory()
            obj_.build(child_)
            self.set_AssociatedCampaigns(obj_)
        elif nodeName_ == 'Confidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_Confidence(obj_)
        elif nodeName_ == 'Activity':
            obj_ = stix_common_binding.ActivityType.factory()
            obj_.build(child_)
            self.Activity.append(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class CampaignType

class NameType(GeneratedsSuper):
    """Specifies the context using this Name. This would typically be the
    entity that assigned this Name or organizations that recognize
    and use this Name."""
    subclass = None
    superclass = None
    def __init__(self, NamingContext=None, valueOf_=None):
        self.NamingContext = _cast(None, NamingContext)
        self.valueOf_ = valueOf_
    def factory(*args_, **kwargs_):
        if NameType.subclass:
            return NameType.subclass(*args_, **kwargs_)
        else:
            return NameType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_NamingContext(self): return self.NamingContext
    def set_NamingContext(self, NamingContext): self.NamingContext = NamingContext
    def get_valueOf_(self): return self.valueOf_
    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
    def export(self, outfile, level, namespace_='campaign:', name_='NameType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='NameType')
        if self.hasContent_():
            outfile.write('>')
            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='NameType'):
        if self.NamingContext is not None and 'NamingContext' not in already_processed:
            already_processed.append('NamingContext')
            outfile.write(' NamingContext=%s' % (self.gds_format_string(quote_attrib(self.NamingContext).encode(ExternalEncoding), input_name='NamingContext'), ))
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='NameType', fromsubclass_=False, pretty_print=True):
        pass
    def hasContent_(self):
        if (
            self.valueOf_
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='NameType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
        showIndent(outfile, level)
        outfile.write('valueOf_ = """%s""",\n' % (self.valueOf_,))
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.NamingContext is not None and 'NamingContext' not in already_processed:
            already_processed.append('NamingContext')
            showIndent(outfile, level)
            outfile.write('NamingContext = "%s",\n' % (self.NamingContext,))
    def exportLiteralChildren(self, outfile, level, name_):
        pass
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        self.valueOf_ = get_all_text_(node)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('NamingContext', node)
        if value is not None and 'NamingContext' not in already_processed:
            already_processed.append('NamingContext')
            self.NamingContext = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class NameType



class NamesType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Name=None):
        if Name is None:
            self.Name = []
        else:
            self.Name = Name
    def factory(*args_, **kwargs_):
        if NamesType.subclass:
            return NamesType.subclass(*args_, **kwargs_)
        else:
            return NamesType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Name(self): return self.Name
    def set_Name(self, Name): self.Name = Name
    def add_Name(self, value): self.Name.append(value)
    def insert_Name(self, index, value): self.Name[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='NamesType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='NamesType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='NamesType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='NamesType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Name_ in self.Name:
            Name_.export(outfile, level, namespace_, name_='Name', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Name
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='NamesType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('Name=[\n')
        level += 1
        for Name_ in self.Name:
            showIndent(outfile, level)
            outfile.write('model_.NameType(\n')
            Name_.exportLiteral(outfile, level, name_='NameType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Name':
            obj_ = NameType.factory()
            obj_.build(child_)
            self.Name.append(obj_)
# end class NamesType




class ObservedTTPType(stix_ttp_binding.TTPType):
    subclass = None
    superclass = stix_ttp_binding.TTPType
    def __init__(self, idref=None, id=None, version=None, Behavior_AttackPatterns=None, Behavior_Malware=None, Behavior_Exploits=None, Resource_Tools=None, Resource_Infrastructure=None, VictimTargeting=None, ExploitTargets=None, Intent=None, RelatedTTPs=None, KillChainPhases=None, InformationSource=None, KillChains=None, ObservedTTPConfidence=None):
        super(ObservedTTPType, self).__init__(idref, id, version, Behavior_AttackPatterns, Behavior_Malware, Behavior_Exploits, Resource_Tools, Resource_Infrastructure, VictimTargeting, ExploitTargets, Intent, RelatedTTPs, KillChainPhases, InformationSource, KillChains, )
        self.ObservedTTPConfidence = ObservedTTPConfidence
    def factory(*args_, **kwargs_):
        if ObservedTTPType.subclass:
            return ObservedTTPType.subclass(*args_, **kwargs_)
        else:
            return ObservedTTPType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ObservedTTPConfidence(self): return self.ObservedTTPConfidence
    def set_ObservedTTPConfidence(self, ObservedTTPConfidence): self.ObservedTTPConfidence = ObservedTTPConfidence
    def export(self, outfile, level, namespace_='TA:', name_='ObservedTTPType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ObservedTTPType'):
        super(ObservedTTPType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPType')
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ObservedTTPType', fromsubclass_=False, pretty_print=True):
        super(ObservedTTPType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.ObservedTTPConfidence is not None:
            self.ObservedTTPConfidence.export(outfile, level, 'TA:', name_='ObservedTTPConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ObservedTTPConfidence is not None or
            super(ObservedTTPType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ObservedTTPType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(ObservedTTPType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(ObservedTTPType, self).exportLiteralChildren(outfile, level, name_)
        if self.ObservedTTPConfidence is not None:
            showIndent(outfile, level)
            outfile.write('ObservedTTPConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.ObservedTTPConfidence.exportLiteral(outfile, level, name_='ObservedTTPConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(ObservedTTPType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ObservedTTPConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_ObservedTTPConfidence(obj_)
        super(ObservedTTPType, self).buildChildren(child_, node, nodeName_, True)
# end class ObservedTTPType

class HistoricalCampaignType(CampaignType):
    subclass = None
    superclass = CampaignType
    def __init__(self, idref=None, id=None, version=None, Names=None, Intent=None, RelatedTTPs=None, RelatedIncidents=None, RelatedIndicators=None, Attribution=None, AssociatedCampaigns=None, Confidence=None, Activity=None, InformationSource=None, HistoricalCampaignConfidence=None):
        super(HistoricalCampaignType, self).__init__(idref, id, version, Names, Intent, RelatedTTPs, RelatedIncidents, RelatedIndicators, Attribution, AssociatedCampaigns, Confidence, Activity, InformationSource, )
        self.HistoricalCampaignConfidence = HistoricalCampaignConfidence
    def factory(*args_, **kwargs_):
        if HistoricalCampaignType.subclass:
            return HistoricalCampaignType.subclass(*args_, **kwargs_)
        else:
            return HistoricalCampaignType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_HistoricalCampaignConfidence(self): return self.HistoricalCampaignConfidence
    def set_HistoricalCampaignConfidence(self, HistoricalCampaignConfidence): self.HistoricalCampaignConfidence = HistoricalCampaignConfidence
    def export(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='HistoricalCampaignType'):
        super(HistoricalCampaignType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignType')
    def exportChildren(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignType', fromsubclass_=False, pretty_print=True):
        super(HistoricalCampaignType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.HistoricalCampaignConfidence is not None:
            self.HistoricalCampaignConfidence.export(outfile, level, 'TA:', name_='HistoricalCampaignConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.HistoricalCampaignConfidence is not None or
            super(HistoricalCampaignType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='HistoricalCampaignType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(HistoricalCampaignType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(HistoricalCampaignType, self).exportLiteralChildren(outfile, level, name_)
        if self.HistoricalCampaignConfidence is not None:
            showIndent(outfile, level)
            outfile.write('HistoricalCampaignConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.HistoricalCampaignConfidence.exportLiteral(outfile, level, name_='HistoricalCampaignConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(HistoricalCampaignType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'HistoricalCampaignConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_HistoricalCampaignConfidence(obj_)
        super(HistoricalCampaignType, self).buildChildren(child_, node, nodeName_, True)
# end class HistoricalCampaignType


class ObservedTTPsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ObservedTTP=None):
        if ObservedTTP is None:
            self.ObservedTTP = []
        else:
            self.ObservedTTP = ObservedTTP
    def factory(*args_, **kwargs_):
        if ObservedTTPsType.subclass:
            return ObservedTTPsType.subclass(*args_, **kwargs_)
        else:
            return ObservedTTPsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ObservedTTP(self): return self.ObservedTTP
    def set_ObservedTTP(self, ObservedTTP): self.ObservedTTP = ObservedTTP
    def add_ObservedTTP(self, value): self.ObservedTTP.append(value)
    def insert_ObservedTTP(self, index, value): self.ObservedTTP[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='ObservedTTPsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ObservedTTPsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ObservedTTPsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ObservedTTPsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for ObservedTTP_ in self.ObservedTTP:
            ObservedTTP_.export(outfile, level, namespace_, name_='ObservedTTP', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ObservedTTP
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ObservedTTPsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('ObservedTTP=[\n')
        level += 1
        for ObservedTTP_ in self.ObservedTTP:
            showIndent(outfile, level)
            outfile.write('model_.ObservedTTPType(\n')
            ObservedTTP_.exportLiteral(outfile, level, name_='ObservedTTPType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ObservedTTP':
            obj_ = ObservedTTPType.factory()
            obj_.build(child_)
            self.ObservedTTP.append(obj_)
# end class ObservedTTPsType


class HistoricalCampaignsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, HistoricalCampaign=None):
        if HistoricalCampaign is None:
            self.HistoricalCampaign = []
        else:
            self.HistoricalCampaign = HistoricalCampaign
    def factory(*args_, **kwargs_):
        if HistoricalCampaignsType.subclass:
            return HistoricalCampaignsType.subclass(*args_, **kwargs_)
        else:
            return HistoricalCampaignsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_HistoricalCampaign(self): return self.HistoricalCampaign
    def set_HistoricalCampaign(self, HistoricalCampaign): self.HistoricalCampaign = HistoricalCampaign
    def add_HistoricalCampaign(self, value): self.HistoricalCampaign.append(value)
    def insert_HistoricalCampaign(self, index, value): self.HistoricalCampaign[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='HistoricalCampaignsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='HistoricalCampaignsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='HistoricalCampaignsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for HistoricalCampaign_ in self.HistoricalCampaign:
            HistoricalCampaign_.export(outfile, level, namespace_, name_='HistoricalCampaign', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.HistoricalCampaign
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='HistoricalCampaignsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('HistoricalCampaign=[\n')
        level += 1
        for HistoricalCampaign_ in self.HistoricalCampaign:
            showIndent(outfile, level)
            outfile.write('model_.HistoricalCampaignType(\n')
            HistoricalCampaign_.exportLiteral(outfile, level, name_='HistoricalCampaignType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'HistoricalCampaign':
            obj_ = HistoricalCampaignType.factory()
            obj_.build(child_)
            self.HistoricalCampaign.append(obj_)
# end class HistoricalCampaignsType






class AssociatedActorsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, AssociatedActor=None):
        if AssociatedActor is None:
            self.AssociatedActor = []
        else:
            self.AssociatedActor = AssociatedActor
    def factory(*args_, **kwargs_):
        if AssociatedActorsType.subclass:
            return AssociatedActorsType.subclass(*args_, **kwargs_)
        else:
            return AssociatedActorsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedActor(self): return self.AssociatedActor
    def set_AssociatedActor(self, AssociatedActor): self.AssociatedActor = AssociatedActor
    def add_AssociatedActor(self, value): self.AssociatedActor.append(value)
    def insert_AssociatedActor(self, index, value): self.AssociatedActor[index] = value
    def export(self, outfile, level, namespace_='TA:', name_='AssociatedActorsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='AssociatedActorsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TA:', name_='AssociatedActorsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for AssociatedActor_ in self.AssociatedActor:
            AssociatedActor_.export(outfile, level, namespace_, name_='AssociatedActor', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedActor
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedActorsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('AssociatedActor=[\n')
        level += 1
        for AssociatedActor_ in self.AssociatedActor:
            showIndent(outfile, level)
            outfile.write('model_.AssociatedActorType(\n')
            AssociatedActor_.exportLiteral(outfile, level, name_='AssociatedActorType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedActor':
            obj_ = AssociatedActorType.factory()
            obj_.build(child_)
            self.AssociatedActor.append(obj_)
# end class AssociatedActorsType



class ThreatActorType(GeneratedsSuper):
    """Specifies a globally unique identifier for this ThreatActor.
    Specifies a globally unique identifier of a ThreatActor
    specified elsewhere.Specifies the relevant STIX-ThreatActor
    schema version for this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Identity = Identity
        if Intent is None:
            self.Intent = []
        else:
            self.Intent = Intent
        self.ObservedTTPs = ObservedTTPs
        self.HistoricalCampaigns = HistoricalCampaigns
        self.AssociatedActors = AssociatedActors
        self.Handling = Handling
        self.Confidence = Confidence
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if ThreatActorType.subclass:
            return ThreatActorType.subclass(*args_, **kwargs_)
        else:
            return ThreatActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Identity(self): return self.Identity
    def set_Identity(self, Identity): self.Identity = Identity
    def get_Intent(self): return self.Intent
    def set_Intent(self, Intent): self.Intent = Intent
    def add_Intent(self, value): self.Intent.append(value)
    def insert_Intent(self, index, value): self.Intent[index] = value
    def get_ObservedTTPs(self): return self.ObservedTTPs
    def set_ObservedTTPs(self, ObservedTTPs): self.ObservedTTPs = ObservedTTPs
    def get_HistoricalCampaigns(self): return self.HistoricalCampaigns
    def set_HistoricalCampaigns(self, HistoricalCampaigns): self.HistoricalCampaigns = HistoricalCampaigns
    def get_AssociatedActors(self): return self.AssociatedActors
    def set_AssociatedActors(self, AssociatedActors): self.AssociatedActors = AssociatedActors
    def get_Handling(self): return self.Handling
    def set_Handling(self, Handling): self.Handling = Handling
    def get_Confidence(self): return self.Confidence
    def set_Confidence(self, Confidence): self.Confidence = Confidence
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='TA:', name_='ThreatActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ThreatActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='ThreatActorType'):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
    def exportChildren(self, outfile, level, namespace_='TA:', name_='ThreatActorType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Identity is not None:
            self.Identity.export(outfile, level, 'TA:', name_='Identity', pretty_print=pretty_print)
        for Intent_ in self.Intent:
            Intent_.export(outfile, level, 'TA:', name_='Intent', pretty_print=pretty_print)
        if self.ObservedTTPs is not None:
            self.ObservedTTPs.export(outfile, level, 'TA:', name_='ObservedTTPs', pretty_print=pretty_print)
        if self.HistoricalCampaigns is not None:
            self.HistoricalCampaigns.export(outfile, level, 'TA:', name_='HistoricalCampaigns', pretty_print=pretty_print)
        if self.AssociatedActors is not None:
            self.AssociatedActors.export(outfile, level, 'TA:', name_='AssociatedActors', pretty_print=pretty_print)
        if self.Handling is not None:
            self.Handling.export(outfile, level, 'TA:', name_='Handling', pretty_print=pretty_print)
        if self.Confidence is not None:
            self.Confidence.export(outfile, level, 'TA:', name_='Confidence', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'TA:', name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Identity is not None or
            self.Intent or
            self.ObservedTTPs is not None or
            self.HistoricalCampaigns is not None or
            self.AssociatedActors is not None or
            self.Handling is not None or
            self.Confidence is not None or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ThreatActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.Identity is not None:
            showIndent(outfile, level)
            outfile.write('Identity=model_.stix_common_binding.IdentityType(\n')
            self.Identity.exportLiteral(outfile, level, name_='Identity')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('Intent=[\n')
        level += 1
        for Intent_ in self.Intent:
            showIndent(outfile, level)
            outfile.write('model_.stix_common_binding.IntentType(\n')
            Intent_.exportLiteral(outfile, level, name_='stix_common_binding.IntentType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.ObservedTTPs is not None:
            showIndent(outfile, level)
            outfile.write('ObservedTTPs=model_.ObservedTTPsType(\n')
            self.ObservedTTPs.exportLiteral(outfile, level, name_='ObservedTTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.HistoricalCampaigns is not None:
            showIndent(outfile, level)
            outfile.write('HistoricalCampaigns=model_.HistoricalCampaignsType(\n')
            self.HistoricalCampaigns.exportLiteral(outfile, level, name_='HistoricalCampaigns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.AssociatedActors is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedActors=model_.AssociatedActorsType(\n')
            self.AssociatedActors.exportLiteral(outfile, level, name_='AssociatedActors')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Handling is not None:
            showIndent(outfile, level)
            outfile.write('Handling=model_.data_marking_binding.MarkingType(\n')
            self.Handling.exportLiteral(outfile, level, name_='Handling')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Confidence is not None:
            showIndent(outfile, level)
            outfile.write('Confidence=model_.stix_common_binding.ConfidenceType(\n')
            self.Confidence.exportLiteral(outfile, level, name_='Confidence')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Identity':
            obj_ = stix_common_binding.IdentityType.factory()
            obj_.build(child_)
            self.set_Identity(obj_)
        elif nodeName_ == 'Intent':
            obj_ = stix_common_binding.IntentType.factory()
            obj_.build(child_)
            self.Intent.append(obj_)
        elif nodeName_ == 'ObservedTTPs':
            obj_ = ObservedTTPsType.factory()
            obj_.build(child_)
            self.set_ObservedTTPs(obj_)
        elif nodeName_ == 'HistoricalCampaigns':
            obj_ = HistoricalCampaignsType.factory()
            obj_.build(child_)
            self.set_HistoricalCampaigns(obj_)
        elif nodeName_ == 'AssociatedActors':
            obj_ = AssociatedActorsType.factory()
            obj_.build(child_)
            self.set_AssociatedActors(obj_)
        elif nodeName_ == 'Handling':
            obj_ = data_marking_binding.MarkingType.factory()
            obj_.build(child_)
            self.set_Handling(obj_)
        elif nodeName_ == 'Confidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_Confidence(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class ThreatActorType

class AssociatedActorType(ThreatActorType):
    """Specifies the type of association between the two ThreatActors."""
    subclass = None
    superclass = ThreatActorType
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None, associationType=None, AssociatedActorConfidence=None):
        super(AssociatedActorType, self).__init__(idref, id, version, Identity, Intent, ObservedTTPs, HistoricalCampaigns, AssociatedActors, Handling, Confidence, InformationSource, )
        self.associationType = _cast(None, associationType)
        self.AssociatedActorConfidence = AssociatedActorConfidence
    def factory(*args_, **kwargs_):
        if AssociatedActorType.subclass:
            return AssociatedActorType.subclass(*args_, **kwargs_)
        else:
            return AssociatedActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedActorConfidence(self): return self.AssociatedActorConfidence
    def set_AssociatedActorConfidence(self, AssociatedActorConfidence): self.AssociatedActorConfidence = AssociatedActorConfidence
    def get_associationType(self): return self.associationType
    def set_associationType(self, associationType): self.associationType = associationType
    def export(self, outfile, level, namespace_='TA:', name_='AssociatedActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='TA:', name_='AssociatedActorType'):
        super(AssociatedActorType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedActorType')
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            outfile.write(' associationType=%s' % (self.gds_format_string(quote_attrib(self.associationType).encode(ExternalEncoding), input_name='associationType'), ))
    def exportChildren(self, outfile, level, namespace_='TA:', name_='AssociatedActorType', fromsubclass_=False, pretty_print=True):
        super(AssociatedActorType, self).exportChildren(outfile, level, 'TA:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.AssociatedActorConfidence is not None:
            self.AssociatedActorConfidence.export(outfile, level, 'TA:', name_='AssociatedActorConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedActorConfidence is not None or
            super(AssociatedActorType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            showIndent(outfile, level)
            outfile.write('associationType = "%s",\n' % (self.associationType,))
        super(AssociatedActorType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(AssociatedActorType, self).exportLiteralChildren(outfile, level, name_)
        if self.AssociatedActorConfidence is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedActorConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.AssociatedActorConfidence.exportLiteral(outfile, level, name_='AssociatedActorConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('associationType', node)
        if value is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            self.associationType = value
        super(AssociatedActorType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedActorConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_AssociatedActorConfidence(obj_)
        super(AssociatedActorType, self).buildChildren(child_, node, nodeName_, True)
# end class AssociatedActorType


class AttributionType(GeneratedsSuper):
    """AttributionType specifies suspected Threat Actors attributed to a
    given Campaign."""
    subclass = None
    superclass = None
    def __init__(self, ThreatActor=None, Confidence=None, InformationSource=None):
        if ThreatActor is None:
            self.ThreatActor = []
        else:
            self.ThreatActor = ThreatActor
        self.Confidence = Confidence
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if AttributionType.subclass:
            return AttributionType.subclass(*args_, **kwargs_)
        else:
            return AttributionType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ThreatActor(self): return self.ThreatActor
    def set_ThreatActor(self, ThreatActor): self.ThreatActor = ThreatActor
    def add_ThreatActor(self, value): self.ThreatActor.append(value)
    def insert_ThreatActor(self, index, value): self.ThreatActor[index] = value
    def get_Confidence(self): return self.Confidence
    def set_Confidence(self, Confidence): self.Confidence = Confidence
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def export(self, outfile, level, namespace_='campaign:', name_='AttributionType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AttributionType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AttributionType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AttributionType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for ThreatActor_ in self.ThreatActor:
            ThreatActor_.export(outfile, level, 'campaign:', name_='ThreatActor', pretty_print=pretty_print)
        if self.Confidence is not None:
            self.Confidence.export(outfile, level, 'campaign:', name_='Confidence', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'campaign:', name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ThreatActor or
            self.Confidence is not None or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AttributionType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('ThreatActor=[\n')
        level += 1
        for ThreatActor_ in self.ThreatActor:
            showIndent(outfile, level)
            outfile.write('model_.AttributedThreatActorType(\n')
            ThreatActor_.exportLiteral(outfile, level, name_='AttributedThreatActorType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.Confidence is not None:
            showIndent(outfile, level)
            outfile.write('Confidence=model_.stix_common_binding.ConfidenceType(\n')
            self.Confidence.exportLiteral(outfile, level, name_='Confidence')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.stix_common_binding.InformationSourceType(\n')
            self.InformationSource.exportLiteral(outfile, level, name_='InformationSource')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ThreatActor':
            obj_ = AttributedThreatActorType.factory()
            obj_.build(child_)
            self.ThreatActor.append(obj_)
        elif nodeName_ == 'Confidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_Confidence(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class AttributionType

class AssociatedCampaignType(CampaignType):
    """The AssociatedCampaignType specifies a single other cyber threat
    Campaign asserted to be associated with this cyber threat
    Campaign.Specifies the type of association between the two
    Campaigns."""
    subclass = None
    superclass = CampaignType
    def __init__(self, idref=None, id=None, version=None, Names=None, Intent=None, RelatedTTPs=None, RelatedIncidents=None, RelatedIndicators=None, Attribution=None, AssociatedCampaigns=None, Confidence=None, Activity=None, InformationSource=None, associationType=None, AssociatedCampaignConfidence=None):
        super(AssociatedCampaignType, self).__init__(idref, id, version, Names, Intent, RelatedTTPs, RelatedIncidents, RelatedIndicators, Attribution, AssociatedCampaigns, Confidence, Activity, InformationSource, )
        self.associationType = _cast(None, associationType)
        self.AssociatedCampaignConfidence = AssociatedCampaignConfidence
    def factory(*args_, **kwargs_):
        if AssociatedCampaignType.subclass:
            return AssociatedCampaignType.subclass(*args_, **kwargs_)
        else:
            return AssociatedCampaignType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedCampaignConfidence(self): return self.AssociatedCampaignConfidence
    def set_AssociatedCampaignConfidence(self, AssociatedCampaignConfidence): self.AssociatedCampaignConfidence = AssociatedCampaignConfidence
    def get_associationType(self): return self.associationType
    def set_associationType(self, associationType): self.associationType = associationType
    def export(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedCampaignType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AssociatedCampaignType'):
        super(AssociatedCampaignType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedCampaignType')
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            outfile.write(' associationType=%s' % (self.gds_format_string(quote_attrib(self.associationType).encode(ExternalEncoding), input_name='associationType'), ))
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignType', fromsubclass_=False, pretty_print=True):
        super(AssociatedCampaignType, self).exportChildren(outfile, level, 'campaign:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.AssociatedCampaignConfidence is not None:
            self.AssociatedCampaignConfidence.export(outfile, level, 'campaign:', name_='AssociatedCampaignConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedCampaignConfidence is not None or
            super(AssociatedCampaignType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedCampaignType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.associationType is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            showIndent(outfile, level)
            outfile.write('associationType = "%s",\n' % (self.associationType,))
        super(AssociatedCampaignType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(AssociatedCampaignType, self).exportLiteralChildren(outfile, level, name_)
        if self.AssociatedCampaignConfidence is not None:
            showIndent(outfile, level)
            outfile.write('AssociatedCampaignConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.AssociatedCampaignConfidence.exportLiteral(outfile, level, name_='AssociatedCampaignConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('associationType', node)
        if value is not None and 'associationType' not in already_processed:
            already_processed.append('associationType')
            self.associationType = value
        super(AssociatedCampaignType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedCampaignConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_AssociatedCampaignConfidence(obj_)
        super(AssociatedCampaignType, self).buildChildren(child_, node, nodeName_, True)
# end class AssociatedCampaignType





class RelatedTTPType(stix_ttp_binding.TTPType):
    """The stix_ttp_binding.RelatedTTPType specifies a single TTP asserted to berelated to
    this cyber threat TTP."""
    subclass = None
    superclass = stix_ttp_binding.TTPType
    def __init__(self, idref=None, id=None, version=None, Behavior_AttackPatterns=None, Behavior_Malware=None, Behavior_Exploits=None, Resource_Tools=None, Resource_Infrastructure=None, VictimTargeting=None, ExploitTargets=None, Intent=None, RelatedTTPs=None, KillChainPhases=None, InformationSource=None, KillChains=None, RelatedTTPConfidence=None):
        super(RelatedTTPType, self).__init__(idref, id, version, Behavior_AttackPatterns, Behavior_Malware, Behavior_Exploits, Resource_Tools, Resource_Infrastructure, VictimTargeting, ExploitTargets, Intent, RelatedTTPs, KillChainPhases, InformationSource, KillChains, )
        self.RelatedTTPConfidence = RelatedTTPConfidence
    def factory(*args_, **kwargs_):
        if RelatedTTPType.subclass:
            return RelatedTTPType.subclass(*args_, **kwargs_)
        else:
            return RelatedTTPType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_RelatedTTPConfidence(self): return self.RelatedTTPConfidence
    def set_RelatedTTPConfidence(self, RelatedTTPConfidence): self.RelatedTTPConfidence = RelatedTTPConfidence
    def export(self, outfile, level, namespace_='campaign:', name_='RelatedTTPType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedTTPType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='RelatedTTPType'):
        super(RelatedTTPType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedTTPType')
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='RelatedTTPType', fromsubclass_=False, pretty_print=True):
        super(RelatedTTPType, self).exportChildren(outfile, level, 'campaign:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.RelatedTTPConfidence is not None:
            self.RelatedTTPConfidence.export(outfile, level, 'campaign:', name_='RelatedTTPConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.RelatedTTPConfidence is not None or
            super(RelatedTTPType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='RelatedTTPType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(RelatedTTPType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(RelatedTTPType, self).exportLiteralChildren(outfile, level, name_)
        if self.RelatedTTPConfidence is not None:
            showIndent(outfile, level)
            outfile.write('RelatedTTPConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.RelatedTTPConfidence.exportLiteral(outfile, level, name_='RelatedTTPConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(RelatedTTPType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'RelatedTTPConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_RelatedTTPConfidence(obj_)
        super(RelatedTTPType, self).buildChildren(child_, node, nodeName_, True)
# end class RelatedTTPType



class RelatedTTPsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, RelatedTTP=None):
        if RelatedTTP is None:
            self.RelatedTTP = []
        else:
            self.RelatedTTP = RelatedTTP
    def factory(*args_, **kwargs_):
        if RelatedTTPsType.subclass:
            return RelatedTTPsType.subclass(*args_, **kwargs_)
        else:
            return RelatedTTPsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_RelatedTTP(self): return self.RelatedTTP
    def set_RelatedTTP(self, RelatedTTP): self.RelatedTTP = RelatedTTP
    def add_RelatedTTP(self, value): self.RelatedTTP.append(value)
    def insert_RelatedTTP(self, index, value): self.RelatedTTP[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='RelatedTTPsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedTTPsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='RelatedTTPsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='RelatedTTPsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for RelatedTTP_ in self.RelatedTTP:
            RelatedTTP_.export(outfile, level, namespace_, name_='RelatedTTP', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.RelatedTTP
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='RelatedTTPsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('RelatedTTP=[\n')
        level += 1
        for RelatedTTP_ in self.RelatedTTP:
            showIndent(outfile, level)
            outfile.write('model_.RelatedTTPType(\n')
            RelatedTTP_.exportLiteral(outfile, level, name_='RelatedTTPType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'RelatedTTP':
            obj_ = RelatedTTPType.factory()
            obj_.build(child_)
            self.RelatedTTP.append(obj_)
# end class RelatedTTPsType


class RelatedIndicatorType(stix_indicator_binding.IndicatorType):
    """Specifies a locally-defined type of relationship (predicate) being
    defined between the subject and the object of the relationship.
    Specifies an externally-defined type of relationship (predicate)
    being defined between the subject and the object of the
    relationship. The value is a QName that should reference a term
    in a controlled vocabulary which is understood by both the
    producing and consuming parties.Indicates how multiple
    IndicatorRef elements should be interpreted in this
    relationship. If "inclusive" is specified, then the relationship
    being defined is between the subject and the collection of
    objects indicated by the IndicatorRef elements (i.e. the
    relationship is not necessarily relevant for any one particular
    object being referenced, but for the aggregated collection of
    objects referenced). If "exclusive" is specified, then the
    relationship being defined is between the specific subject
    Indicator and each object individually (i.e. this is the same as
    specifying multiple relationship elements, each with the same
    @type).A placeholder so that content creators can add attributes
    as desired."""
    subclass = None
    superclass = stix_indicator_binding.IndicatorType
    def __init__(self, id=None, idref=None, version=None, RelatedIndicatorConfidence=None):
        super(RelatedIndicatorType, self).__init__()
        self.id = _cast(None, id)
        self.idref= _cast(None, idref)
        self.version = _cast(None, version)
        self.RelatedIndicatorConfidence = RelatedIndicatorConfidence

    def factory(*args_, **kwargs_):
        if RelatedIndicatorType.subclass:
            return RelatedIndicatorType.subclass(*args_, **kwargs_)
        else:
            return RelatedIndicatorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_RelatedIndicatorConfidence(self): return self.RelatedIndicatorConfidence
    def set_RelatedIndicatorConfidence(self, RelatedIndicatorConfidence): self.RelatedIndicatorConfidence = RelatedIndicatorConfidence
    def get_id(self): return self.id
    def set_id(self, id): self.id = id
    def get_idref(self): return self.idref
    def set_idref(self, idref): self.idref = idref
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def export(self, outfile, level, namespace_='campaign:', name_='RelatedIndicatorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedIndicatorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='RelatedIndicatorType'):
        super(RelatedIndicatorType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedIndicatorType')
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            outfile.write(' id=%s' % (quote_attrib(self.id), ))
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            outfile.write(' idref=%s' % (quote_attrib(self.idref), ))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (quote_attrib(self.version), ))
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='RelatedIndicatorType', fromsubclass_=False, pretty_print=True):
        super(RelatedIndicatorType, self).exportChildren(outfile, level, 'campaign:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.RelatedIndicatorConfidence is not None:
            self.RelatedIndicatorConfidence.export(outfile, level, 'campaign:', name_='RelatedIndicatorConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.RelatedIndicatorConfidence is not None or
            super(RelatedIndicatorType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='RelatedIndicatorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        if self.id is not None and 'id' not in already_processed:
            already_processed.append('id')
            showIndent(outfile, level)
            outfile.write('id = %s,\n' % (self.id,))
        if self.idref is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            showIndent(outfile, level)
            outfile.write('idref = %s,\n' % (self.idref,))
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = %s,\n' % (self.version,))
        for name, value in self.anyAttributes_.items():
            showIndent(outfile, level)
            outfile.write('%s = "%s",\n' % (name, value,))
        super(RelatedIndicatorType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(RelatedIndicatorType, self).exportLiteralChildren(outfile, level, name_)
        if self.RelatedIndicatorConfidence is not None:
            showIndent(outfile, level)
            outfile.write('RelatedIndicatorConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.RelatedIndicatorConfidence.exportLiteral(outfile, level, name_='RelatedIndicatorConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('id', node)
        if value is not None and 'id' not in already_processed:
            already_processed.append('id')
            self.id = value
        value = find_attr_value_('idref', node)
        if value is not None and 'idref' not in already_processed:
            already_processed.append('idref')
            self.idref = value
        value = find_attr_value_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
            
        super(RelatedIndicatorType, self).buildAttributes(node, attrs, already_processed)
        
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'RelatedIndicatorConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_RelatedIndicatorConfidence(obj_)
        super(RelatedIndicatorType, self).buildChildren(child_, node, nodeName_, True)
# end class RelatedIndicatorType


class RelatedIncidentsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, RelatedIncident=None):
        if RelatedIncident is None:
            self.RelatedIncident = []
        else:
            self.RelatedIncident = RelatedIncident
    def factory(*args_, **kwargs_):
        if RelatedIncidentsType.subclass:
            return RelatedIncidentsType.subclass(*args_, **kwargs_)
        else:
            return RelatedIncidentsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_RelatedIncident(self): return self.RelatedIncident
    def set_RelatedIncident(self, RelatedIncident): self.RelatedIncident = RelatedIncident
    def add_RelatedIncident(self, value): self.RelatedIncident.append(value)
    def insert_RelatedIncident(self, index, value): self.RelatedIncident[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='RelatedIncidentsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedIncidentsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='RelatedIncidentsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='RelatedIncidentsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for RelatedIncident_ in self.RelatedIncident:
            RelatedIncident_.export(outfile, level, namespace_, name_='RelatedIncident', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.RelatedIncident
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='RelatedIncidentsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('RelatedIncident=[\n')
        level += 1
        for RelatedIncident_ in self.RelatedIncident:
            showIndent(outfile, level)
            outfile.write('model_.RelatedIncidentType(\n')
            RelatedIncident_.exportLiteral(outfile, level, name_='RelatedIncidentType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'RelatedIncident':
            class_obj_ = self.get_class_obj_(child_, stix_incident_binding.RelatedIncidentType)
            obj_ = class_obj_.factory()
            obj_.build(child_)
            self.RelatedIncident.append(obj_)
# end class RelatedIncidentsType


class RelatedIndicatorsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, RelatedIndicator=None):
        if RelatedIndicator is None:
            self.RelatedIndicator = []
        else:
            self.RelatedIndicator = RelatedIndicator
    def factory(*args_, **kwargs_):
        if RelatedIndicatorsType.subclass:
            return RelatedIndicatorsType.subclass(*args_, **kwargs_)
        else:
            return RelatedIndicatorsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_RelatedIndicator(self): return self.RelatedIndicator
    def set_RelatedIndicator(self, RelatedIndicator): self.RelatedIndicator = RelatedIndicator
    def add_RelatedIndicator(self, value): self.RelatedIndicator.append(value)
    def insert_RelatedIndicator(self, index, value): self.RelatedIndicator[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='RelatedIndicatorsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedIndicatorsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='RelatedIndicatorsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='RelatedIndicatorsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for RelatedIndicator_ in self.RelatedIndicator:
            RelatedIndicator_.export(outfile, level, namespace_, name_='RelatedIndicator', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.RelatedIndicator
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='RelatedIndicatorsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('RelatedIndicator=[\n')
        level += 1
        for RelatedIndicator_ in self.RelatedIndicator:
            showIndent(outfile, level)
            outfile.write('model_.RelatedIndicatorType(\n')
            RelatedIndicator_.exportLiteral(outfile, level, name_='RelatedIndicatorType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'RelatedIndicator':
            obj_ = RelatedIndicatorType.factory()
            obj_.build(child_)
            self.RelatedIndicator.append(obj_)
# end class RelatedIndicatorsType


class AssociatedCampaignsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, AssociatedCampaign=None):
        if AssociatedCampaign is None:
            self.AssociatedCampaign = []
        else:
            self.AssociatedCampaign = AssociatedCampaign
    def factory(*args_, **kwargs_):
        if AssociatedCampaignsType.subclass:
            return AssociatedCampaignsType.subclass(*args_, **kwargs_)
        else:
            return AssociatedCampaignsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AssociatedCampaign(self): return self.AssociatedCampaign
    def set_AssociatedCampaign(self, AssociatedCampaign): self.AssociatedCampaign = AssociatedCampaign
    def add_AssociatedCampaign(self, value): self.AssociatedCampaign.append(value)
    def insert_AssociatedCampaign(self, index, value): self.AssociatedCampaign[index] = value
    def export(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignsType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AssociatedCampaignsType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AssociatedCampaignsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AssociatedCampaignsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for AssociatedCampaign_ in self.AssociatedCampaign:
            AssociatedCampaign_.export(outfile, level, namespace_, name_='AssociatedCampaign', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AssociatedCampaign
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AssociatedCampaignsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        showIndent(outfile, level)
        outfile.write('AssociatedCampaign=[\n')
        level += 1
        for AssociatedCampaign_ in self.AssociatedCampaign:
            showIndent(outfile, level)
            outfile.write('model_.AssociatedCampaignType(\n')
            AssociatedCampaign_.exportLiteral(outfile, level, name_='AssociatedCampaignType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AssociatedCampaign':
            obj_ = AssociatedCampaignType.factory()
            obj_.build(child_)
            self.AssociatedCampaign.append(obj_)
# end class AssociatedCampaignsType



class AttributedThreatActorType(ThreatActorType):
    """The AttributedThreatActorType specifies a Threat Actor asserted to
    be attributed for a Campaign."""
    subclass = None
    superclass = ThreatActorType
    def __init__(self, idref=None, id=None, version=None, Identity=None, Intent=None, ObservedTTPs=None, HistoricalCampaigns=None, AssociatedActors=None, Handling=None, Confidence=None, InformationSource=None, AttributedThreatActorConfidence=None):
        super(AttributedThreatActorType, self).__init__(idref, id, version, Identity, Intent, ObservedTTPs, HistoricalCampaigns, AssociatedActors, Handling, Confidence, InformationSource, )
        self.AttributedThreatActorConfidence = AttributedThreatActorConfidence
    def factory(*args_, **kwargs_):
        if AttributedThreatActorType.subclass:
            return AttributedThreatActorType.subclass(*args_, **kwargs_)
        else:
            return AttributedThreatActorType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AttributedThreatActorConfidence(self): return self.AttributedThreatActorConfidence
    def set_AttributedThreatActorConfidence(self, AttributedThreatActorConfidence): self.AttributedThreatActorConfidence = AttributedThreatActorConfidence
    def export(self, outfile, level, namespace_='campaign:', name_='AttributedThreatActorType', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='AttributedThreatActorType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            showIndent(outfile, level, pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='campaign:', name_='AttributedThreatActorType'):
        super(AttributedThreatActorType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='AttributedThreatActorType')
    def exportChildren(self, outfile, level, namespace_='campaign:', name_='AttributedThreatActorType', fromsubclass_=False, pretty_print=True):
        super(AttributedThreatActorType, self).exportChildren(outfile, level, 'campaign:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.AttributedThreatActorConfidence is not None:
            self.AttributedThreatActorConfidence.export(outfile, level, 'campaign:', name_='AttributedThreatActorConfidence', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AttributedThreatActorConfidence is not None or
            super(AttributedThreatActorType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AttributedThreatActorType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(AttributedThreatActorType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(AttributedThreatActorType, self).exportLiteralChildren(outfile, level, name_)
        if self.AttributedThreatActorConfidence is not None:
            showIndent(outfile, level)
            outfile.write('AttributedThreatActorConfidence=model_.stix_common_binding.ConfidenceType(\n')
            self.AttributedThreatActorConfidence.exportLiteral(outfile, level, name_='AttributedThreatActorConfidence')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        super(AttributedThreatActorType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'AttributedThreatActorConfidence':
            obj_ = stix_common_binding.ConfidenceType.factory()
            obj_.build(child_)
            self.set_AttributedThreatActorConfidence(obj_)
        super(AttributedThreatActorType, self).buildChildren(child_, node, nodeName_, True)
# end class AttributedThreatActorType






USAGE_TEXT = """
Usage: python <Parser>.py [ -s ] <in_xml_file>
"""

def usage():
    print(USAGE_TEXT)
    sys.exit(1)

def get_root_tag(node):
    tag = Tag_pattern_.match(node.tag).groups()[-1]
    rootClass = globals().get(tag)
    return tag, rootClass

def parse(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Campaign'
        rootClass = CampaignType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('<?xml version="1.0" ?>\n')
    rootObj.export(sys.stdout, 0, name_=rootTag,
        namespacedef_='',
        pretty_print=True)
    return rootObj

def parseString(inString):
    from StringIO import StringIO
    doc = parsexml_(StringIO(inString))
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Campaign'
        rootClass = CampaignType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('<?xml version="1.0" ?>\n')
    rootObj.export(sys.stdout, 0, name_="Campaign",
        namespacedef_='')
    return rootObj

def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Campaign'
        rootClass = CampaignType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('#from stix_campaign_0_5 import *\n\n')
    sys.stdout.write('import stix_campaign_0_5 as model_\n\n')
    sys.stdout.write('rootObj = model_.rootTag(\n')
    rootObj.exportLiteral(sys.stdout, 0, name_=rootTag)
    sys.stdout.write(')\n')
    return rootObj

def main():
    args = sys.argv[1:]
    if len(args) == 1:
        parse(args[0])
    else:
        usage()

if __name__ == '__main__':
    #import pdb; pdb.set_trace()
    main()

__all__ = [
    "CampaignType",
    "RelatedTTPType",
    "AttributionType",
    "AttributedThreatActorType",
    "AssociatedCampaignType",
    "RelatedIndicatorType",
    "ThreatActorType"
    ]
