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

#
# Generated Wed Nov 14 13:02:46 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.capec.ap_schema_2_5 as ap_binding
import maec.bindings.maec_package_1_0 as maec_package_binding
import stix.bindings.stix_exploit_target_0_3_1 as stix_exploit_target_binding
import stix.bindings.stix_common_0_2 as stix_common_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 TTPType(GeneratedsSuper):
    """TTPType characterizes an individual adversary TTP.Specifies a
    globally unique identifier for this TTP item. Specifies a
    globally unique identifier of a TTP item specified
    elsewhere.Specifies the relevant STIX-TTP schema version for
    this content."""
    subclass = None
    superclass = None
    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):
        self.idref = _cast(None, idref)
        self.id = _cast(None, id)
        self.version = _cast(None, version)
        self.Behavior_AttackPatterns = Behavior_AttackPatterns
        self.Behavior_Malware = Behavior_Malware
        self.Behavior_Exploits = Behavior_Exploits
        self.Resource_Tools = Resource_Tools
        self.Resource_Infrastructure = Resource_Infrastructure
        self.VictimTargeting = VictimTargeting
        self.ExploitTargets = ExploitTargets
        self.Intent = Intent
        self.RelatedTTPs = RelatedTTPs
        self.KillChainPhases = KillChainPhases
        self.InformationSource = InformationSource
        self.KillChains = KillChains
    def factory(*args_, **kwargs_):
        if TTPType.subclass:
            return TTPType.subclass(*args_, **kwargs_)
        else:
            return TTPType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Behavior_AttackPatterns(self): return self.Behavior_AttackPatterns
    def set_Behavior_AttackPatterns(self, Behavior_AttackPatterns): self.Behavior_AttackPatterns = Behavior_AttackPatterns
    def get_Behavior_Malware(self): return self.Behavior_Malware
    def set_Behavior_Malware(self, Behavior_Malware): self.Behavior_Malware = Behavior_Malware
    def get_Behavior_Exploits(self): return self.Behavior_Exploits
    def set_Behavior_Exploits(self, Behavior_Exploits): self.Behavior_Exploits = Behavior_Exploits
    def get_Resource_Tools(self): return self.Resource_Tools
    def set_Resource_Tools(self, Resource_Tools): self.Resource_Tools = Resource_Tools
    def get_Resource_Infrastructure(self): return self.Resource_Infrastructure
    def set_Resource_Infrastructure(self, Resource_Infrastructure): self.Resource_Infrastructure = Resource_Infrastructure
    def get_VictimTargeting(self): return self.VictimTargeting
    def set_VictimTargeting(self, VictimTargeting): self.VictimTargeting = VictimTargeting
    def get_ExploitTargets(self): return self.ExploitTargets
    def set_ExploitTargets(self, ExploitTargets): self.ExploitTargets = ExploitTargets
    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_KillChainPhases(self): return self.KillChainPhases
    def set_KillChainPhases(self, KillChainPhases): self.KillChainPhases = KillChainPhases
    def get_InformationSource(self): return self.InformationSource
    def set_InformationSource(self, InformationSource): self.InformationSource = InformationSource
    def get_KillChains(self): return self.KillChains
    def set_KillChains(self, KillChains): self.KillChains = KillChains
    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_='TTP:', name_='TTPType', 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_='TTPType')
        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_='TTP:', name_='TTPType'):
        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_='TTP:', name_='TTPType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Behavior_AttackPatterns is not None:
            self.Behavior_AttackPatterns.export(outfile, level, 'TTP:', name_='Behavior-AttackPatterns', pretty_print=pretty_print)
        if self.Behavior_Malware is not None:
            self.Behavior_Malware.export(outfile, level, 'TTP:', name_='Behavior-Malware', pretty_print=pretty_print)
        if self.Behavior_Exploits is not None:
            self.Behavior_Exploits.export(outfile, level, 'TTP:', name_='Behavior-Exploits', pretty_print=pretty_print)
        if self.Resource_Tools is not None:
            self.Resource_Tools.export(outfile, level, 'TTP:', name_='Resource-Tools', pretty_print=pretty_print)
        if self.Resource_Infrastructure is not None:
            self.Resource_Infrastructure.export(outfile, level, 'TTP:', name_='Resource-Infrastructure', pretty_print=pretty_print)
        if self.VictimTargeting is not None:
            self.VictimTargeting.export(outfile, level, 'TTP:', name_='VictimTargeting', pretty_print=pretty_print)
        if self.ExploitTargets is not None:
            self.ExploitTargets.export(outfile, level, 'TTP:', name_='ExploitTargets', pretty_print=pretty_print)
        if self.Intent is not None:
            self.Intent.export(outfile, level, 'TTP:', name_='Intent', pretty_print=pretty_print)
        if self.RelatedTTPs is not None:
            self.RelatedTTPs.export(outfile, level, 'TTP:', name_='RelatedTTPs', pretty_print=pretty_print)
        if self.KillChainPhases is not None:
            self.KillChainPhases.export(outfile, level, 'TTP:', name_='KillChainPhases', pretty_print=pretty_print)
        if self.InformationSource is not None:
            self.InformationSource.export(outfile, level, 'TTP:', name_='InformationSource', pretty_print=pretty_print)
        if self.KillChains is not None:
            self.KillChains.export(outfile, level, 'TTP:', name_='KillChains', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Behavior_AttackPatterns is not None or
            self.Behavior_Malware is not None or
            self.Behavior_Exploits is not None or
            self.Resource_Tools is not None or
            self.Resource_Infrastructure is not None or
            self.VictimTargeting is not None or
            self.ExploitTargets is not None or
            self.Intent is not None or
            self.RelatedTTPs is not None or
            self.KillChainPhases is not None or
            self.InformationSource is not None or
            self.KillChains is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='TTPType'):
        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.Behavior_AttackPatterns is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_AttackPatterns=model_.Behavior_AttackPatternsType(\n')
            self.Behavior_AttackPatterns.exportLiteral(outfile, level, name_='Behavior_AttackPatterns')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Behavior_Malware is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_Malware=model_.Behavior_MalwareType(\n')
            self.Behavior_Malware.exportLiteral(outfile, level, name_='Behavior_Malware')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Behavior_Exploits is not None:
            showIndent(outfile, level)
            outfile.write('Behavior_Exploits=model_.Behavior_ExploitsType(\n')
            self.Behavior_Exploits.exportLiteral(outfile, level, name_='Behavior_Exploits')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Resource_Tools is not None:
            showIndent(outfile, level)
            outfile.write('Resource_Tools=model_.Resource_ToolsType(\n')
            self.Resource_Tools.exportLiteral(outfile, level, name_='Resource_Tools')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Resource_Infrastructure is not None:
            showIndent(outfile, level)
            outfile.write('Resource_Infrastructure=model_.Resource_InfrastructureType(\n')
            self.Resource_Infrastructure.exportLiteral(outfile, level, name_='Resource_Infrastructure')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.VictimTargeting is not None:
            showIndent(outfile, level)
            outfile.write('VictimTargeting=model_.stix_common_binding.IdentityType(\n')
            self.VictimTargeting.exportLiteral(outfile, level, name_='VictimTargeting')
            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.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.KillChainPhases is not None:
            showIndent(outfile, level)
            outfile.write('KillChainPhases=model_.KillChainPhasesType(\n')
            self.KillChainPhases.exportLiteral(outfile, level, name_='KillChainPhases')
            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')
        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):
        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_ == 'Behavior-AttackPatterns':
            obj_ = Behavior_AttackPatternsType.factory()
            obj_.build(child_)
            self.set_Behavior_AttackPatterns(obj_)
        elif nodeName_ == 'Behavior-Malware':
            obj_ = Behavior_MalwareType.factory()
            obj_.build(child_)
            self.set_Behavior_Malware(obj_)
        elif nodeName_ == 'Behavior-Exploits':
            obj_ = Behavior_ExploitsType.factory()
            obj_.build(child_)
            self.set_Behavior_Exploits(obj_)
        elif nodeName_ == 'Resource-Tools':
            obj_ = Resource_ToolsType.factory()
            obj_.build(child_)
            self.set_Resource_Tools(obj_)
        elif nodeName_ == 'Resource-Infrastructure':
            obj_ = Resource_InfrastructureType.factory()
            obj_.build(child_)
            self.set_Resource_Infrastructure(obj_)
        elif nodeName_ == 'VictimTargeting':
            obj_ = stix_common_binding.IdentityType.factory()
            obj_.build(child_)
            self.set_VictimTargeting(obj_)
        elif nodeName_ == 'ExploitTargets':
            obj_ = ExploitTargetsType.factory()
            obj_.build(child_)
            self.set_ExploitTargets(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_ == 'KillChainPhases':
            obj_ = KillChainPhasesType.factory()
            obj_.build(child_)
            self.set_KillChainPhases(obj_)
        elif nodeName_ == 'InformationSource':
            obj_ = stix_common_binding.InformationSourceType.factory()
            obj_.build(child_)
            self.set_InformationSource(obj_)
        elif nodeName_ == 'KillChains':
            obj_ = KillChainsType.factory()
            obj_.build(child_)
            self.set_KillChains(obj_)
# end class TTPType

class RelatedTTPType(TTPType):
    """The RelatedTTPType specifies a single TTP asserted to berelated to
    this cyber threat TTP."""
    subclass = None
    superclass = 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_='TTP:', 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_='TTP:', name_='RelatedTTPType'):
        super(RelatedTTPType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='RelatedTTPType')
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='RelatedTTPType', fromsubclass_=False, pretty_print=True):
        super(RelatedTTPType, self).exportChildren(outfile, level, 'TTP:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.RelatedTTPConfidence is not None:
            self.RelatedTTPConfidence.export(outfile, level, 'TTP:', 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 Behavior_AttackPatternsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, AttackPattern=None):
        if AttackPattern is None:
            self.AttackPattern = []
        else:
            self.AttackPattern = AttackPattern
    def factory(*args_, **kwargs_):
        if Behavior_AttackPatternsType.subclass:
            return Behavior_AttackPatternsType.subclass(*args_, **kwargs_)
        else:
            return Behavior_AttackPatternsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_AttackPattern(self): return self.AttackPattern
    def set_AttackPattern(self, AttackPattern): self.AttackPattern = AttackPattern
    def add_AttackPattern(self, value): self.AttackPattern.append(value)
    def insert_AttackPattern(self, index, value): self.AttackPattern[index] = value
    def export(self, outfile, level, namespace_='TTP:', name_='Behavior-AttackPatternsType', 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_='Behavior-AttackPatternsType')
        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_='TTP:', name_='Behavior-AttackPatternsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='Behavior-AttackPatternsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for AttackPattern_ in self.AttackPattern:
            AttackPattern_.export(outfile, level, namespace_, name_='AttackPattern', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.AttackPattern
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='Behavior-AttackPatternsType'):
        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('AttackPattern=[\n')
        level += 1
        for AttackPattern_ in self.AttackPattern:
            showIndent(outfile, level)
            outfile.write('model_.AttackPatternType(\n')
            AttackPattern_.exportLiteral(outfile, level, name_='AttackPatternType')
            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_ == 'AttackPattern':
            obj_ = AttackPatternType.factory()
            obj_.build(child_)
            self.AttackPattern.append(obj_)
# end class Behavior_AttackPatternsType


class AttackPatternType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, StructuredDescription=None, ProseDescription=None):
        self.StructuredDescription = StructuredDescription
        self.ProseDescription = ProseDescription
    def factory(*args_, **kwargs_):
        if AttackPatternType.subclass:
            return AttackPatternType.subclass(*args_, **kwargs_)
        else:
            return AttackPatternType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_StructuredDescription(self): return self.StructuredDescription
    def set_StructuredDescription(self, StructuredDescription): self.StructuredDescription = StructuredDescription
    def get_ProseDescription(self): return self.ProseDescription
    def set_ProseDescription(self, ProseDescription): self.ProseDescription = ProseDescription
    def export(self, outfile, level, namespace_='TTP:', name_='AttackPatternType', 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_='AttackPatternType')
        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_='TTP:', name_='AttackPatternType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='AttackPatternType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.StructuredDescription is not None:
            self.StructuredDescription.export(outfile, level, namespace_, name_='StructuredDescription', pretty_print=pretty_print)
        if self.ProseDescription is not None:
            self.ProseDescription.export(outfile, level, namespace_, name_='ProseDescription', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.StructuredDescription is not None or
            self.ProseDescription is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='AttackPatternType'):
        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.StructuredDescription is not None:
            showIndent(outfile, level)
            outfile.write('StructuredDescription=model_.Attack_PatternType(\n')
            self.StructuredDescription.exportLiteral(outfile, level, name_='StructuredDescription')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.ProseDescription is not None:
            showIndent(outfile, level)
            outfile.write('ProseDescription=model_.StructuredTextType(\n')
            self.ProseDescription.exportLiteral(outfile, level, name_='ProseDescription')
            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_ == 'StructuredDescription':
            obj_ = ap_binding.Attack_PatternType.factory()
            obj_.build(child_)
            self.set_StructuredDescription(obj_)
        elif nodeName_ == 'ProseDescription':
            obj_ = cybox_common_binding.StructuredTextType.factory()
            obj_.build(child_)
            self.set_ProseDescription(obj_)
