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

#
# Generated Mon Apr 09 15:16:36 2012 by generateDS.py version 2.7b.
#

import sys
import getopt
import re as re_
import common_types_1_0 as common
import cybox.address_object_1_1 as address_object
import cybox.port_object_1_2 as port_object

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):
    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):
        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)
    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 ProcessObjectType(common.DefinedObjectType):
    """The ProcessObjectType type is intended to characterize system
    processes.The hidden attribute specifies whether the process is
    hidden or not."""
    subclass = None
    superclass = common.DefinedObjectType
    def __init__(self, is_hidden=None, PID=None, Name=None, Path=None, Current_Working_Directory=None, Creation_Time=None, Parent_PID=None, Child_PID_List=None, Argument_List=None, Environment_Variable_List=None, Image_Info=None, Kernel_Time=None, Port_List=None, Network_Connection_List=None, Start_Time=None, Status=None, String_List=None, Username=None, User_Time=None):
        super(ProcessObjectType, self).__init__(None)
        self.is_hidden = _cast(bool, is_hidden)
        self.PID = PID
        self.Name = Name
        self.Path = Path
        self.Current_Working_Directory = Current_Working_Directory
        self.Creation_Time = Creation_Time
        self.Parent_PID = Parent_PID
        self.Child_PID_List = Child_PID_List
        self.Argument_List = Argument_List
        self.Environment_Variable_List = Environment_Variable_List
        self.Image_Info = Image_Info
        self.Kernel_Time = Kernel_Time
        self.Port_List = Port_List
        self.Network_Connection_List = Network_Connection_List
        self.Start_Time = Start_Time
        self.Status = Status
        self.String_List = String_List
        self.Username = Username
        self.User_Time = User_Time
    def factory(*args_, **kwargs_):
        if ProcessObjectType.subclass:
            return ProcessObjectType.subclass(*args_, **kwargs_)
        else:
            return ProcessObjectType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_PID(self): return self.PID
    def set_PID(self, PID): self.PID = PID
    def get_Name(self): return self.Name
    def set_Name(self, Name): self.Name = Name
    def get_Path(self): return self.Path
    def set_Path(self, Path): self.Path = Path
    def get_Current_Working_Directory(self): return self.Current_Working_Directory
    def set_Current_Working_Directory(self, Current_Working_Directory): self.Current_Working_Directory = Current_Working_Directory
    def get_Creation_Time(self): return self.Creation_Time
    def set_Creation_Time(self, Creation_Time): self.Creation_Time = Creation_Time
    def get_Parent_PID(self): return self.Parent_PID
    def set_Parent_PID(self, Parent_PID): self.Parent_PID = Parent_PID
    def get_Child_PID_List(self): return self.Child_PID_List
    def set_Child_PID_List(self, Child_PID_List): self.Child_PID_List = Child_PID_List
    def get_Argument_List(self): return self.Argument_List
    def set_Argument_List(self, Argument_List): self.Argument_List = Argument_List
    def get_Environment_Variable_List(self): return self.Environment_Variable_List
    def set_Environment_Variable_List(self, Environment_Variable_List): self.Environment_Variable_List = Environment_Variable_List
    def get_Image_Info(self): return self.Image_Info
    def set_Image_Info(self, Image_Info): self.Image_Info = Image_Info
    def get_Kernel_Time(self): return self.Kernel_Time
    def set_Kernel_Time(self, Kernel_Time): self.Kernel_Time = Kernel_Time
    def get_Port_List(self): return self.Port_List
    def set_Port_List(self, Port_List): self.Port_List = Port_List
    def get_Network_Connection_List(self): return self.Network_Connection_List
    def set_Network_Connection_List(self, Network_Connection_List): self.Network_Connection_List = Network_Connection_List
    def get_Start_Time(self): return self.Start_Time
    def set_Start_Time(self, Start_Time): self.Start_Time = Start_Time
    def get_Status(self): return self.Status
    def set_Status(self, Status): self.Status = Status
    def get_String_List(self): return self.String_List
    def set_String_List(self, String_List): self.String_List = String_List
    def get_Username(self): return self.Username
    def set_Username(self, Username): self.Username = Username
    def get_User_Time(self): return self.User_Time
    def set_User_Time(self, User_Time): self.User_Time = User_Time
    def get_is_hidden(self): return self.is_hidden
    def set_is_hidden(self, is_hidden): self.is_hidden = is_hidden
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ProcessObjectType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ProcessObjectType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, 'ProcessObj:', name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ProcessObjectType'):
        super(ProcessObjectType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='ProcessObjectType')
        if self.is_hidden is not None and 'is_hidden' not in already_processed:
            already_processed.append('is_hidden')
            outfile.write(' is_hidden="%s"' % self.gds_format_boolean(self.gds_str_lower(str(self.is_hidden)), input_name='is_hidden'))
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ProcessObjectType', fromsubclass_=False):
        if self.PID is not None:
            self.PID.export(outfile, level, namespace_, name_='PID')
        if self.Name is not None:
            self.Name.export(outfile, level, namespace_, name_='Name')
        if self.Path is not None:
            self.Path.export(outfile, level, namespace_, name_='Path')
        if self.Current_Working_Directory is not None:
            self.Current_Working_Directory.export(outfile, level, namespace_, name_='Current_Working_Directory')
        if self.Creation_Time is not None:
            self.Creation_Time.export(outfile, level, namespace_, name_='Creation_Time')
        if self.Parent_PID is not None:
            self.Parent_PID.export(outfile, level, namespace_, name_='Parent_PID')
        if self.Child_PID_List is not None:
            self.Child_PID_List.export(outfile, level, namespace_, name_='Child_PID_List')
        if self.Argument_List is not None:
            self.Argument_List.export(outfile, level, namespace_, name_='Argument_List')
        if self.Environment_Variable_List is not None:
            self.Environment_Variable_List.export(outfile, level, namespace_, name_='Environment_Variable_List')
        if self.Image_Info is not None:
            self.Image_Info.export(outfile, level, namespace_, name_='Image_Info')
        if self.Kernel_Time is not None:
            self.Kernel_Time.export(outfile, level, namespace_, name_='Kernel_Time')
        if self.Port_List is not None:
            self.Port_List.export(outfile, level, namespace_, name_='Port_List')
        if self.Network_Connection_List is not None:
            self.Network_Connection_List.export(outfile, level, namespace_, name_='Network_Connection_List')
        if self.Start_Time is not None:
            self.Start_Time.export(outfile, level, namespace_, name_='Start_Time')
        if self.Status is not None:
            self.Status.export(outfile, level, namespace_, name_='Status')
        if self.String_List is not None:
            self.String_List.export(outfile, level, namespace_, name_='String_List')
        if self.Username is not None:
            self.Username.export(outfile, level, namespace_, name_='Username')
        if self.User_Time is not None:
            self.User_Time.export(outfile, level, namespace_, name_='User_Time')
    def hasContent_(self):
        if (
            self.PID is not None or
            self.Name is not None or
            self.Path is not None or
            self.Current_Working_Directory is not None or
            self.Creation_Time is not None or
            self.Parent_PID is not None or
            self.Child_PID_List is not None or
            self.Argument_List is not None or
            self.Environment_Variable_List is not None or
            self.Image_Info is not None or
            self.Kernel_Time is not None or
            self.Port_List is not None or
            self.Network_Connection_List is not None or
            self.Start_Time is not None or
            self.Status is not None or
            self.String_List is not None or
            self.Username is not None or
            self.User_Time is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ProcessObjectType'):
        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.is_hidden is not None and 'is_hidden' not in already_processed:
            already_processed.append('is_hidden')
            showIndent(outfile, level)
            outfile.write('is_hidden = %s,\n' % (self.is_hidden,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.PID is not None:
            showIndent(outfile, level)
            outfile.write('PID=%s,\n' % quote_python(self.PID).encode(ExternalEncoding))
        if self.Name is not None:
            showIndent(outfile, level)
            outfile.write('Name=%s,\n' % quote_python(self.Name).encode(ExternalEncoding))
        if self.Path is not None:
            showIndent(outfile, level)
            outfile.write('Path=%s,\n' % quote_python(self.Path).encode(ExternalEncoding))
        if self.Current_Working_Directory is not None:
            showIndent(outfile, level)
            outfile.write('Current_Working_Directory=%s,\n' % quote_python(self.Current_Working_Directory).encode(ExternalEncoding))
        if self.Creation_Time is not None:
            showIndent(outfile, level)
            outfile.write('Creation_Time=%s,\n' % quote_python(self.Creation_Time).encode(ExternalEncoding))
        if self.Parent_PID is not None:
            showIndent(outfile, level)
            outfile.write('Parent_PID=%s,\n' % quote_python(self.Parent_PID).encode(ExternalEncoding))
        if self.Child_PID_List is not None:
            showIndent(outfile, level)
            outfile.write('Child_PID_List=model_.ChildPIDListType(\n')
            self.Child_PID_List.exportLiteral(outfile, level, name_='Child_PID_List')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Argument_List is not None:
            showIndent(outfile, level)
            outfile.write('Argument_List=model_.ArgumentListType(\n')
            self.Argument_List.exportLiteral(outfile, level, name_='Argument_List')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Environment_Variable_List is not None:
            showIndent(outfile, level)
            outfile.write('Environment_Variable_List=%s,\n' % quote_python(self.Environment_Variable_List).encode(ExternalEncoding))
        if self.Image_Info is not None:
            showIndent(outfile, level)
            outfile.write('Image_Info=model_.ImageInfoType(\n')
            self.Image_Info.exportLiteral(outfile, level, name_='Image_Info')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Kernel_Time is not None:
            showIndent(outfile, level)
            outfile.write('Kernel_Time=%s,\n' % quote_python(self.Kernel_Time).encode(ExternalEncoding))
        if self.Port_List is not None:
            showIndent(outfile, level)
            outfile.write('Port_List=model_.PortListType(\n')
            self.Port_List.exportLiteral(outfile, level, name_='Port_List')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Network_Connection_List is not None:
            showIndent(outfile, level)
            outfile.write('Network_Connection_List=model_.NetworkConnectionListType(\n')
            self.Network_Connection_List.exportLiteral(outfile, level, name_='Network_Connection_List')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Start_Time is not None:
            showIndent(outfile, level)
            outfile.write('Start_Time=%s,\n' % quote_python(self.Start_Time).encode(ExternalEncoding))
        if self.ProcessStatusType is not None:
            showIndent(outfile, level)
            outfile.write('ProcessStatusType=model_.ProcessStatusType(\n')
            self.ProcessStatusType.exportLiteral(outfile, level)
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.String_List is not None:
            showIndent(outfile, level)
            outfile.write('String_List=%s,\n' % quote_python(self.String_List).encode(ExternalEncoding))
        if self.Username is not None:
            showIndent(outfile, level)
            outfile.write('Username=%s,\n' % quote_python(self.Username).encode(ExternalEncoding))
        if self.User_Time is not None:
            showIndent(outfile, level)
            outfile.write('User_Time=%s,\n' % quote_python(self.User_Time).encode(ExternalEncoding))
    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_('is_hidden', node)
        if value is not None and 'is_hidden' not in already_processed:
            already_processed.append('is_hidden')
            if value in ('true', '1'):
                self.is_hidden = True
            elif value in ('false', '0'):
                self.is_hidden = False
            else:
                raise_parse_error(node, 'Bad boolean attribute')
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'PID':
            PID_ = common.UnsignedIntegerObjectAttributeType.factory()
            PID_.build(child_)
            self.PID = PID_
        elif nodeName_ == 'Name':
            Name_ = common.StringObjectAttributeType.factory()
            Name_.build(child_)
            self.Name = Name_
        elif nodeName_ == 'Path':
            Path_ = common.StringObjectAttributeType.factory()
            Path_.build(child_)
            self.Path = Path_
        elif nodeName_ == 'Current_Working_Directory':
            Current_Working_Directory_ = common.StringObjectAttributeType.factory()
            Current_Working_Directory_.build(child_)
            self.Current_Working_Directory = Current_Working_Directory_
        elif nodeName_ == 'Creation_Time':
            Creation_Time_ = common.DateTimeObjectAttributeType.factory()
            Creation_Time_.build(child_)
            self.Creation_Time = Creation_Time_
        elif nodeName_ == 'Parent_PID':
            Parent_PID_ = common.UnsignedIntegerObjectAttributeType.factory()
            Parent_PID_.build(child_)
            self.Parent_PID = Parent_PID_
        elif nodeName_ == 'Child_PID_List':
            obj_ = ChildPIDListType.factory()
            obj_.build(child_)
            self.set_Child_PID_List(obj_)
        elif nodeName_ == 'Argument_List':
            obj_ = ArgumentListType.factory()
            obj_.build(child_)
            self.set_Argument_List(obj_)
        elif nodeName_ == 'Environment_Variable_List':
            Environment_Variable_List_ = common.StringObjectAttributeType.factory()
            Environment_Variable_List_.build(child_)
            self.Environment_Variable_List = Environment_Variable_List_
        elif nodeName_ == 'Image_Info':
            obj_ = ImageInfoType.factory()
            obj_.build(child_)
            self.set_Image_Info(obj_)
        elif nodeName_ == 'Kernel_Time':
            Kernel_Time_ = common.DurationObjectAttributeType.factory()
            Kernel_Time_.build(child_)
            self.Kernel_Time = Kernel_Time_
        elif nodeName_ == 'Port_List':
            obj_ = PortListType.factory()
            obj_.build(child_)
            self.set_Port_List(obj_)
        elif nodeName_ == 'Network_Connection_List':
            obj_ = NetworkConnectionListType.factory()
            obj_.build(child_)
            self.set_Network_Connection_List(obj_)
        elif nodeName_ == 'Start_Time':
            Start_Time_ = common.DateTimeObjectAttributeType.factory()
            Start_Time_.build(child_)
            self.Start_Time = Start_Time_
        elif nodeName_ == 'Status':
            type_name_ = child_.attrib.get('{http://www.w3.org/2001/XMLSchema-instance}type')
            if type_name_ is None:
                type_name_ = child_.attrib.get('type')
            if type_name_ is not None:
                type_names_ = type_name_.split(':')
                if len(type_names_) == 1:
                    type_name_ = type_names_[0]
                else:
                    type_name_ = type_names_[1]
                class_ = globals()[type_name_]
                obj_ = class_.factory()
                obj_.build(child_)
            else:
                raise NotImplementedError(
                    'Class not implemented for <Status> element')
            self.set_Status(obj_)
        elif nodeName_ == 'String_List':
            String_List_ =  common.ExtractedStringsType.factory()
            String_List_.build(child_)
            self.String_List = String_List_
        elif nodeName_ == 'Username':
            Username_ = common.StringObjectAttributeType.factory()
            Username_.build(child_)
            self.Username = Username_
        elif nodeName_ == 'User_Time':
            User_Time_ = common.DurationObjectAttributeType.factory()
            User_Time_.build(child_)
            self.User_Time = User_Time_
        super(ProcessObjectType, self).buildChildren(child_, node, nodeName_, True)
# end class ProcessObjectType


class NetworkConnectionType(GeneratedsSuper):
    """The NetworkConnectionType type captures the critical information
    about a TCP or UDP network connection."""
    subclass = None
    superclass = None
    def __init__(self, Creation_Time=None, Destination_IP_Address=None, Destination_Port=None, Source_IP_Address=None, Source_Port=None, TCP_State=None):
        self.Creation_Time = Creation_Time
        self.Destination_IP_Address = Destination_IP_Address
        self.Destination_Port = Destination_Port
        self.Source_IP_Address = Source_IP_Address
        self.Source_Port = Source_Port
        self.TCP_State = TCP_State
    def factory(*args_, **kwargs_):
        if NetworkConnectionType.subclass:
            return NetworkConnectionType.subclass(*args_, **kwargs_)
        else:
            return NetworkConnectionType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Creation_Time(self): return self.Creation_Time
    def set_Creation_Time(self, Creation_Time): self.Creation_Time = Creation_Time
    def get_Destination_IP_Address(self): return self.Destination_IP_Address
    def set_Destination_IP_Address(self, Destination_IP_Address): self.Destination_IP_Address = Destination_IP_Address
    def get_Destination_Port(self): return self.Destination_Port
    def set_Destination_Port(self, Destination_Port): self.Destination_Port = Destination_Port
    def get_Source_IP_Address(self): return self.Source_IP_Address
    def set_Source_IP_Address(self, Source_IP_Address): self.Source_IP_Address = Source_IP_Address
    def get_Source_Port(self): return self.Source_Port
    def set_Source_Port(self, Source_Port): self.Source_Port = Source_Port
    def get_TCP_State(self): return self.TCP_State
    def set_TCP_State(self, TCP_State): self.TCP_State = TCP_State
    def validate_ConnectionStateType(self, value):
        # Validate type ConnectionStateType, a restriction on None.
        pass
    def export(self, outfile, level, namespace_='ProcessObj:', name_='NetworkConnectionType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='NetworkConnectionType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='NetworkConnectionType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='NetworkConnectionType', fromsubclass_=False):
        if self.Creation_Time is not None:
            self.Creation_Time.export(outfile, level, namespace_, name_='Creation_Time')
        if self.Destination_IP_Address is not None:
            self.Destination_IP_Address.export(outfile, level, namespace_, name_='Destination_IP_Address')
        if self.Destination_Port is not None:
            self.Destination_Port.export(outfile, level, namespace_, name_='Destination_Port')
        if self.Source_IP_Address is not None:
            self.Source_IP_Address.export(outfile, level, namespace_, name_='Source_IP_Address')
        if self.Source_Port is not None:
            self.Source_Port.export(outfile, level, namespace_, name_='Source_Port')
        if self.TCP_State is not None:
            self.TCP_State.export(outfile, level, namespace_, name_='TCP_State')
    def hasContent_(self):
        if (
            self.Creation_Time is not None or
            self.Destination_IP_Address is not None or
            self.Destination_Port is not None or
            self.Source_IP_Address is not None or
            self.Source_Port is not None or
            self.TCP_State is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='NetworkConnectionType'):
        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.Creation_Time is not None:
            showIndent(outfile, level)
            outfile.write('Creation_Time=%s,\n' % quote_python(self.Creation_Time).encode(ExternalEncoding))
        if self.Destination_IP_Address is not None:
            showIndent(outfile, level)
            outfile.write('Destination_IP_Address=%s,\n' % quote_python(self.Destination_IP_Address).encode(ExternalEncoding))
        if self.Destination_Port is not None:
            showIndent(outfile, level)
            outfile.write('Destination_Port=%s,\n' % quote_python(self.Destination_Port).encode(ExternalEncoding))
        if self.Source_IP_Address is not None:
            showIndent(outfile, level)
            outfile.write('Source_IP_Address=%s,\n' % quote_python(self.Source_IP_Address).encode(ExternalEncoding))
        if self.Source_Port is not None:
            showIndent(outfile, level)
            outfile.write('Source_Port=%s,\n' % quote_python(self.Source_Port).encode(ExternalEncoding))
        if self.TCP_State is not None:
            showIndent(outfile, level)
            outfile.write('TCP_State=model_.ConnectionStateType(\n')
            self.TCP_State.exportLiteral(outfile, level, name_='TCP_State')
            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_ == 'Creation_Time':
            Creation_Time_ = common.DateTimeObjectAttributeType.factory()
            Creation_Time_.build(child_)
            self.Creation_Time = Creation_Time_
        elif nodeName_ == 'Destination_IP_Address':
            Destination_IP_Address_ = address_object.AddressObjectType.factory()
            Destination_IP_Address_.build(child_)
            self.Destination_IP_Address = Destination_IP_Address_
        elif nodeName_ == 'Destination_Port':
            Destination_Port_ = port_object.PortObjectType.factory()
            Destination_Port_.build(child_)
            self.Destination_Port = Destination_Port_
        elif nodeName_ == 'Source_IP_Address':
            Source_IP_Address_ = address_object.AddressObjectType.factory()
            Source_IP_Address_.build(child_)
            self.Source_IP_Address = Source_IP_Address_
        elif nodeName_ == 'Source_Port':
            Source_Port_ = port_object.PortObjectType.factory()
            Source_Port_.build(child_)
            self.Source_Port = Source_Port_
        elif nodeName_ == 'TCP_State':
            obj_ = common.StringObjectAttributeType.factory()
            obj_.build(child_)
            self.set_TCP_State(obj_)
            self.validate_ConnectionStateType(self.TCP_State)    # validate type ConnectionStateType
# end class NetworkConnectionType


class NetworkConnectionListType(GeneratedsSuper):
    """The NetworkConnectionListType type is a list of network connections."""
    subclass = None
    superclass = None
    def __init__(self, Network_Connection=None):
        if Network_Connection is None:
            self.Network_Connection = []
        else:
            self.Network_Connection = Network_Connection
    def factory(*args_, **kwargs_):
        if NetworkConnectionListType.subclass:
            return NetworkConnectionListType.subclass(*args_, **kwargs_)
        else:
            return NetworkConnectionListType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Network_Connection(self): return self.Network_Connection
    def set_Network_Connection(self, Network_Connection): self.Network_Connection = Network_Connection
    def add_Network_Connection(self, value): self.Network_Connection.append(value)
    def insert_Network_Connection(self, index, value): self.Network_Connection[index] = value
    def export(self, outfile, level, namespace_='ProcessObj:', name_='NetworkConnectionListType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='NetworkConnectionListType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='NetworkConnectionListType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='NetworkConnectionListType', fromsubclass_=False):
        for Network_Connection_ in self.Network_Connection:
            Network_Connection_.export(outfile, level, namespace_, name_='Network_Connection')
    def hasContent_(self):
        if (
            self.Network_Connection
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='NetworkConnectionListType'):
        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('Network_Connection=[\n')
        level += 1
        for Network_Connection_ in self.Network_Connection:
            showIndent(outfile, level)
            outfile.write('model_.NetworkConnectionType(\n')
            Network_Connection_.exportLiteral(outfile, level, name_='NetworkConnectionType')
            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_ == 'Network_Connection':
            obj_ = NetworkConnectionType.factory()
            obj_.build(child_)
            self.Network_Connection.append(obj_)
# end class NetworkConnectionListType


class ImageInfoType(GeneratedsSuper):
    """The ImageInfoType type captures information about the process image."""
    subclass = None
    superclass = None
    def __init__(self, Command_Line=None, Current_Directory=None, Path=None):
        self.Command_Line = Command_Line
        self.Current_Directory = Current_Directory
        self.Path = Path
    def factory(*args_, **kwargs_):
        if ImageInfoType.subclass:
            return ImageInfoType.subclass(*args_, **kwargs_)
        else:
            return ImageInfoType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Command_Line(self): return self.Command_Line
    def set_Command_Line(self, Command_Line): self.Command_Line = Command_Line
    def get_Current_Directory(self): return self.Current_Directory
    def set_Current_Directory(self, Current_Directory): self.Current_Directory = Current_Directory
    def get_Path(self): return self.Path
    def set_Path(self, Path): self.Path = Path
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ImageInfoType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ImageInfoType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ImageInfoType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ImageInfoType', fromsubclass_=False):
        if self.Command_Line is not None:
            self.Command_Line.export(outfile, level, namespace_, name_='Command_Line')
        if self.Current_Directory is not None:
            self.Current_Directory.export(outfile, level, namespace_, name_='Current_Directory')
        if self.Path is not None:
            self.Path.export(outfile, level, namespace_, name_='Path')
    def hasContent_(self):
        if (
            self.Command_Line is not None or
            self.Current_Directory is not None or
            self.Path is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ImageInfoType'):
        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.Command_Line is not None:
            showIndent(outfile, level)
            outfile.write('Command_Line=%s,\n' % quote_python(self.Command_Line).encode(ExternalEncoding))
        if self.Current_Directory is not None:
            showIndent(outfile, level)
            outfile.write('Current_Directory=%s,\n' % quote_python(self.Current_Directory).encode(ExternalEncoding))
        if self.Path is not None:
            showIndent(outfile, level)
            outfile.write('Path=%s,\n' % quote_python(self.Path).encode(ExternalEncoding))
    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_ == 'Command_Line':
            Command_Line_ = common.StringObjectAttributeType.factory()
            Command_Line_.build(child_)
            self.Command_Line = Command_Line_
        elif nodeName_ == 'Current_Directory':
            Current_Directory_ = common.StringObjectAttributeType.factory()
            Current_Directory_.build(child_)
            self.Current_Directory = Current_Directory_
        elif nodeName_ == 'Path':
            Path_ = common.StringObjectAttributeType.factory()
            Path_.build(child_)
            self.Path = Path_
# end class ImageInfoType


class ProcessStatusType(GeneratedsSuper):
    """The ProcessStatusType is used for specifying the status of a running
    or terminated process. Since this property is platform-specific,
    it is created here as an abstract type and then used in the
    platform-specific process CybOX objects."""
    subclass = None
    superclass = None
    def __init__(self):
        pass
    def factory(*args_, **kwargs_):
        if ProcessStatusType.subclass:
            return ProcessStatusType.subclass(*args_, **kwargs_)
        else:
            return ProcessStatusType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ProcessStatusType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ProcessStatusType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ProcessStatusType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ProcessStatusType', fromsubclass_=False):
        pass
    def hasContent_(self):
        if (

            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ProcessStatusType'):
        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_):
        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):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class ProcessStatusType


class ChildPIDListType(GeneratedsSuper):
    """The ChildPIDListType type captures the PID's of the children of the
    process in a list format."""
    subclass = None
    superclass = None
    def __init__(self, Child_PID=None):
        if Child_PID is None:
            self.Child_PID = []
        else:
            self.Child_PID = Child_PID
    def factory(*args_, **kwargs_):
        if ChildPIDListType.subclass:
            return ChildPIDListType.subclass(*args_, **kwargs_)
        else:
            return ChildPIDListType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Child_PID(self): return self.Child_PID
    def set_Child_PID(self, Child_PID): self.Child_PID = Child_PID
    def add_Child_PID(self, value): self.Child_PID.append(value)
    def insert_Child_PID(self, index, value): self.Child_PID[index] = value
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ChildPIDListType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ChildPIDListType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ChildPIDListType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ChildPIDListType', fromsubclass_=False):
        for Child_PID_ in self.Child_PID:
            Child_PID_.export(outfile, level, namespace_, name_='Child_PID')
    def hasContent_(self):
        if (
            self.Child_PID
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ChildPIDListType'):
        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('Child_PID=[\n')
        level += 1
        for Child_PID_ in self.Child_PID:
            showIndent(outfile, level)
            outfile.write('%s,\n' % quote_python(Child_PID_).encode(ExternalEncoding))
        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_ == 'Child_PID':
            Child_PID_ = common.UnsignedIntegerObjectAttributeType.factory()
            Child_PID_.build(child_)
            self.Child_PID.append(Child_PID_)
# end class ChildPIDListType


class ConnectionStateType(GeneratedsSuper):
    """ConnectionStateType specifies connection states, via a union of the
    ConnectionStateEnum type and the atomic xs:string type. Its base
    type is the CybOX Core BaseObjectAttributeType, for permitting
    complex (i.e. regular-expression based) specifications.This
    attribute is optional and specifies the expected type for the
    value of the specified element."""
    subclass = None
    superclass = None
    def __init__(self, datatype=None, valueOf_=None):
        self.datatype = _cast(None, datatype)
        self.valueOf_ = valueOf_
    def factory(*args_, **kwargs_):
        if ConnectionStateType.subclass:
            return ConnectionStateType.subclass(*args_, **kwargs_)
        else:
            return ConnectionStateType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_datatype(self): return self.datatype
    def set_datatype(self, datatype): self.datatype = datatype
    def get_valueOf_(self): return self.valueOf_
    def set_valueOf_(self, valueOf_): self.valueOf_ = valueOf_
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ConnectionStateType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ConnectionStateType')
        if self.hasContent_():
            outfile.write('>')
            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
            self.exportChildren(outfile, level + 1, namespace_, name_)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ConnectionStateType'):
        if self.datatype is not None and 'datatype' not in already_processed:
            already_processed.append('datatype')
            outfile.write(' datatype=%s' % (quote_attrib(self.datatype), ))
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ConnectionStateType', fromsubclass_=False):
        pass
    def hasContent_(self):
        if (
            self.valueOf_
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ConnectionStateType'):
        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.datatype is not None and 'datatype' not in already_processed:
            already_processed.append('datatype')
            showIndent(outfile, level)
            outfile.write('datatype = %s,\n' % (self.datatype,))
    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_('datatype', node)
        if value is not None and 'datatype' not in already_processed:
            already_processed.append('datatype')
            self.datatype = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class ConnectionStateType


class ArgumentListType(GeneratedsSuper):
    """The ArgumentListType is intended to specify a list of arguments
    utlized in intiating the process."""
    subclass = None
    superclass = None
    def __init__(self, Argument=None):
        self.Argument = Argument
    def factory(*args_, **kwargs_):
        if ArgumentListType.subclass:
            return ArgumentListType.subclass(*args_, **kwargs_)
        else:
            return ArgumentListType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Argument(self): return self.Argument
    def set_Argument(self, Argument): self.Argument = Argument
    def export(self, outfile, level, namespace_='ProcessObj:', name_='ArgumentListType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ArgumentListType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='ArgumentListType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='ArgumentListType', fromsubclass_=False):
        if self.Argument is not None:
            self.Argument.export(outfile, level, namespace_, name_='Argument')
    def hasContent_(self):
        if (
            self.Argument is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='ArgumentListType'):
        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.Argument is not None:
            showIndent(outfile, level)
            outfile.write('Argument=%s,\n' % quote_python(self.Argument).encode(ExternalEncoding))
    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_ == 'Argument':
            Argument_ = common.StringObjectAttributeType.factory()
            Argument_.build(child_)
            self.Argument = Argument_
# end class ArgumentListType


class PortListType(GeneratedsSuper):
    """The PortListType is intended to specify a list of network ports."""
    subclass = None
    superclass = None
    def __init__(self, Port=None):
        if Port is None:
            self.Port = []
        else:
            self.Port = Port
    def factory(*args_, **kwargs_):
        if PortListType.subclass:
            return PortListType.subclass(*args_, **kwargs_)
        else:
            return PortListType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Port(self): return self.Port
    def set_Port(self, Port): self.Port = Port
    def add_Port(self, value): self.Port.append(value)
    def insert_Port(self, index, value): self.Port[index] = value
    def export(self, outfile, level, namespace_='ProcessObj:', name_='PortListType', namespacedef_=''):
        showIndent(outfile, level)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = []
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='PortListType')
        if self.hasContent_():
            outfile.write('>\n')
            self.exportChildren(outfile, level + 1, namespace_, name_)
            showIndent(outfile, level)
            outfile.write('</%s%s>\n' % (namespace_, name_))
        else:
            outfile.write('/>\n')
    def exportAttributes(self, outfile, level, already_processed, namespace_='ProcessObj:', name_='PortListType'):
        pass
    def exportChildren(self, outfile, level, namespace_='ProcessObj:', name_='PortListType', fromsubclass_=False):
        for Port_ in self.Port:
            Port_.export(outfile, level, namespace_, name_='Port')
    def hasContent_(self):
        if (
            self.Port
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='PortListType'):
        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('Port=[\n')
        level += 1
        for Port_ in self.Port:
            showIndent(outfile, level)
            outfile.write('%s,\n' % quote_python(Port_).encode(ExternalEncoding))
        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_ == 'Port':
            Port_ = port_object.PortObjectType.factory()
            Port_.build(child_)
            self.Port.append(Port_)
# end class PortListType


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


def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Process'
        rootClass = ProcessObjectType
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    sys.stdout.write('#from process_object import *\n\n')
    sys.stdout.write('import process_object 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__ = [
    "ArgumentListType",
    "ChildPIDListType",
    "ConnectionStateType",
    "ImageInfoType",
    "NetworkConnectionListType",
    "NetworkConnectionType",
    "PortListType",
    "ProcessObjectType",
    "ProcessStatusType"
    ]
