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

#
# Generated Wed Nov 14 13:03:31 2012 by generateDS.py version 2.7c.
#

import sys
import getopt
import re as re_

import stix.bindings.data_marking_0_5 as data_marking_binding
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_common_0_2 as stix_common_binding
import stix.bindings.stix_indicator_1_1 as stix_indicator_binding
import stix.bindings.capec.ap_schema_2_5 as ap_binding
import stix.bindings.iodef.iodef_1_0 as iodef_binding
import stix.bindings.stix_campaign_0_5_1 as stix_campaign_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_exploit_target_0_3_1 as stix_exploit_target_binding
import stix.bindings.stix_coa_0_3_1 as stix_coa_binding
import stix.bindings.stix_incident_0_3_1 as stix_incident_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 STIXType(GeneratedsSuper):
    """STIXType defines a bundle of information characterized in the
    Structured Threat Information eXpression (STIX)
    language.Specifies a globally unique identifier for this STIX
    Package. Specifies a globally unique identifier of a STIX
    Package specified elsewhere.Specifies the relevant STIX schema
    version for this content."""
    subclass = None
    superclass = None
    def __init__(self, idref=None, id=None, version=None, STIXHeader=None, Observables=None, Indicators=None, TTPs=None, ExploitTargets=None, Incidents=None, CoursesOfAction=None, Campaigns=None, ThreatActors=None):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.STIXHeader = STIXHeader
        self.Observables = Observables
        self.Indicators = Indicators
        self.TTPs = TTPs
        self.ExploitTargets = ExploitTargets
        self.Incidents = Incidents
        self.CoursesOfAction = CoursesOfAction
        self.Campaigns = Campaigns
        self.ThreatActors = ThreatActors
    def factory(*args_, **kwargs_):
        if STIXType.subclass:
            return STIXType.subclass(*args_, **kwargs_)
        else:
            return STIXType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_STIXHeader(self): return self.STIXHeader
    def set_STIXHeader(self, STIXHeader): self.STIXHeader = STIXHeader
    def get_Observables(self): return self.Observables
    def set_Observables(self, Observables): self.Observables = Observables
    def get_Indicators(self): return self.Indicators
    def set_Indicators(self, Indicators): self.Indicators = Indicators
    def get_TTPs(self): return self.TTPs
    def set_TTPs(self, TTPs): self.TTPs = TTPs
    def get_ExploitTargets(self): return self.ExploitTargets
    def set_ExploitTargets(self, ExploitTargets): self.ExploitTargets = ExploitTargets
    def get_Incidents(self): return self.Incidents
    def set_Incidents(self, Incidents): self.Incidents = Incidents
    def get_CoursesOfAction(self): return self.CoursesOfAction
    def set_CoursesOfAction(self, CoursesOfAction): self.CoursesOfAction = CoursesOfAction
    def get_Campaigns(self): return self.Campaigns
    def set_Campaigns(self, Campaigns): self.Campaigns = Campaigns
    def get_ThreatActors(self): return self.ThreatActors
    def set_ThreatActors(self, ThreatActors): self.ThreatActors = ThreatActors
    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_='stix:', name_='STIXType', 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_='STIXType')
        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_='stix:', name_='STIXType'):
        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_='stix:', name_='STIXType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.STIXHeader is not None:
            self.STIXHeader.export(outfile, level, 'stix:', name_='STIXHeader', pretty_print=pretty_print)
        if self.Observables is not None:
            self.Observables.export(outfile, level, 'stix:', name_='Observables', pretty_print=pretty_print)
        if self.Indicators is not None:
            self.Indicators.export(outfile, level, 'stix:', name_='Indicators', pretty_print=pretty_print)
        if self.TTPs is not None:
            self.TTPs.export(outfile, level, 'stix:', name_='TTPs', pretty_print=pretty_print)
        if self.ExploitTargets is not None:
            self.ExploitTargets.export(outfile, level, 'stix:', name_='ExploitTargets', pretty_print=pretty_print)
        if self.Incidents is not None:
            self.Incidents.export(outfile, level, 'stix:', name_='Incidents', pretty_print=pretty_print)
        if self.CoursesOfAction is not None:
            self.CoursesOfAction.export(outfile, level, 'stix:', name_='CoursesOfAction', pretty_print=pretty_print)
        if self.Campaigns is not None:
            self.Campaigns.export(outfile, level, 'stix:', name_='Campaigns', pretty_print=pretty_print)
        if self.ThreatActors is not None:
            self.ThreatActors.export(outfile, level, 'stix:', name_='ThreatActors', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.STIXHeader is not None or
            self.Observables is not None or
            self.Indicators is not None or
            self.TTPs is not None or
            self.ExploitTargets is not None or
            self.Incidents is not None or
            self.CoursesOfAction is not None or
            self.Campaigns is not None or
            self.ThreatActors is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='STIXType'):
        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.STIXHeader is not None:
            showIndent(outfile, level)
            outfile.write('STIXHeader=model_.STIXHeaderType(\n')
            self.STIXHeader.exportLiteral(outfile, level, name_='STIXHeader')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Observables is not None:
            showIndent(outfile, level)
            outfile.write('Observables=model_.cybox_core_binding.ObservablesType(\n')
            self.Observables.exportLiteral(outfile, level, name_='Observables')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Indicators is not None:
            showIndent(outfile, level)
            outfile.write('Indicators=model_.IndicatorsType(\n')
            self.Indicators.exportLiteral(outfile, level, name_='Indicators')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.TTPs is not None:
            showIndent(outfile, level)
            outfile.write('TTPs=model_.TTPsType(\n')
            self.TTPs.exportLiteral(outfile, level, name_='TTPs')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.ExploitTargets is not None:
            showIndent(outfile, level)
            outfile.write('ExploitTargets=model_.ExploitTargetsType(\n')
            self.ExploitTargets.exportLiteral(outfile, level, name_='ExploitTargets')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Incidents is not None:
            showIndent(outfile, level)
            outfile.write('Incidents=model_.IncidentsType(\n')
            self.Incidents.exportLiteral(outfile, level, name_='Incidents')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.CoursesOfAction is not None:
            showIndent(outfile, level)
            outfile.write('CoursesOfAction=model_.CoursesOfActionType(\n')
            self.CoursesOfAction.exportLiteral(outfile, level, name_='CoursesOfAction')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Campaigns is not None:
            showIndent(outfile, level)
            outfile.write('Campaigns=model_.CampaignsType(\n')
            self.Campaigns.exportLiteral(outfile, level, name_='Campaigns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.ThreatActors is not None:
            showIndent(outfile, level)
            outfile.write('ThreatActors=model_.ThreatActorsType(\n')
            self.ThreatActors.exportLiteral(outfile, level, name_='ThreatActors')
            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_ == 'STIXHeader':
            obj_ = STIXHeaderType.factory()
            obj_.build(child_)
            self.set_STIXHeader(obj_)
        elif nodeName_ == 'Observables':
            obj_ = cybox_core_binding.ObservablesType.factory()
            obj_.build(child_)
            self.set_Observables(obj_)
        elif nodeName_ == 'Indicators':
            obj_ = IndicatorsType.factory()
            obj_.build(child_)
            self.set_Indicators(obj_)
        elif nodeName_ == 'TTPs':
            obj_ = TTPsType.factory()
            obj_.build(child_)
            self.set_TTPs(obj_)
        elif nodeName_ == 'ExploitTargets':
            obj_ = ExploitTargetsType.factory()
            obj_.build(child_)
            self.set_ExploitTargets(obj_)
        elif nodeName_ == 'Incidents':
            obj_ = IncidentsType.factory()
            obj_.build(child_)
            self.set_Incidents(obj_)
        elif nodeName_ == 'CoursesOfAction':
            obj_ = CoursesOfActionType.factory()
            obj_.build(child_)
            self.set_CoursesOfAction(obj_)
        elif nodeName_ == 'Campaigns':
            obj_ = CampaignsType.factory()
            obj_.build(child_)
            self.set_Campaigns(obj_)
        elif nodeName_ == 'ThreatActors':
            obj_ = ThreatActorsType.factory()
            obj_.build(child_)
            self.set_ThreatActors(obj_)
# end class STIXType



class STIXHeaderType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, PackageIntent=None, Description=None, Handling=None, InformationSource=None):
        self.PackageIntent = PackageIntent
        self.Description = Description
        self.Handling = Handling
        self.InformationSource = InformationSource
    def factory(*args_, **kwargs_):
        if STIXHeaderType.subclass:
            return STIXHeaderType.subclass(*args_, **kwargs_)
        else:
            return STIXHeaderType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_PackageIntent(self): return self.PackageIntent
    def set_PackageIntent(self, PackageIntent): self.PackageIntent = PackageIntent
    def get_Description(self): return self.Description
    def set_Description(self, Description): self.Description = Description
    def get_Handling(self): return self.Handling
    def set_Handling(self, Handling): self.Handling = Handling
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def export(self, outfile, level, namespace_='stix:', name_='STIXHeaderType', 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_='STIXHeaderType')
        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_='stix:', name_='STIXHeaderType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='STIXHeaderType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.PackageIntent is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sPackageIntent>%s</%sPackageIntent>%s' % (namespace_, self.gds_format_string(quote_xml(self.PackageIntent).encode(ExternalEncoding), input_name='PackageIntent'), namespace_, eol_))
        if self.Description is not None:
            self.Description.export(outfile, level, namespace_, name_='Description', pretty_print=pretty_print)
        if self.Handling is not None:
            self.Handling.export(outfile, level, namespace_, name_='Handling', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, namespace_, name_='InformationSource', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.PackageIntent is not None or
            self.Description is not None or
            self.Handling is not None or
            self.InformationSource is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='STIXHeaderType'):
        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_):
        if self.PackageIntent is not None:
            showIndent(outfile, level)
            outfile.write('PackageIntent=%s,\n' % quote_python(self.PackageIntent).encode(ExternalEncoding))
        if self.Description is not None:
            showIndent(outfile, level)
            outfile.write('Description=model_.StructuredTextType(\n')
            self.Description.exportLiteral(outfile, level, name_='Description')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Handling is not None:
            showIndent(outfile, level)
            outfile.write('Handling=model_.MarkingType(\n')
            self.Handling.exportLiteral(outfile, level, name_='Handling')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.InformationSource is not None:
            showIndent(outfile, level)
            outfile.write('InformationSource=model_.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_ == 'PackageIntent':
            PackageIntent_ = child_.text
            PackageIntent_ = self.gds_validate_string(PackageIntent_, node, 'PackageIntent')
            self.PackageIntent = PackageIntent_
        elif nodeName_ == 'Description':
            obj_ = cybox_common_binding.StructuredTextType.factory()
            obj_.build(child_)
            self.set_Description(obj_)
        elif nodeName_ == 'Handling':
            obj_ = data_marking_binding.MarkingType.factory()
            obj_.build(child_)
            self.set_Handling(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
# end class STIXHeaderType


class IndicatorsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Indicator=None):
        if Indicator is None:
            self.Indicator = []
        else:
            self.Indicator = Indicator
    def factory(*args_, **kwargs_):
        if IndicatorsType.subclass:
            return IndicatorsType.subclass(*args_, **kwargs_)
        else:
            return IndicatorsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Indicator(self): return self.Indicator
    def set_Indicator(self, Indicator): self.Indicator = Indicator
    def add_Indicator(self, value): self.Indicator.append(value)
    def insert_Indicator(self, index, value): self.Indicator[index] = value
    def export(self, outfile, level, namespace_='stix:', name_='IndicatorsType', 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_='IndicatorsType')
        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_='stix:', name_='IndicatorsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='IndicatorsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Indicator_ in self.get_Indicator():
            Indicator_.export(outfile, level, namespace_, name_='Indicator', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Indicator
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='IndicatorsType'):
        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('Indicator=[\n')
        level += 1
        for Indicator_ in self.Indicator:
            showIndent(outfile, level)
            outfile.write('model_.IndicatorType(\n')
            Indicator_.exportLiteral(outfile, level, name_='IndicatorType')
            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):
        obj_ = stix_indicator_binding.IndicatorType.factory()
        obj_.build(child_)
        self.Indicator.append(obj_)