# end class AttackPatternType

class Behavior_MalwareType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, MalwareInstance=None):
        if MalwareInstance is None:
            self.MalwareInstance = []
        else:
            self.MalwareInstance = MalwareInstance
    def factory(*args_, **kwargs_):
        if Behavior_MalwareType.subclass:
            return Behavior_MalwareType.subclass(*args_, **kwargs_)
        else:
            return Behavior_MalwareType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_MalwareInstance(self): return self.MalwareInstance
    def set_MalwareInstance(self, MalwareInstance): self.MalwareInstance = MalwareInstance
    def add_MalwareInstance(self, value): self.MalwareInstance.append(value)
    def insert_MalwareInstance(self, index, value): self.MalwareInstance[index] = value
    def export(self, outfile, level, namespace_='TTP:', name_='Behavior-MalwareType', 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_='Behavior-MalwareType')
        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_='TTP:', name_='Behavior-MalwareType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='Behavior-MalwareType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for MalwareInstance_ in self.MalwareInstance:
            MalwareInstance_.export(outfile, level, namespace_, name_='MalwareInstance', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.MalwareInstance
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='Behavior-MalwareType'):
        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('MalwareInstance=[\n')
        level += 1
        for MalwareInstance_ in self.MalwareInstance:
            showIndent(outfile, level)
            outfile.write('model_.MalwareInstanceType(\n')
            MalwareInstance_.exportLiteral(outfile, level, name_='MalwareInstanceType')
            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_ == 'MalwareInstance':
            obj_ = MalwareInstanceType.factory()
            obj_.build(child_)
            self.MalwareInstance.append(obj_)
