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

#
# Generated Tue Nov 06 14:04:02 2012 by generateDS.py version 2.7c.
#

import sys
import getopt
import re as re_

import cybox_common_types_1_0
import file_object_1_3
import win_computer_account_object_1_3

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:
    if Verbose_import_:
        print('Error: LXML version 2.3+ required for parsing files')

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 = 'utf-8'
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 StreamListType(GeneratedsSuper):
    """The StreamListType type specifies a list of NTFS alternate data
    streams."""
    subclass = None
    superclass = None
    def __init__(self, Stream=None):
        if Stream is None:
            self.Stream = []
        else:
            self.Stream = Stream
    def factory(*args_, **kwargs_):
        if StreamListType.subclass:
            return StreamListType.subclass(*args_, **kwargs_)
        else:
            return StreamListType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Stream(self): return self.Stream
    def set_Stream(self, Stream): self.Stream = Stream
    def add_Stream(self, value): self.Stream.append(value)
    def insert_Stream(self, index, value): self.Stream[index] = value
    def export(self, outfile, level, namespace_='WinFileObj:', name_='StreamListType', 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_='StreamListType')
        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_='WinFileObj:', name_='StreamListType'):
        pass
    def exportChildren(self, outfile, level, namespace_='WinFileObj:', name_='StreamListType', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Stream_ in self.Stream:
            Stream_.export(outfile, level, 'WinFileObj:', name_='Stream', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Stream
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='StreamListType'):
        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('Stream=[\n')
        level += 1
        for Stream_ in self.Stream:
            showIndent(outfile, level)
            outfile.write('model_.StreamObjectType(\n')
            Stream_.exportLiteral(outfile, level, name_='StreamObjectType')
            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_ == 'Stream':
            obj_ = StreamObjectType.factory()
            obj_.build(child_)
            self.Stream.append(obj_)
# end class StreamListType

class WindowsFilePermissionsType(file_object_1_3.FilePermissionsType):
    """The WindowsFilePermissionsType type specifies Windows file
    permissions. It imports and extends the file_object_1_3.FilePermissionsType from
    the CybOX File Object."""
    subclass = None
    superclass = file_object_1_3.FilePermissionsType
    def __init__(self, Full_Control=None, Modify=None, Read=None, Read_And_Execute=None, Write=None):
        super(WindowsFilePermissionsType, self).__init__()
        self.Full_Control = Full_Control
        self.Modify = Modify
        self.Read = Read
        self.Read_And_Execute = Read_And_Execute
        self.Write = Write
    def factory(*args_, **kwargs_):
        if WindowsFilePermissionsType.subclass:
            return WindowsFilePermissionsType.subclass(*args_, **kwargs_)
        else:
            return WindowsFilePermissionsType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Full_Control(self): return self.Full_Control
    def set_Full_Control(self, Full_Control): self.Full_Control = Full_Control
    def get_Modify(self): return self.Modify
    def set_Modify(self, Modify): self.Modify = Modify
    def get_Read(self): return self.Read
    def set_Read(self, Read): self.Read = Read
    def get_Read_And_Execute(self): return self.Read_And_Execute
    def set_Read_And_Execute(self, Read_And_Execute): self.Read_And_Execute = Read_And_Execute
    def get_Write(self): return self.Write
    def set_Write(self, Write): self.Write = Write
    def export(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFilePermissionsType', 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_='WindowsFilePermissionsType')
        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_='WinFileObj:', name_='WindowsFilePermissionsType'):
        super(WindowsFilePermissionsType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='WindowsFilePermissionsType')
    def exportChildren(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFilePermissionsType', fromsubclass_=False, pretty_print=True):
        super(WindowsFilePermissionsType, self).exportChildren(outfile, level, 'WinFileObj:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Full_Control is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sFull_Control>%s</%sFull_Control>%s' % ('WinFileObj:', self.gds_format_boolean(self.gds_str_lower(str(self.Full_Control)), input_name='Full_Control'), 'WinFileObj:', eol_))
        if self.Modify is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sModify>%s</%sModify>%s' % ('WinFileObj:', self.gds_format_boolean(self.gds_str_lower(str(self.Modify)), input_name='Modify'), 'WinFileObj:', eol_))
        if self.Read is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sRead>%s</%sRead>%s' % ('WinFileObj:', self.gds_format_boolean(self.gds_str_lower(str(self.Read)), input_name='Read'), 'WinFileObj:', eol_))
        if self.Read_And_Execute is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sRead_And_Execute>%s</%sRead_And_Execute>%s' % ('WinFileObj:', self.gds_format_boolean(self.gds_str_lower(str(self.Read_And_Execute)), input_name='Read_And_Execute'), 'WinFileObj:', eol_))
        if self.Write is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sWrite>%s</%sWrite>%s' % ('WinFileObj:', self.gds_format_boolean(self.gds_str_lower(str(self.Write)), input_name='Write'), 'WinFileObj:', eol_))
    def hasContent_(self):
        if (
            self.Full_Control is not None or
            self.Modify is not None or
            self.Read is not None or
            self.Read_And_Execute is not None or
            self.Write is not None or
            super(WindowsFilePermissionsType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='WindowsFilePermissionsType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(WindowsFilePermissionsType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(WindowsFilePermissionsType, self).exportLiteralChildren(outfile, level, name_)
        if self.Full_Control is not None:
            showIndent(outfile, level)
            outfile.write('Full_Control=%s,\n' % self.Full_Control)
        if self.Modify is not None:
            showIndent(outfile, level)
            outfile.write('Modify=%s,\n' % self.Modify)
        if self.Read is not None:
            showIndent(outfile, level)
            outfile.write('Read=%s,\n' % self.Read)
        if self.Read_And_Execute is not None:
            showIndent(outfile, level)
            outfile.write('Read_And_Execute=%s,\n' % self.Read_And_Execute)
        if self.Write is not None:
            showIndent(outfile, level)
            outfile.write('Write=%s,\n' % self.Write)
    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(WindowsFilePermissionsType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Full_Control':
            sval_ = child_.text
            if sval_ in ('true', '1'):
                ival_ = True
            elif sval_ in ('false', '0'):
                ival_ = False
            else:
                raise_parse_error(child_, 'requires boolean')
            ival_ = self.gds_validate_boolean(ival_, node, 'Full_Control')
            self.Full_Control = ival_
        elif nodeName_ == 'Modify':
            sval_ = child_.text
            if sval_ in ('true', '1'):
                ival_ = True
            elif sval_ in ('false', '0'):
                ival_ = False
            else:
                raise_parse_error(child_, 'requires boolean')
            ival_ = self.gds_validate_boolean(ival_, node, 'Modify')
            self.Modify = ival_
        elif nodeName_ == 'Read':
            sval_ = child_.text
            if sval_ in ('true', '1'):
                ival_ = True
            elif sval_ in ('false', '0'):
                ival_ = False
            else:
                raise_parse_error(child_, 'requires boolean')
            ival_ = self.gds_validate_boolean(ival_, node, 'Read')
            self.Read = ival_
        elif nodeName_ == 'Read_And_Execute':
            sval_ = child_.text
            if sval_ in ('true', '1'):
                ival_ = True
            elif sval_ in ('false', '0'):
                ival_ = False
            else:
                raise_parse_error(child_, 'requires boolean')
            ival_ = self.gds_validate_boolean(ival_, node, 'Read_And_Execute')
            self.Read_And_Execute = ival_
        elif nodeName_ == 'Write':
            sval_ = child_.text
            if sval_ in ('true', '1'):
                ival_ = True
            elif sval_ in ('false', '0'):
                ival_ = False
            else:
                raise_parse_error(child_, 'requires boolean')
            ival_ = self.gds_validate_boolean(ival_, node, 'Write')
            self.Write = ival_
        super(WindowsFilePermissionsType, self).buildChildren(child_, node, nodeName_, True)
# end class WindowsFilePermissionsType

class WindowsFileAttributeType(cybox_common_types_1_0.BaseObjectAttributeType):
    """WindowsFileAttributeType specifies Windows file attributes via a
    union of the FileAttributesEnum type and the atomic xs:string
    type. Its base type is the CybOX Core cybox_common_types_1_0.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 = cybox_common_types_1_0.BaseObjectAttributeType
    def __init__(self, end_range=None, pattern_type=None, has_changed=None, value_set=None, datatype='String', refanging_transform=None, refanging_transform_type=None, appears_random=None, trend=None, defanging_algorithm_ref=None, is_obfuscated=None, regex_syntax=None, obfuscation_algorithm_ref=None, start_range=None, idref=None, is_defanged=None, id=None, condition=None, valueOf_=None):
        super(WindowsFileAttributeType, self).__init__(end_range, pattern_type, has_changed, value_set, datatype, refanging_transform, refanging_transform_type, appears_random, trend, defanging_algorithm_ref, is_obfuscated, regex_syntax, obfuscation_algorithm_ref, start_range, idref, is_defanged, id, condition, valueOf_, )
        self.datatype = _cast(None, datatype)
        self.valueOf_ = valueOf_
    def factory(*args_, **kwargs_):
        if WindowsFileAttributeType.subclass:
            return WindowsFileAttributeType.subclass(*args_, **kwargs_)
        else:
            return WindowsFileAttributeType(*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_='WinFileObj:', name_='WindowsFileAttributeType', 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_='WindowsFileAttributeType')
        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_='WinFileObj:', name_='WindowsFileAttributeType'):
        super(WindowsFileAttributeType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='WindowsFileAttributeType')
        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_='WinFileObj:', name_='WindowsFileAttributeType', fromsubclass_=False, pretty_print=True):
        super(WindowsFileAttributeType, self).exportChildren(outfile, level, 'WinFileObj:', name_, True, pretty_print=pretty_print)
        pass
    def hasContent_(self):
        if (
            self.valueOf_ or
            super(WindowsFileAttributeType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='WindowsFileAttributeType'):
        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,))
        super(WindowsFileAttributeType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(WindowsFileAttributeType, self).exportLiteralChildren(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
        super(WindowsFileAttributeType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class WindowsFileAttributeType

class WindowsFileAttributesType(file_object_1_3.FileAttributeType):
    """The WindowsFileAttributesType type specifies Windows file
    attributes. It imports and extends the file_object_1_3.FileAttributeType from
    the CybOX File Object."""
    subclass = None
    superclass = file_object_1_3.FileAttributeType
    def __init__(self, Attribute=None):
        super(WindowsFileAttributesType, self).__init__()
        if Attribute is None:
            self.Attribute = []
        else:
            self.Attribute = Attribute
    def factory(*args_, **kwargs_):
        if WindowsFileAttributesType.subclass:
            return WindowsFileAttributesType.subclass(*args_, **kwargs_)
        else:
            return WindowsFileAttributesType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Attribute(self): return self.Attribute
    def set_Attribute(self, Attribute): self.Attribute = Attribute
    def add_Attribute(self, value): self.Attribute.append(value)
    def insert_Attribute(self, index, value): self.Attribute[index] = value
    def validate_WindowsFileAttributeType(self, value):
        # Validate type WindowsFileAttributeType, a restriction on None.
        pass
    def export(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFileAttributesType', 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_='WindowsFileAttributesType')
        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_='WinFileObj:', name_='WindowsFileAttributesType'):
        super(WindowsFileAttributesType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='WindowsFileAttributesType')
    def exportChildren(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFileAttributesType', fromsubclass_=False, pretty_print=True):
        super(WindowsFileAttributesType, self).exportChildren(outfile, level, 'WinFileObj:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for Attribute_ in self.Attribute:
            Attribute_.export(outfile, level, 'WinFileObj:', name_='Attribute', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Attribute or
            super(WindowsFileAttributesType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='WindowsFileAttributesType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(WindowsFileAttributesType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(WindowsFileAttributesType, self).exportLiteralChildren(outfile, level, name_)
        showIndent(outfile, level)
        outfile.write('Attribute=[\n')
        level += 1
        for Attribute_ in self.Attribute:
            showIndent(outfile, level)
            outfile.write('model_.WindowsFileAttributeType(\n')
            Attribute_.exportLiteral(outfile, level, name_='WindowsFileAttributeType')
            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):
        super(WindowsFileAttributesType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Attribute':
            obj_ = WindowsFileAttributeType.factory()
            obj_.build(child_)
            self.Attribute.append(obj_)
        super(WindowsFileAttributesType, self).buildChildren(child_, node, nodeName_, True)
# end class WindowsFileAttributesType

class StreamObjectType(cybox_common_types_1_0.HashListType):
    """The StreamObjectType type is intended to characterize NTFS alternate
    data streams."""
    subclass = None
    superclass = cybox_common_types_1_0.HashListType
    def __init__(self, Hash=None, Name=None, Size_In_Bytes=None):
        super(StreamObjectType, self).__init__(Hash, )
        self.Name = Name
        self.Size_In_Bytes = Size_In_Bytes
    def factory(*args_, **kwargs_):
        if StreamObjectType.subclass:
            return StreamObjectType.subclass(*args_, **kwargs_)
        else:
            return StreamObjectType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Name(self): return self.Name
    def set_Name(self, Name): self.Name = Name
    def validate_StringObjectAttributeType(self, value):
        # Validate type cybox_common_types_1_0.StringObjectAttributeType, a restriction on None.
        pass
    def get_Size_In_Bytes(self): return self.Size_In_Bytes
    def set_Size_In_Bytes(self, Size_In_Bytes): self.Size_In_Bytes = Size_In_Bytes
    def validate_UnsignedLongObjectAttributeType(self, value):
        # Validate type cybox_common_types_1_0.UnsignedLongObjectAttributeType, a restriction on None.
        pass
    def export(self, outfile, level, namespace_='WinFileObj:', name_='StreamObjectType', 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_='StreamObjectType')
        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_='WinFileObj:', name_='StreamObjectType'):
        super(StreamObjectType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='StreamObjectType')
    def exportChildren(self, outfile, level, namespace_='WinFileObj:', name_='StreamObjectType', fromsubclass_=False, pretty_print=True):
        super(StreamObjectType, self).exportChildren(outfile, level, 'WinFileObj:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Name is not None:
            self.Name.export(outfile, level, 'WinFileObj:', name_='Name', pretty_print=pretty_print)
        if self.Size_In_Bytes is not None:
            self.Size_In_Bytes.export(outfile, level, 'WinFileObj:', name_='Size_In_Bytes', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Name is not None or
            self.Size_In_Bytes is not None or
            super(StreamObjectType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='StreamObjectType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(StreamObjectType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(StreamObjectType, self).exportLiteralChildren(outfile, level, name_)
        if self.Name is not None:
            showIndent(outfile, level)
            outfile.write('Name=model_.cybox_common_types_1_0.StringObjectAttributeType(\n')
            self.Name.exportLiteral(outfile, level, name_='Name')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Size_In_Bytes is not None:
            showIndent(outfile, level)
            outfile.write('Size_In_Bytes=model_.cybox_common_types_1_0.UnsignedLongObjectAttributeType(\n')
            self.Size_In_Bytes.exportLiteral(outfile, level, name_='Size_In_Bytes')
            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(StreamObjectType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Name':
            obj_ = cybox_common_types_1_0.StringObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Name(obj_)
        elif nodeName_ == 'Size_In_Bytes':
            obj_ = cybox_common_types_1_0.UnsignedLongObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Size_In_Bytes(obj_)
        super(StreamObjectType, self).buildChildren(child_, node, nodeName_, True)
# end class StreamObjectType

class WindowsFileObjectType(file_object_1_3.FileObjectType):
    """The WindowsFileObjectType type is intended to characterize Windows
    files."""
    subclass = None
    superclass = file_object_1_3.FileObjectType
    def __init__(self, object_reference=None, is_packed=None, File_Name=None, File_Path=None, Device_Path=None, Full_Path=None, File_Extension=None, Size_In_Bytes=None, Magic_Number=None, File_Format=None, Hashes=None, Digital_Signatures=None, Modified_Time=None, Accessed_Time=None, Created_Time=None, File_Attributes_List=None, Permissions=None, User_Owner=None, Packer_List=None, Peak_Entropy=None, Sym_Links=None, Byte_Runs=None, Filename_Accessed_Time=None, Filename_Created_Time=None, Filename_Modified_Time=None, Drive=None, Security_ID=None, Security_Type=None, Stream_List=None):
        super(WindowsFileObjectType, self).__init__(object_reference, is_packed, File_Name, File_Path, Device_Path, Full_Path, File_Extension, Size_In_Bytes, Magic_Number, File_Format, Hashes, Digital_Signatures, Modified_Time, Accessed_Time, Created_Time, File_Attributes_List, Permissions, User_Owner, Packer_List, Peak_Entropy, Sym_Links, Byte_Runs, )
        self.Filename_Accessed_Time = Filename_Accessed_Time
        self.Filename_Created_Time = Filename_Created_Time
        self.Filename_Modified_Time = Filename_Modified_Time
        self.Drive = Drive
        self.Security_ID = Security_ID
        self.Security_Type = Security_Type
        self.Stream_List = Stream_List
    def factory(*args_, **kwargs_):
        if WindowsFileObjectType.subclass:
            return WindowsFileObjectType.subclass(*args_, **kwargs_)
        else:
            return WindowsFileObjectType(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_Filename_Accessed_Time(self): return self.Filename_Accessed_Time
    def set_Filename_Accessed_Time(self, Filename_Accessed_Time): self.Filename_Accessed_Time = Filename_Accessed_Time
    def validate_DateTimeObjectAttributeType(self, value):
        # Validate type cybox_common_types_1_0.DateTimeObjectAttributeType, a restriction on None.
        pass
    def get_Filename_Created_Time(self): return self.Filename_Created_Time
    def set_Filename_Created_Time(self, Filename_Created_Time): self.Filename_Created_Time = Filename_Created_Time
    def get_Filename_Modified_Time(self): return self.Filename_Modified_Time
    def set_Filename_Modified_Time(self, Filename_Modified_Time): self.Filename_Modified_Time = Filename_Modified_Time
    def get_Drive(self): return self.Drive
    def set_Drive(self, Drive): self.Drive = Drive
    def validate_StringObjectAttributeType(self, value):
        # Validate type cybox_common_types_1_0.StringObjectAttributeType, a restriction on None.
        pass
    def get_Security_ID(self): return self.Security_ID
    def set_Security_ID(self, Security_ID): self.Security_ID = Security_ID
    def get_Security_Type(self): return self.Security_Type
    def set_Security_Type(self, Security_Type): self.Security_Type = Security_Type
    def validate_SIDType(self, value):
        # Validate type cybox_common_types_1_0.SIDType, a restriction on None.
        pass
    def get_Stream_List(self): return self.Stream_List
    def set_Stream_List(self, Stream_List): self.Stream_List = Stream_List
    def export(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFileObjectType', 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_='WindowsFileObjectType')
        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_='WinFileObj:', name_='WindowsFileObjectType'):
        super(WindowsFileObjectType, self).exportAttributes(outfile, level, already_processed, namespace_, name_='WindowsFileObjectType')
    def exportChildren(self, outfile, level, namespace_='WinFileObj:', name_='WindowsFileObjectType', fromsubclass_=False, pretty_print=True):
        super(WindowsFileObjectType, self).exportChildren(outfile, level, 'WinFileObj:', name_, True, pretty_print=pretty_print)
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Filename_Accessed_Time is not None:
            self.Filename_Accessed_Time.export(outfile, level, 'WinFileObj:', name_='Filename_Accessed_Time', pretty_print=pretty_print)
        if self.Filename_Created_Time is not None:
            self.Filename_Created_Time.export(outfile, level, 'WinFileObj:', name_='Filename_Created_Time', pretty_print=pretty_print)
        if self.Filename_Modified_Time is not None:
            self.Filename_Modified_Time.export(outfile, level, 'WinFileObj:', name_='Filename_Modified_Time', pretty_print=pretty_print)
        if self.Drive is not None:
            self.Drive.export(outfile, level, 'WinFileObj:', name_='Drive', pretty_print=pretty_print)
        if self.Security_ID is not None:
            self.Security_ID.export(outfile, level, 'WinFileObj:', name_='Security_ID', pretty_print=pretty_print)
        if self.Security_Type is not None:
            self.Security_Type.export(outfile, level, 'WinFileObj:', name_='Security_Type', pretty_print=pretty_print)
        if self.Stream_List is not None:
            self.Stream_List.export(outfile, level, 'WinFileObj:', name_='Stream_List', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.Filename_Accessed_Time is not None or
            self.Filename_Created_Time is not None or
            self.Filename_Modified_Time is not None or
            self.Drive is not None or
            self.Security_ID is not None or
            self.Security_Type is not None or
            self.Stream_List is not None or
            super(WindowsFileObjectType, self).hasContent_()
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='WindowsFileObjectType'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        super(WindowsFileObjectType, self).exportLiteralAttributes(outfile, level, already_processed, name_)
    def exportLiteralChildren(self, outfile, level, name_):
        super(WindowsFileObjectType, self).exportLiteralChildren(outfile, level, name_)
        if self.Filename_Accessed_Time is not None:
            showIndent(outfile, level)
            outfile.write('Filename_Accessed_Time=model_.cybox_common_types_1_0.DateTimeObjectAttributeType(\n')
            self.Filename_Accessed_Time.exportLiteral(outfile, level, name_='Filename_Accessed_Time')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Filename_Created_Time is not None:
            showIndent(outfile, level)
            outfile.write('Filename_Created_Time=model_.cybox_common_types_1_0.DateTimeObjectAttributeType(\n')
            self.Filename_Created_Time.exportLiteral(outfile, level, name_='Filename_Created_Time')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Filename_Modified_Time is not None:
            showIndent(outfile, level)
            outfile.write('Filename_Modified_Time=model_.cybox_common_types_1_0.DateTimeObjectAttributeType(\n')
            self.Filename_Modified_Time.exportLiteral(outfile, level, name_='Filename_Modified_Time')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Drive is not None:
            showIndent(outfile, level)
            outfile.write('Drive=model_.cybox_common_types_1_0.StringObjectAttributeType(\n')
            self.Drive.exportLiteral(outfile, level, name_='Drive')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Security_ID is not None:
            showIndent(outfile, level)
            outfile.write('Security_ID=model_.cybox_common_types_1_0.StringObjectAttributeType(\n')
            self.Security_ID.exportLiteral(outfile, level, name_='Security_ID')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Security_Type is not None:
            showIndent(outfile, level)
            outfile.write('Security_Type=model_.cybox_common_types_1_0.SIDType(\n')
            self.Security_Type.exportLiteral(outfile, level, name_='Security_Type')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.Stream_List is not None:
            showIndent(outfile, level)
            outfile.write('Stream_List=model_.StreamListType(\n')
            self.Stream_List.exportLiteral(outfile, level, name_='Stream_List')
            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(WindowsFileObjectType, self).buildAttributes(node, attrs, already_processed)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Filename_Accessed_Time':
            obj_ = cybox_common_types_1_0.DateTimeObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Filename_Accessed_Time(obj_)
        elif nodeName_ == 'Filename_Created_Time':
            obj_ = cybox_common_types_1_0.DateTimeObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Filename_Created_Time(obj_)
        elif nodeName_ == 'Filename_Modified_Time':
            obj_ = cybox_common_types_1_0.DateTimeObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Filename_Modified_Time(obj_)
        elif nodeName_ == 'Drive':
            obj_ = cybox_common_types_1_0.StringObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Drive(obj_)
        elif nodeName_ == 'Security_ID':
            obj_ = cybox_common_types_1_0.StringObjectAttributeType.factory()
            obj_.build(child_)
            self.set_Security_ID(obj_)
        elif nodeName_ == 'Security_Type':
            obj_ = cybox_common_types_1_0.SIDType.factory()
            obj_.build(child_)
            self.set_Security_Type(obj_)
        elif nodeName_ == 'Stream_List':
            obj_ = StreamListType.factory()
            obj_.build(child_)
            self.set_Stream_List(obj_)
        super(WindowsFileObjectType, self).buildChildren(child_, node, nodeName_, True)
# end class WindowsFileObjectType

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

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