# end class IndicatorsType


class TTPsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, TTP=None, KillChains=None):
        if TTP is None:
            self.TTP = []
        else:
            self.TTP = TTP
        self.KillChains = KillChains
    def factory(*args_, **kwargs_):
        if TTPsType.subclass:
            return TTPsType.subclass(*args_, **kwargs_)
        else:
            return TTPsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_TTP(self): return self.TTP
    def set_TTP(self, TTP): self.TTP = TTP
    def add_TTP(self, value): self.TTP.append(value)
    def insert_TTP(self, index, value): self.TTP[index] = value
    def get_KillChains(self): return self.KillChains
    def set_KillChains(self, KillChains): self.KillChains = KillChains
    def export(self, outfile, level, namespace_='stix:', name_='TTPsType', 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_='TTPsType')
        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_='stix:', name_='TTPsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='TTPsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for TTP_ in self.TTP:
            TTP_.export(outfile, level, namespace_, name_='TTP', pretty_print=pretty_print)
        if self.KillChains is not None:
            self.KillChains.export(outfile, level, namespace_, name_='KillChains', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.TTP or
            self.KillChains is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='TTPsType'):
        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('TTP=[\n')
        level += 1
        for TTP_ in self.TTP:
            showIndent(outfile, level)
            outfile.write('model_.TTPType(\n')
            TTP_.exportLiteral(outfile, level, name_='TTPType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.KillChains is not None:
            showIndent(outfile, level)
            outfile.write('KillChains=model_.KillChainsType(\n')
            self.KillChains.exportLiteral(outfile, level, name_='KillChains')
            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_ == 'TTP':
            obj_ = stix_ttp_binding.TTPType.factory()
            obj_.build(child_)
            self.TTP.append(obj_)
        elif nodeName_ == 'KillChains':
            obj_ = stix_ttp_binding.KillChainsType.factory()
            obj_.build(child_)
            self.set_KillChains(obj_)
# end class TTPsType



class ExploitTargetsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ExploitTarget=None):
        if ExploitTarget is None:
            self.ExploitTarget = []
        else:
            self.ExploitTarget = ExploitTarget
    def factory(*args_, **kwargs_):
        if ExploitTargetsType.subclass:
            return ExploitTargetsType.subclass(*args_, **kwargs_)
        else:
            return ExploitTargetsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_ExploitTarget(self): return self.ExploitTarget
    def set_ExploitTarget(self, ExploitTarget): self.ExploitTarget = ExploitTarget
    def add_ExploitTarget(self, value): self.ExploitTarget.append(value)
    def insert_ExploitTarget(self, index, value): self.ExploitTarget[index] = value
    def export(self, outfile, level, namespace_='stix:', name_='ExploitTargetsType', 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_='ExploitTargetsType')
        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_='stix:', name_='ExploitTargetsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='ExploitTargetsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for ExploitTarget_ in self.ExploitTarget:
            ExploitTarget_.export(outfile, level, namespace_, name_='ExploitTarget', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ExploitTarget
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ExploitTargetsType'):
        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('ExploitTarget=[\n')
        level += 1
        for ExploitTarget_ in self.ExploitTarget:
            showIndent(outfile, level)
            outfile.write('model_.ExploitTargetType(\n')
            ExploitTarget_.exportLiteral(outfile, level, name_='ExploitTargetType')
            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_ == 'ExploitTarget':
            obj_ = stix_exploit_target_binding.ExploitTargetType.factory()
            obj_.build(child_)
            self.ExploitTarget.append(obj_)
# end class ExploitTargetsType


class IncidentsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Incident=None):
        if Incident is None:
            self.Incident = []
        else:
            self.Incident = Incident
    def factory(*args_, **kwargs_):
        if IncidentsType.subclass:
            return IncidentsType.subclass(*args_, **kwargs_)
        else:
            return IncidentsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Incident(self): return self.Incident
    def set_Incident(self, Incident): self.Incident = Incident
    def add_Incident(self, value): self.Incident.append(value)
    def insert_Incident(self, index, value): self.Incident[index] = value
    def export(self, outfile, level, namespace_='stix:', name_='IncidentsType', 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_='IncidentsType')
        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_='stix:', name_='IncidentsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='IncidentsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Incident_ in self.Incident:
            Incident_.export(outfile, level, namespace_, name_='Incident', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Incident
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='IncidentsType'):
        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('Incident=[\n')
        level += 1
        for Incident_ in self.Incident:
            showIndent(outfile, level)
            outfile.write('model_.IncidentType(\n')
            Incident_.exportLiteral(outfile, level, name_='IncidentType')
            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_ == 'Incident':
            obj_ = stix_incident_binding.IncidentType.factory()
            obj_.build(child_)
            self.Incident.append(obj_)