# end class Behavior_MalwareType


class MalwareInstanceType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, MalwareType=None, MalwareName=None, StructuredDescription=None, ProseDescription=None):
        if MalwareType is None:
            self.MalwareType = []
        else:
            self.MalwareType = MalwareType
        if MalwareName is None:
            self.MalwareName = []
        else:
            self.MalwareName = MalwareName
        self.StructuredDescription = StructuredDescription
        self.ProseDescription = ProseDescription
    def factory(*args_, **kwargs_):
        if MalwareInstanceType.subclass:
            return MalwareInstanceType.subclass(*args_, **kwargs_)
        else:
            return MalwareInstanceType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_MalwareType(self): return self.MalwareType
    def set_MalwareType(self, MalwareType): self.MalwareType = MalwareType
    def add_MalwareType(self, value): self.MalwareType.append(value)
    def insert_MalwareType(self, index, value): self.MalwareType[index] = value
    def get_MalwareName(self): return self.MalwareName
    def set_MalwareName(self, MalwareName): self.MalwareName = MalwareName
    def add_MalwareName(self, value): self.MalwareName.append(value)
    def insert_MalwareName(self, index, value): self.MalwareName[index] = value
    def get_StructuredDescription(self): return self.StructuredDescription
    def set_StructuredDescription(self, StructuredDescription): self.StructuredDescription = StructuredDescription
    def get_ProseDescription(self): return self.ProseDescription
    def set_ProseDescription(self, ProseDescription): self.ProseDescription = ProseDescription
    def export(self, outfile, level, namespace_='TTP:', name_='MalwareInstanceType', 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_='MalwareInstanceType')
        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_='TTP:', name_='MalwareInstanceType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='MalwareInstanceType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for MalwareType_ in self.MalwareType:
            MalwareType_.export(outfile, level, namespace_, name_='MalwareType', pretty_print=pretty_print)
        for MalwareName_ in self.MalwareName:
            MalwareName_.export(outfile, level, namespace_, name_='MalwareName', pretty_print=pretty_print)
        if self.StructuredDescription is not None:
            self.StructuredDescription.export(outfile, level, namespace_, name_='StructuredDescription', pretty_print=pretty_print)
        if self.ProseDescription is not None:
            self.ProseDescription.export(outfile, level, namespace_, name_='ProseDescription', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.MalwareType or
            self.MalwareName or
            self.StructuredDescription is not None or
            self.ProseDescription is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='MalwareInstanceType'):
        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('MalwareType=[\n')
        level += 1
        for MalwareType_ in self.MalwareType:
            showIndent(outfile, level)
            outfile.write('model_.MalwareTypeType(\n')
            MalwareType_.exportLiteral(outfile, level, name_='MalwareTypeType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        showIndent(outfile, level)
        outfile.write('MalwareName=[\n')
        level += 1
        for MalwareName_ in self.MalwareName:
            showIndent(outfile, level)
            outfile.write('model_.MalwareNameType(\n')
            MalwareName_.exportLiteral(outfile, level, name_='MalwareNameType')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.StructuredDescription is not None:
            showIndent(outfile, level)
            outfile.write('StructuredDescription=model_.BundleType(\n')
            self.StructuredDescription.exportLiteral(outfile, level, name_='StructuredDescription')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.ProseDescription is not None:
            showIndent(outfile, level)
            outfile.write('ProseDescription=model_.StructuredTextType(\n')
            self.ProseDescription.exportLiteral(outfile, level, name_='ProseDescription')
            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_ == 'MalwareType':
            obj_ = MalwareTypeType.factory()
            obj_.build(child_)
            self.MalwareType.append(obj_)
        elif nodeName_ == 'MalwareName':
            obj_ = MalwareNameType.factory()
            obj_.build(child_)
            self.MalwareName.append(obj_)
        elif nodeName_ == 'StructuredDescription':
            obj_ = maec_package_binding.PackageType.factory()
            obj_.build(child_)
            self.set_StructuredDescription(obj_)
        elif nodeName_ == 'ProseDescription':
            obj_ = cybox_common_binding.StructuredTextType.factory()
            obj_.build(child_)
            self.set_ProseDescription(obj_)
# end class MalwareInstanceType


class MalwareTypeType(GeneratedsSuper):
    """This field specifies a reference to an malware type value reference.
    The value is a QName or URL that should reference a term in a
    controlled vocabulary which is understood by both the producing
    and consuming parties."""
    subclass = None
    superclass = None
    def __init__(self, malwareTypeRef=None, valueOf_=None):
        self.malwareTypeRef = _cast(None, malwareTypeRef)
        self.valueOf_ = valueOf_
        
    def factory(*args_, **kwargs_):
        if MalwareTypeType.subclass:
            return MalwareTypeType.subclass(*args_, **kwargs_)
        else:
            return MalwareTypeType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_malwareTypeRef(self): return self.malwareTypeRef
    def set_malwareTypeRef(self, malwareTypeRef): self.malwareTypeRef = malwareTypeRef
    def get_valueOf_(self): return self.valueOf_
    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
    def export(self, outfile, level, namespace_='TTP:', name_='MalwareTypeType', 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_='MalwareTypeType')
        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_='TTP:', name_='MalwareTypeType'):
        if self.malwareTypeRef is not None and 'malwareTypeRef' not in already_processed:
            already_processed.append('malwareTypeRef')
            outfile.write(' malwareTypeRef=%s' % (self.gds_format_string(quote_attrib(self.malwareTypeRef).encode(ExternalEncoding), input_name='malwareTypeRef'), ))
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='MalwareTypeType', fromsubclass_=False, pretty_print=True):
        pass
    def hasContent_(self):
        if (
                self.valueOf_
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='MalwareTypeType'):
        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.malwareTypeRef is not None and 'malwareTypeRef' not in already_processed:
            already_processed.append('malwareTypeRef')
            showIndent(outfile, level)
            outfile.write('malwareTypeRef = "%s",\n' % (self.malwareTypeRef,))
    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_('malwareTypeRef', node)
        if value is not None and 'malwareTypeRef' not in already_processed:
            already_processed.append('malwareTypeRef')
            self.malwareTypeRef = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class MalwareTypeType