# end class IncidentsType


class CoursesOfActionType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, CourseOfAction=None):
        if CourseOfAction is None:
            self.CourseOfAction = []
        else:
            self.CourseOfAction = CourseOfAction
    def factory(*args_, **kwargs_):
        if CoursesOfActionType.subclass:
            return CoursesOfActionType.subclass(*args_, **kwargs_)
        else:
            return CoursesOfActionType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_CourseOfAction(self): return self.CourseOfAction
    def set_CourseOfAction(self, CourseOfAction): self.CourseOfAction = CourseOfAction
    def add_CourseOfAction(self, value): self.CourseOfAction.append(value)
    def insert_CourseOfAction(self, index, value): self.CourseOfAction[index] = value
    def export(self, outfile, level, namespace_='stix:', name_='CoursesOfActionType', 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_='CoursesOfActionType')
        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_='stix:', name_='CoursesOfActionType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='CoursesOfActionType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for CourseOfAction_ in self.CourseOfAction:
            CourseOfAction_.export(outfile, level, namespace_, name_='CourseOfAction', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.CourseOfAction
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='CoursesOfActionType'):
        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('CourseOfAction=[\n')
        level += 1
        for CourseOfAction_ in self.CourseOfAction:
            showIndent(outfile, level)
            outfile.write('model_.COAType(\n')
            CourseOfAction_.exportLiteral(outfile, level, name_='COAType')
            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_ == 'CourseOfAction':
            obj_ = stix_coa_binding.COAType.factory()
            obj_.build(child_)
            self.CourseOfAction.append(obj_)