class MalwareNameType(GeneratedsSuper):
    """This field specifies the authoring source of this malware name."""
    subclass = None
    superclass = None
    def __init__(self, nameSource=None, valueOf_=None):
        self.nameSource = _cast(None, nameSource)
        self.valueOf_ = valueOf_
    def factory(*args_, **kwargs_):
        if MalwareNameType.subclass:
            return MalwareNameType.subclass(*args_, **kwargs_)
        else:
            return MalwareNameType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_nameSource(self): return self.nameSource
    def set_nameSource(self, nameSource): self.nameSource = nameSource
    def get_valueOf_(self): return self.valueOf_
    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
    def export(self, outfile, level, namespace_='TTP:', name_='MalwareNameType', 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_='MalwareNameType')
        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_='TTP:', name_='MalwareNameType'):
        if self.nameSource is not None and 'nameSource' not in already_processed:
            already_processed.append('nameSource')
            outfile.write(' nameSource=%s' % (self.gds_format_string(quote_attrib(self.nameSource).encode(ExternalEncoding), input_name='nameSource'), ))
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='MalwareNameType', fromsubclass_=False, pretty_print=True):
        pass
    def hasContent_(self):
        if (
            self.valueOf_
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='MalwareNameType'):
        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.nameSource is not None and 'nameSource' not in already_processed:
            already_processed.append('nameSource')
            showIndent(outfile, level)
            outfile.write('nameSource = "%s",\n' % (self.nameSource,))
    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_('nameSource', node)
        if value is not None and 'nameSource' not in already_processed:
            already_processed.append('nameSource')
            self.nameSource = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class MalwareNameType