# end class CoursesOfActionType


class CampaignsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Campaign=None):
        if Campaign is None:
            self.Campaign = []
        else:
            self.Campaign = Campaign
    def factory(*args_, **kwargs_):
        if CampaignsType.subclass:
            return CampaignsType.subclass(*args_, **kwargs_)
        else:
            return CampaignsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Campaign(self): return self.Campaign
    def set_Campaign(self, Campaign): self.Campaign = Campaign
    def add_Campaign(self, value): self.Campaign.append(value)
    def insert_Campaign(self, index, value): self.Campaign[index] = value
    def export(self, outfile, level, namespace_='stix:', name_='CampaignsType', 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_='CampaignsType')
        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_='stix:', name_='CampaignsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='CampaignsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Campaign_ in self.Campaign:
            Campaign_.export(outfile, level, namespace_, name_='Campaign', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Campaign
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='CampaignsType'):
        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('Campaign=[\n')
        level += 1
        for Campaign_ in self.Campaign:
            showIndent(outfile, level)
            outfile.write('model_.CampaignType(\n')
            Campaign_.exportLiteral(outfile, level, name_='CampaignType')
            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_ == 'Campaign':
            obj_ = stix_campaign_binding.CampaignType.factory()
            obj_.build(child_)
            self.Campaign.append(obj_)
# end class CampaignsType


class ThreatActorsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ThreatActor=None):
        if ThreatActor is None:
            self.ThreatActor = []
        else:
            self.ThreatActor = ThreatActor
    def factory(*args_, **kwargs_):
        if ThreatActorsType.subclass:
            return ThreatActorsType.subclass(*args_, **kwargs_)
        else:
            return ThreatActorsType(*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 export(self, outfile, level, namespace_='stix:', name_='ThreatActorsType', 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_='ThreatActorsType')
        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_='stix:', name_='ThreatActorsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='stix:', name_='ThreatActorsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for ThreatActor_ in self.ThreatActor:
            ThreatActor_.export(outfile, level, namespace_, name_='ThreatActor', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.ThreatActor
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ThreatActorsType'):
        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_.ThreatActorType(\n')
            ThreatActor_.exportLiteral(outfile, level, name_='ThreatActorType')
            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_ == 'ThreatActor':
            obj_ = stix_threat_actor_binding.ThreatActorType.factory()
            obj_.build(child_)
            self.ThreatActor.append(obj_)
# end class ThreatActorsType





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 = 'STIX_Package'
        rootClass = STIXType
    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 = 'STIX_Package'
        rootClass = STIXType
    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_="STIX_Package",
        namespacedef_='')
    return rootObj

def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'STIX_Package'
        rootClass = STIXType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('#from stix_core_1_0 import *\n\n')
    sys.stdout.write('import stix.bindings.stix_core_1_0 as stix_core_binding 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__ = [
    "STIXType"
    ]