class Behavior_ExploitsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Exploit=None):
        if Exploit is None:
            self.Exploit = []
        else:
            self.Exploit = Exploit
    def factory(*args_, **kwargs_):
        if Behavior_ExploitsType.subclass:
            return Behavior_ExploitsType.subclass(*args_, **kwargs_)
        else:
            return Behavior_ExploitsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Exploit(self): return self.Exploit
    def set_Exploit(self, Exploit): self.Exploit = Exploit
    def add_Exploit(self, value): self.Exploit.append(value)
    def insert_Exploit(self, index, value): self.Exploit[index] = value
    def export(self, outfile, level, namespace_='TTP:', name_='Behavior-ExploitsType', 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_='Behavior-ExploitsType')
        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_='TTP:', name_='Behavior-ExploitsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='Behavior-ExploitsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Exploit_ in self.Exploit:
            Exploit_.export(outfile, level, namespace_, name_='Exploit', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Exploit
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='Behavior-ExploitsType'):
        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('Exploit=[\n')
        level += 1
        for Exploit_ in self.Exploit:
            showIndent(outfile, level)
            outfile.write('model_.StructuredTextType(\n')
            Exploit_.exportLiteral(outfile, level, name_='StructuredTextType')
            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_ == 'Exploit':
            obj_ = cybox_common_binding.StructuredTextType.factory()
            obj_.build(child_)
            self.Exploit.append(obj_)
# end class Behavior_ExploitsType


class Resource_ToolsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Tool=None):
        if Tool is None:
            self.Tool = []
        else:
            self.Tool = Tool
    def factory(*args_, **kwargs_):
        if Resource_ToolsType.subclass:
            return Resource_ToolsType.subclass(*args_, **kwargs_)
        else:
            return Resource_ToolsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Tool(self): return self.Tool
    def set_Tool(self, Tool): self.Tool = Tool
    def add_Tool(self, value): self.Tool.append(value)
    def insert_Tool(self, index, value): self.Tool[index] = value
    def export(self, outfile, level, namespace_='TTP:', name_='Resource-ToolsType', 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_='Resource-ToolsType')
        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_='TTP:', name_='Resource-ToolsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='Resource-ToolsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Tool_ in self.Tool:
            Tool_.export(outfile, level, namespace_, name_='Tool', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Tool
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='Resource-ToolsType'):
        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('Tool=[\n')
        level += 1
        for Tool_ in self.Tool:
            showIndent(outfile, level)
            outfile.write('model_.ToolInformationType(\n')
            Tool_.exportLiteral(outfile, level, name_='ToolInformationType')
            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_ == 'Tool':
            obj_ = cybox_common_binding.ToolInformationType.factory()
            obj_.build(child_)
            self.Tool.append(obj_)
# end class Resource_ToolsType


class Resource_InfrastructureType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Description=None, ObservableCharacterization=None):
        self.Description = Description
        self.ObservableCharacterization = ObservableCharacterization
    def factory(*args_, **kwargs_):
        if Resource_InfrastructureType.subclass:
            return Resource_InfrastructureType.subclass(*args_, **kwargs_)
        else:
            return Resource_InfrastructureType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Description(self): return self.Description
    def set_Description(self, Description): self.Description = Description
    def get_ObservableCharacterization(self): return self.ObservableCharacterization
    def set_ObservableCharacterization(self, ObservableCharacterization): self.ObservableCharacterization = ObservableCharacterization
    def export(self, outfile, level, namespace_='TTP:', name_='Resource-InfrastructureType', 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_='Resource-InfrastructureType')
        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_='TTP:', name_='Resource-InfrastructureType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='Resource-InfrastructureType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Description is not None:
            self.Description.export(outfile, level, namespace_, name_='Description', pretty_print=pretty_print)
        if self.ObservableCharacterization is not None:
            self.ObservableCharacterization.export(outfile, level, namespace_, name_='ObservableCharacterization', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Description is not None or
            self.ObservableCharacterization is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='Resource-InfrastructureType'):
        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.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.ObservableCharacterization is not None:
            showIndent(outfile, level)
            outfile.write('ObservableCharacterization=model_.ObservablesType(\n')
            self.ObservableCharacterization.exportLiteral(outfile, level, name_='ObservableCharacterization')
            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_ == 'Description':
            obj_ = cybox_common_binding.StructuredTextType.factory()
            obj_.build(child_)
            self.set_Description(obj_)
        elif nodeName_ == 'ObservableCharacterization':
            class_obj_ = self.get_class_obj_(child_, cybox_core_binding.ObservablesType)
            obj_ = class_obj_.factory()
            obj_.build(child_)
            self.set_ObservableCharacterization(obj_)
# end class Resource_InfrastructureType


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_='TTP:', 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_='TTP:', name_='ExploitTargetsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', 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 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_='TTP:', 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_='TTP:', name_='RelatedTTPsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', 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 KillChainPhasesType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, KillChainPhase=None):
        if KillChainPhase is None:
            self.KillChainPhase = []
        else:
            self.KillChainPhase = KillChainPhase
    def factory(*args_, **kwargs_):
        if KillChainPhasesType.subclass:
            return KillChainPhasesType.subclass(*args_, **kwargs_)
        else:
            return KillChainPhasesType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_KillChainPhase(self): return self.KillChainPhase
    def set_KillChainPhase(self, KillChainPhase): self.KillChainPhase = KillChainPhase
    def add_KillChainPhase(self, value): self.KillChainPhase.append(value)
    def insert_KillChainPhase(self, index, value): self.KillChainPhase[index] = value
    def export(self, outfile, level, namespace_='TTP:', name_='KillChainPhasesType', 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_='KillChainPhasesType')
        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_='TTP:', name_='KillChainPhasesType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='KillChainPhasesType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for KillChainPhase_ in self.KillChainPhase:
            KillChainPhase_.export(outfile, level, namespace_, name_='KillChainPhase', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.KillChainPhase
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='KillChainPhasesType'):
        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('KillChainPhase=[\n')
        level += 1
        for KillChainPhase_ in self.KillChainPhase:
            showIndent(outfile, level)
            outfile.write('model_.KillChainPhaseType(\n')
            KillChainPhase_.exportLiteral(outfile, level, name_='KillChainPhaseType')
            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_ == 'KillChainPhase':
            obj_ = KillChainPhaseType.factory()
            obj_.build(child_)
            self.KillChainPhase.append(obj_)
# end class KillChainPhasesType


class KillChainPhaseType(stix_common_binding.KillChainPhaseType):
    """This field specifies the ID for the relevant defined kill chain.This
    field specifies the descriptive name of the relevant kill chain."""
    subclass = None
    superclass = stix_common_binding.KillChainPhaseType
    def __init__(self, phaseID=None, ordinality=None, name=None, killChainName=None, killChainID=None):
        super(KillChainPhaseType, self).__init__(phaseID, ordinality, name, )
        self.killChainName = _cast(None, killChainName)
        self.killChainID = _cast(None, killChainID)
        pass
    def factory(*args_, **kwargs_):
        if KillChainPhaseType.subclass:
            return KillChainPhaseType.subclass(*args_, **kwargs_)
        else:
            return KillChainPhaseType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_killChainName(self): return self.killChainName
    def set_killChainName(self, killChainName): self.killChainName = killChainName
    def get_killChainID(self): return self.killChainID
    def set_killChainID(self, killChainID): self.killChainID = killChainID
    def export(self, outfile, level, namespace_='TTP:', name_='KillChainPhaseType', 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_='KillChainPhaseType')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            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_='TTP:', name_='KillChainPhaseType'):
        super(KillChainPhaseType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='KillChainPhaseType')
        if self.killChainName is not None and 'killChainName' not in already_processed:
            already_processed.append('killChainName')
            outfile.write(' killChainName=%s' % (self.gds_format_string(quote_attrib(self.killChainName).encode(ExternalEncoding), input_name='killChainName'), ))
        if self.killChainID is not None and 'killChainID' not in already_processed:
            already_processed.append('killChainID')
            outfile.write(' killChainID=%s' % (quote_attrib(self.killChainID), ))
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='KillChainPhaseType', fromsubclass_=False, pretty_print=True):
        super(KillChainPhaseType, self).exportChildren(outfile, level, namespace_, name_, True, pretty_print=pretty_print)
        pass
    def hasContent_(self):
        if (
            super(KillChainPhaseType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='KillChainPhaseType'):
        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.killChainName is not None and 'killChainName' not in already_processed:
            already_processed.append('killChainName')
            showIndent(outfile, level)
            outfile.write('killChainName = "%s",\n' % (self.killChainName,))
        if self.killChainID is not None and 'killChainID' not in already_processed:
            already_processed.append('killChainID')
            showIndent(outfile, level)
            outfile.write('killChainID = %s,\n' % (self.killChainID,))
        super(KillChainPhaseType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(KillChainPhaseType, self).exportLiteralChildren(outfile, level, name_)
        pass
    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_('killChainName', node)
        if value is not None and 'killChainName' not in already_processed:
            already_processed.append('killChainName')
            self.killChainName = value
        value = find_attr_value_('killChainID', node)
        if value is not None and 'killChainID' not in already_processed:
            already_processed.append('killChainID')
            self.killChainID = value
        super(KillChainPhaseType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        super(KillChainPhaseType, self).buildChildren(child_, node, nodeName_, True)
        pass
# end class KillChainPhaseType


class KillChainsType(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, KillChain=None):
        self.KillChain = KillChain
    def factory(*args_, **kwargs_):
        if KillChainsType.subclass:
            return KillChainsType.subclass(*args_, **kwargs_)
        else:
            return KillChainsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_KillChain(self): return self.KillChain
    def set_KillChain(self, KillChain): self.KillChain = KillChain
    def export(self, outfile, level, namespace_='TTP:', name_='KillChainsType', 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_='KillChainsType')
        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_='TTP:', name_='KillChainsType'):
        pass
    def exportChildren(self, outfile, level, namespace_='TTP:', name_='KillChainsType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.KillChain is not None:
            self.KillChain.export(outfile, level, namespace_, name_='KillChain', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.KillChain is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='KillChainsType'):
        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.KillChain is not None:
            showIndent(outfile, level)
            outfile.write('KillChain=model_.KillChainType(\n')
            self.KillChain.exportLiteral(outfile, level, name_='KillChain')
            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_ == 'KillChain':
            obj_ = stix_common_binding.KillChainType.factory()
            obj_.build(child_)
            self.set_KillChain(obj_)
# end class KillChainsType




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

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