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

#
# Generated Mon Jan 28 11:54:09 2013 by generateDS.py version 2.8a.
#

import sys
import getopt
import re as re_
import base64
from datetime import datetime, tzinfo, timedelta

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):
        tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$')
        class _FixedOffsetTZ(tzinfo):
            def __init__(self, offset, name):
                self.__offset = timedelta(minutes = offset)
                self.__name = name
            def utcoffset(self, dt):
                return self.__offset
            def tzname(self, dt):
                return self.__name
            def dst(self, dt):
                return None
        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_base64(self, input_data, input_name=''):
            return base64.b64encode(input_data)
        def gds_validate_base64(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_validate_datetime(self, input_data, node, input_name=''):
            return input_data
        def gds_format_datetime(self, input_data, input_name=''):
            _svalue = input_data.strftime('%Y-%m-%dT%H:%M:%S')
            if input_data.tzinfo is not None:
                tzoff = input_data.tzinfo.utcoffset(input_data)
                if tzoff is not None:
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
                    if total_seconds == 0:
                        _svalue += 'Z'
                    else:
                        if total_seconds < 0:
                            _svalue += '-'
                            total_seconds *= -1
                        else:
                            _svalue += '+'
                        hours = total_seconds // 3600
                        minutes = (total_seconds - (hours * 3600)) // 60
                        _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
            return _svalue
        def gds_parse_datetime(self, input_data, node, input_name=''):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
                input_data = input_data[:-1]
            else:
                results = GeneratedsSuper.tzoff_pattern.search(input_data)
                if results is not None:
                    tzoff_parts = results.group(2).split(':')
                    tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                    if results.group(1) == '-':
                        tzoff *= -1
                    tz = GeneratedsSuper._FixedOffsetTZ(
                        tzoff, results.group(0))
                    input_data = input_data[:-6]
            return datetime.strptime(input_data,
                '%Y-%m-%dT%H:%M:%S').replace(tzinfo = tz)
        def gds_validate_date(self, input_data, node, input_name=''):
            return input_data
        def gds_format_date(self, input_data, input_name=''):
            _svalue = input_data.strftime('%Y-%m-%d')
            if input_data.tzinfo is not None:
                tzoff = input_data.tzinfo.utcoffset(input_data)
                if tzoff is not None:
                    total_seconds = tzoff.seconds + (86400 * tzoff.days)
                    if total_seconds == 0:
                        _svalue += 'Z'
                    else:
                        if total_seconds < 0:
                            _svalue += '-'
                            total_seconds *= -1
                        else:
                            _svalue += '+'
                        hours = total_seconds // 3600
                        minutes = (total_seconds - (hours * 3600)) // 60
                        _svalue += '{0:02d}:{1:02d}'.format(hours, minutes)
            return _svalue
        def gds_parse_date(self, input_data, node, input_name=''):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'GMT')
                input_data = input_data[:-1]
            else:
                results = GeneratedsSuper.tzoff_pattern.search(input_data)
                if results is not None:
                    tzoff_parts = results.group(2).split(':')
                    tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1])
                    if results.group(1) == '-':
                        tzoff *= -1
                    tz = GeneratedsSuper._FixedOffsetTZ(
                        tzoff, results.group(0))
                    input_data = input_data[:-6]
            return datetime.strptime(input_data,
                '%Y-%m-%d').replace(tzinfo = tz)
        def gds_str_lower(self, instring):
            return instring.lower()
        def get_path_(self, node):
            path_list = []
            self.get_path_list_(node, path_list)
            path_list.reverse()
            path = '/'.join(path_list)
            return path
        Tag_strip_pattern_ = re_.compile(r'\{.*\}')
        def get_path_list_(self, node, path_list):
            if node is None:
                return
            tag = GeneratedsSuper.Tag_strip_pattern_.sub('', node.tag)
            if tag:
                path_list.append(tag)
            self.get_path_list_(node.getparent(), path_list)
        def get_class_obj_(self, node, default_class=None):
            class_obj1 = default_class
            if 'xsi' in node.nsmap:
                classname = node.get('{%s}type' % node.nsmap['xsi'])
                if classname is not None:
                    names = classname.split(':')
                    if len(names) == 2:
                        classname = names[1]
                    class_obj2 = globals().get(classname)
                    if class_obj2 is not None:
                        class_obj1 = class_obj2
            return class_obj1
        def gds_build_any(self, node, type_name=None):
            return None


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

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

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

#
# Globals
#

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

#
# Support/utility functions.
#

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

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

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

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

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

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


class GDSParseError(Exception):
    pass

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


class MixedContainer:
    # Constants for category:
    CategoryNone = 0
    CategoryText = 1
    CategorySimple = 2
    CategoryComplex = 3
    # Constants for content_type:
    TypeNone = 0
    TypeText = 1
    TypeString = 2
    TypeInteger = 3
    TypeFloat = 4
    TypeDecimal = 5
    TypeDouble = 6
    TypeBoolean = 7
    TypeBase64 = 8
    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))
        elif self.content_type == MixedContainer.TypeBase64:
            outfile.write('<%s>%s</%s>' %
                (self.name, base64.b64encode(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 annotation_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, algorithm=None, analysis=None, dataset=None, anomaly=None):
        self.algorithm = algorithm
        self.analysis = analysis
        self.dataset = dataset
        if anomaly is None:
            self.anomaly = []
        else:
            self.anomaly = anomaly
    def factory(*args_, **kwargs_):
        if annotation_t.subclass:
            return annotation_t.subclass(*args_, **kwargs_)
        else:
            return annotation_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_algorithm(self): return self.algorithm
    def set_algorithm(self, algorithm): self.algorithm = algorithm
    def get_analysis(self): return self.analysis
    def set_analysis(self, analysis): self.analysis = analysis
    def get_dataset(self): return self.dataset
    def set_dataset(self, dataset): self.dataset = dataset
    def get_anomaly(self): return self.anomaly
    def set_anomaly(self, anomaly): self.anomaly = anomaly
    def add_anomaly(self, value): self.anomaly.append(value)
    def insert_anomaly(self, index, value): self.anomaly[index] = value
    def export(self, outfile, level, namespace_='admd:', name_='annotation_t', 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_='annotation_t')
        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_='admd:', name_='annotation_t'):
        pass
    def exportChildren(self, outfile, level, namespace_='admd:', name_='annotation_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.algorithm is not None:
            self.algorithm.export(outfile, level, namespace_, name_='algorithm', pretty_print=pretty_print)
        if self.analysis is not None:
            self.analysis.export(outfile, level, namespace_, name_='analysis', pretty_print=pretty_print)
        if self.dataset is not None:
            self.dataset.export(outfile, level, namespace_, name_='dataset', pretty_print=pretty_print)
        for anomaly_ in self.anomaly:
            anomaly_.export(outfile, level, namespace_, name_='anomaly', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.algorithm is not None or
            self.analysis is not None or
            self.dataset is not None or
            self.anomaly
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='annotation_t'):
        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.algorithm is not None:
            showIndent(outfile, level)
            outfile.write('algorithm=model_.algorithm_t(\n')
            self.algorithm.exportLiteral(outfile, level, name_='algorithm')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.analysis is not None:
            showIndent(outfile, level)
            outfile.write('analysis=model_.analysis_t(\n')
            self.analysis.exportLiteral(outfile, level, name_='analysis')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.dataset is not None:
            showIndent(outfile, level)
            outfile.write('dataset=model_.dataset_t(\n')
            self.dataset.exportLiteral(outfile, level, name_='dataset')
            showIndent(outfile, level)
            outfile.write('),\n')
        showIndent(outfile, level)
        outfile.write('anomaly=[\n')
        level += 1
        for anomaly_ in self.anomaly:
            showIndent(outfile, level)
            outfile.write('model_.anomaly_t(\n')
            anomaly_.exportLiteral(outfile, level, name_='anomaly_t')
            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_ == 'algorithm':
            obj_ = algorithm_t.factory()
            obj_.build(child_)
            self.set_algorithm(obj_)
        elif nodeName_ == 'analysis':
            obj_ = analysis_t.factory()
            obj_.build(child_)
            self.set_analysis(obj_)
        elif nodeName_ == 'dataset':
            obj_ = dataset_t.factory()
            obj_.build(child_)
            self.set_dataset(obj_)
        elif nodeName_ == 'anomaly':
            obj_ = anomaly_t.factory()
            obj_.build(child_)
            self.anomaly.append(obj_)
# end class annotation_t


class algorithm_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, version=None, name=None, description=None, url=None, parameter=None):
        self.version = _cast(None, version)
        self.name = _cast(None, name)
        self.description = description
        self.url = url
        self.parameter = parameter
    def factory(*args_, **kwargs_):
        if algorithm_t.subclass:
            return algorithm_t.subclass(*args_, **kwargs_)
        else:
            return algorithm_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_description(self): return self.description
    def set_description(self, description): self.description = description
    def get_url(self): return self.url
    def set_url(self, url): self.url = url
    def get_parameter(self): return self.parameter
    def set_parameter(self, parameter): self.parameter = parameter
    def get_version(self): return self.version
    def set_version(self, version): self.version = version
    def get_name(self): return self.name
    def set_name(self, name): self.name = name
    def export(self, outfile, level, namespace_='admd:', name_='algorithm_t', 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_='algorithm_t')
        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_='admd:', name_='algorithm_t'):
        if self.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            outfile.write(' version=%s' % (self.gds_format_string(quote_attrib(self.version).encode(ExternalEncoding), input_name='version'), ))
        if self.name is not None and 'name' not in already_processed:
            already_processed.append('name')
            outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), ))
    def exportChildren(self, outfile, level, namespace_='admd:', name_='algorithm_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.description is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_))
        if self.url is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%surl>%s</%surl>%s' % (namespace_, self.gds_format_string(quote_xml(self.url).encode(ExternalEncoding), input_name='url'), namespace_, eol_))
        if self.parameter is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sparameter>%s</%sparameter>%s' % (namespace_, self.gds_format_string(quote_xml(self.parameter).encode(ExternalEncoding), input_name='parameter'), namespace_, eol_))
    def hasContent_(self):
        if (
            self.description is not None or
            self.url is not None or
            self.parameter is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='algorithm_t'):
        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.version is not None and 'version' not in already_processed:
            already_processed.append('version')
            showIndent(outfile, level)
            outfile.write('version = "%s",\n' % (self.version,))
        if self.name is not None and 'name' not in already_processed:
            already_processed.append('name')
            showIndent(outfile, level)
            outfile.write('name = "%s",\n' % (self.name,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.description is not None:
            showIndent(outfile, level)
            outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))
        if self.url is not None:
            showIndent(outfile, level)
            outfile.write('url=%s,\n' % quote_python(self.url).encode(ExternalEncoding))
        if self.parameter is not None:
            showIndent(outfile, level)
            outfile.write('parameter=%s,\n' % quote_python(self.parameter).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_('version', node)
        if value is not None and 'version' not in already_processed:
            already_processed.append('version')
            self.version = value
        value = find_attr_value_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.append('name')
            self.name = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'description':
            description_ = child_.text
            description_ = self.gds_validate_string(description_, node, 'description')
            self.description = description_
        elif nodeName_ == 'url':
            url_ = child_.text
            url_ = self.gds_validate_string(url_, node, 'url')
            self.url = url_
        elif nodeName_ == 'parameter':
            parameter_ = child_.text
            parameter_ = self.gds_validate_string(parameter_, node, 'parameter')
            self.parameter = parameter_
# end class algorithm_t


class analysis_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, description=None, datetime=None, analyst=None, organization=None):
        self.description = description
        self.datetime = datetime
        self.analyst = analyst
        self.organization = organization
    def factory(*args_, **kwargs_):
        if analysis_t.subclass:
            return analysis_t.subclass(*args_, **kwargs_)
        else:
            return analysis_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_description(self): return self.description
    def set_description(self, description): self.description = description
    def get_datetime(self): return self.datetime
    def set_datetime(self, datetime): self.datetime = datetime
    def get_analyst(self): return self.analyst
    def set_analyst(self, analyst): self.analyst = analyst
    def get_organization(self): return self.organization
    def set_organization(self, organization): self.organization = organization
    def export(self, outfile, level, namespace_='admd:', name_='analysis_t', 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_='analysis_t')
        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_='admd:', name_='analysis_t'):
        pass
    def exportChildren(self, outfile, level, namespace_='admd:', name_='analysis_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.description is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_))
        if self.datetime is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdatetime>%s</%sdatetime>%s' % (namespace_, self.gds_format_datetime(self.datetime, input_name='datetime'), namespace_, eol_))
        if self.analyst is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sanalyst>%s</%sanalyst>%s' % (namespace_, self.gds_format_string(quote_xml(self.analyst).encode(ExternalEncoding), input_name='analyst'), namespace_, eol_))
        if self.organization is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sorganization>%s</%sorganization>%s' % (namespace_, self.gds_format_string(quote_xml(self.organization).encode(ExternalEncoding), input_name='organization'), namespace_, eol_))
    def hasContent_(self):
        if (
            self.description is not None or
            self.datetime is not None or
            self.analyst is not None or
            self.organization is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='analysis_t'):
        level += 1
        self.exportLiteralAttributes(outfile, level, [], name_)
        if self.hasContent_():
            self.exportLiteralChildren(outfile, level, name_)
    def exportLiteralAttributes(self, outfile, level, already_processed, name_):
        pass
    def exportLiteralChildren(self, outfile, level, name_):
        if self.description is not None:
            showIndent(outfile, level)
            outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))
        if self.datetime is not None:
            showIndent(outfile, level)
            outfile.write('datetime=datetime_.strptime("%s", "%%Y-%%m-%%dT%%H:%%M:%%S"),\n' % self.gds_format_datetime(self.datetime, input_name='datetime'))
        if self.analyst is not None:
            showIndent(outfile, level)
            outfile.write('analyst=%s,\n' % quote_python(self.analyst).encode(ExternalEncoding))
        if self.organization is not None:
            showIndent(outfile, level)
            outfile.write('organization=%s,\n' % quote_python(self.organization).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_ == 'description':
            description_ = child_.text
            description_ = self.gds_validate_string(description_, node, 'description')
            self.description = description_
        elif nodeName_ == 'datetime':
            sval_ = child_.text
            dval_ = self.gds_parse_datetime(sval_, node, 'datetime')
            self.datetime = dval_
        elif nodeName_ == 'analyst':
            analyst_ = child_.text
            analyst_ = self.gds_validate_string(analyst_, node, 'analyst')
            self.analyst = analyst_
        elif nodeName_ == 'organization':
            organization_ = child_.text
            organization_ = self.gds_validate_string(organization_, node, 'organization')
            self.organization = organization_
# end class analysis_t


class dataset_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, name=None, description=None, url=None):
        self.name = _cast(None, name)
        self.description = description
        self.url = url
    def factory(*args_, **kwargs_):
        if dataset_t.subclass:
            return dataset_t.subclass(*args_, **kwargs_)
        else:
            return dataset_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_description(self): return self.description
    def set_description(self, description): self.description = description
    def get_url(self): return self.url
    def set_url(self, url): self.url = url
    def get_name(self): return self.name
    def set_name(self, name): self.name = name
    def export(self, outfile, level, namespace_='admd:', name_='dataset_t', 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_='dataset_t')
        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_='admd:', name_='dataset_t'):
        if self.name is not None and 'name' not in already_processed:
            already_processed.append('name')
            outfile.write(' name=%s' % (self.gds_format_string(quote_attrib(self.name).encode(ExternalEncoding), input_name='name'), ))
    def exportChildren(self, outfile, level, namespace_='admd:', name_='dataset_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.description is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_))
        if self.url is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%surl>%s</%surl>%s' % (namespace_, self.gds_format_string(quote_xml(self.url).encode(ExternalEncoding), input_name='url'), namespace_, eol_))
    def hasContent_(self):
        if (
            self.description is not None or
            self.url is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='dataset_t'):
        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.name is not None and 'name' not in already_processed:
            already_processed.append('name')
            showIndent(outfile, level)
            outfile.write('name = "%s",\n' % (self.name,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.description is not None:
            showIndent(outfile, level)
            outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))
        if self.url is not None:
            showIndent(outfile, level)
            outfile.write('url=%s,\n' % quote_python(self.url).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_('name', node)
        if value is not None and 'name' not in already_processed:
            already_processed.append('name')
            self.name = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'description':
            description_ = child_.text
            description_ = self.gds_validate_string(description_, node, 'description')
            self.description = description_
        elif nodeName_ == 'url':
            url_ = child_.text
            url_ = self.gds_validate_string(url_, node, 'url')
            self.url = url_
# end class dataset_t


class anomaly_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, type_=None, value=None, description=None, slice=None, packet=None, fromxx=None, to=None):
        self.type_ = _cast(None, type_)
        self.value = _cast(None, value)
        self.description = description
        if slice is None:
            self.slice = []
        else:
            self.slice = slice
        if packet is None:
            self.packet = []
        else:
            self.packet = packet
        self.fromxx = fromxx
        self.to = to
    def factory(*args_, **kwargs_):
        if anomaly_t.subclass:
            return anomaly_t.subclass(*args_, **kwargs_)
        else:
            return anomaly_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_description(self): return self.description
    def set_description(self, description): self.description = description
    def get_slice(self): return self.slice
    def set_slice(self, slice): self.slice = slice
    def add_slice(self, value): self.slice.append(value)
    def insert_slice(self, index, value): self.slice[index] = value
    def get_packet(self): return self.packet
    def set_packet(self, packet): self.packet = packet
    def add_packet(self, value): self.packet.append(value)
    def insert_packet(self, index, value): self.packet[index] = value
    def get_from(self): return self.fromxx
    def set_from(self, fromxx): self.fromxx = fromxx
    def get_to(self): return self.to
    def set_to(self, to): self.to = to
    def get_type(self): return self.type_
    def set_type(self, type_): self.type_ = type_
    def get_value(self): return self.value
    def set_value(self, value): self.value = value
    def export(self, outfile, level, namespace_='admd:', name_='anomaly_t', 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_='anomaly_t')
        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_='admd:', name_='anomaly_t'):
        if self.type_ is not None and 'type_' not in already_processed:
            already_processed.append('type_')
            outfile.write(' type=%s' % (self.gds_format_string(quote_attrib(self.type_).encode(ExternalEncoding), input_name='type'), ))
        if self.value is not None and 'value' not in already_processed:
            already_processed.append('value')
            outfile.write(' value=%s' % (self.gds_format_string(quote_attrib(self.value).encode(ExternalEncoding), input_name='value'), ))
    def exportChildren(self, outfile, level, namespace_='admd:', name_='anomaly_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.description is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdescription>%s</%sdescription>%s' % (namespace_, self.gds_format_string(quote_xml(self.description).encode(ExternalEncoding), input_name='description'), namespace_, eol_))
        for slice_ in self.slice:
            slice_.export(outfile, level, namespace_, name_='slice', pretty_print=pretty_print)
        for packet_ in self.packet:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%spacket>%s</%spacket>%s' % (namespace_, self.gds_format_base64(packet_, input_name='packet'), namespace_, eol_))
        if self.fromxx is not None:
            self.fromxx.export(outfile, level, namespace_, name_='from', pretty_print=pretty_print)
        if self.to is not None:
            self.to.export(outfile, level, namespace_, name_='to', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.description is not None or
            self.slice or
            self.packet or
            self.fromxx is not None or
            self.to is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='anomaly_t'):
        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.type_ is not None and 'type_' not in already_processed:
            already_processed.append('type_')
            showIndent(outfile, level)
            outfile.write('type_ = "%s",\n' % (self.type_,))
        if self.value is not None and 'value' not in already_processed:
            already_processed.append('value')
            showIndent(outfile, level)
            outfile.write('value = "%s",\n' % (self.value,))
    def exportLiteralChildren(self, outfile, level, name_):
        if self.description is not None:
            showIndent(outfile, level)
            outfile.write('description=%s,\n' % quote_python(self.description).encode(ExternalEncoding))
        showIndent(outfile, level)
        outfile.write('slice=[\n')
        level += 1
        for slice_ in self.slice:
            showIndent(outfile, level)
            outfile.write('model_.slice_t(\n')
            slice_.exportLiteral(outfile, level, name_='slice_t')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        showIndent(outfile, level)
        outfile.write('packet=[\n')
        level += 1
        for packet_ in self.packet:
            showIndent(outfile, level)
            outfile.write('model_.xs_base64Binary(\n')
            packet_.exportLiteral(outfile, level, name_='xs:base64Binary')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.fromxx is not None:
            showIndent(outfile, level)
            outfile.write('fromxx=model_.timestamp_t(\n')
            self.fromxx.exportLiteral(outfile, level, name_='from')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.to is not None:
            showIndent(outfile, level)
            outfile.write('to=model_.timestamp_t(\n')
            self.to.exportLiteral(outfile, level, name_='to')
            showIndent(outfile, level)
            outfile.write('),\n')
    def build(self, node):
        self.buildAttributes(node, node.attrib, [])
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('type', node)
        if value is not None and 'type' not in already_processed:
            already_processed.append('type')
            self.type_ = value
        value = find_attr_value_('value', node)
        if value is not None and 'value' not in already_processed:
            already_processed.append('value')
            self.value = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'description':
            description_ = child_.text
            description_ = self.gds_validate_string(description_, node, 'description')
            self.description = description_
        elif nodeName_ == 'slice':
            obj_ = slice_t.factory()
            obj_.build(child_)
            self.slice.append(obj_)
        elif nodeName_ == 'packet':
            sval_ = child_.text
            if sval_ is not None:
                try:
                    bval_ = base64.b64decode(sval_)
                except (TypeError, ValueError), exp:
                    raise_parse_error(child_, 'requires base64 encoded string: %s' % exp)
                bval_ = self.gds_validate_base64(bval_, node, 'packet')
            else:
                bval_ = None
            self.packet.append(bval_)
        elif nodeName_ == 'from':
            obj_ = timestamp_t.factory()
            obj_.build(child_)
            self.set_from(obj_)
        elif nodeName_ == 'to':
            obj_ = timestamp_t.factory()
            obj_.build(child_)
            self.set_to(obj_)
# end class anomaly_t


class slice_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, filter=None, fromxx=None, to=None):
        if filter is None:
            self.filter = []
        else:
            self.filter = filter
        self.fromxx = fromxx
        self.to = to
    def factory(*args_, **kwargs_):
        if slice_t.subclass:
            return slice_t.subclass(*args_, **kwargs_)
        else:
            return slice_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_filter(self): return self.filter
    def set_filter(self, filter): self.filter = filter
    def add_filter(self, value): self.filter.append(value)
    def insert_filter(self, index, value): self.filter[index] = value
    def get_from(self): return self.fromxx
    def set_from(self, fromxx): self.fromxx = fromxx
    def get_to(self): return self.to
    def set_to(self, to): self.to = to
    def export(self, outfile, level, namespace_='admd:', name_='slice_t', 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_='slice_t')
        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_='admd:', name_='slice_t'):
        pass
    def exportChildren(self, outfile, level, namespace_='admd:', name_='slice_t', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for filter_ in self.filter:
            filter_.export(outfile, level, namespace_, name_='filter', pretty_print=pretty_print)
        if self.fromxx is not None:
            self.fromxx.export(outfile, level, namespace_, name_='from', pretty_print=pretty_print)
        if self.to is not None:
            self.to.export(outfile, level, namespace_, name_='to', pretty_print=pretty_print)
    def hasContent_(self):
        if (
            self.filter or
            self.fromxx is not None or
            self.to is not None
            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='slice_t'):
        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('filter=[\n')
        level += 1
        for filter_ in self.filter:
            showIndent(outfile, level)
            outfile.write('model_.filter_t(\n')
            filter_.exportLiteral(outfile, level, name_='filter_t')
            showIndent(outfile, level)
            outfile.write('),\n')
        level -= 1
        showIndent(outfile, level)
        outfile.write('],\n')
        if self.fromxx is not None:
            showIndent(outfile, level)
            outfile.write('fromxx=model_.timestamp_t(\n')
            self.fromxx.exportLiteral(outfile, level, name_='from')
            showIndent(outfile, level)
            outfile.write('),\n')
        if self.to is not None:
            showIndent(outfile, level)
            outfile.write('to=model_.timestamp_t(\n')
            self.to.exportLiteral(outfile, level, name_='to')
            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_ == 'filter':
            obj_ = filter_t.factory()
            obj_.build(child_)
            self.filter.append(obj_)
        elif nodeName_ == 'from':
            obj_ = timestamp_t.factory()
            obj_.build(child_)
            self.set_from(obj_)
        elif nodeName_ == 'to':
            obj_ = timestamp_t.factory()
            obj_.build(child_)
            self.set_to(obj_)
# end class slice_t


class filter_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, src_ip=None, dst_ip=None, src_port=None, dst_port=None, proto=None):
        self.src_ip = _cast(None, src_ip)
        self.dst_ip = _cast(None, dst_ip)
        self.src_port = _cast(int, src_port)
        self.dst_port = _cast(int, dst_port)
        self.proto = _cast(None, proto)
        pass
    def factory(*args_, **kwargs_):
        if filter_t.subclass:
            return filter_t.subclass(*args_, **kwargs_)
        else:
            return filter_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_src_ip(self): return self.src_ip
    def set_src_ip(self, src_ip): self.src_ip = src_ip
    def get_dst_ip(self): return self.dst_ip
    def set_dst_ip(self, dst_ip): self.dst_ip = dst_ip
    def get_src_port(self): return self.src_port
    def set_src_port(self, src_port): self.src_port = src_port
    def get_dst_port(self): return self.dst_port
    def set_dst_port(self, dst_port): self.dst_port = dst_port
    def get_proto(self): return self.proto
    def set_proto(self, proto): self.proto = proto
    def export(self, outfile, level, namespace_='admd:', name_='filter_t', 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_='filter_t')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='admd:', name_='filter_t'):
        if self.src_ip is not None and 'src_ip' not in already_processed:
            already_processed.append('src_ip')
            outfile.write(' src_ip=%s' % (self.gds_format_string(quote_attrib(self.src_ip).encode(ExternalEncoding), input_name='src_ip'), ))
        if self.dst_ip is not None and 'dst_ip' not in already_processed:
            already_processed.append('dst_ip')
            outfile.write(' dst_ip=%s' % (self.gds_format_string(quote_attrib(self.dst_ip).encode(ExternalEncoding), input_name='dst_ip'), ))
        if self.src_port is not None and 'src_port' not in already_processed:
            already_processed.append('src_port')
            outfile.write(' src_port="%s"' % self.gds_format_integer(self.src_port, input_name='src_port'))
        if self.dst_port is not None and 'dst_port' not in already_processed:
            already_processed.append('dst_port')
            outfile.write(' dst_port="%s"' % self.gds_format_integer(self.dst_port, input_name='dst_port'))
        if self.proto is not None and 'proto' not in already_processed:
            already_processed.append('proto')
            outfile.write(' proto=%s' % (self.gds_format_string(quote_attrib(self.proto).encode(ExternalEncoding), input_name='proto'), ))
    def exportChildren(self, outfile, level, namespace_='admd:', name_='filter_t', fromsubclass_=False, pretty_print=True):
        pass
    def hasContent_(self):
        if (

            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='filter_t'):
        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.src_ip is not None and 'src_ip' not in already_processed:
            already_processed.append('src_ip')
            showIndent(outfile, level)
            outfile.write('src_ip = "%s",\n' % (self.src_ip,))
        if self.dst_ip is not None and 'dst_ip' not in already_processed:
            already_processed.append('dst_ip')
            showIndent(outfile, level)
            outfile.write('dst_ip = "%s",\n' % (self.dst_ip,))
        if self.src_port is not None and 'src_port' not in already_processed:
            already_processed.append('src_port')
            showIndent(outfile, level)
            outfile.write('src_port = %d,\n' % (self.src_port,))
        if self.dst_port is not None and 'dst_port' not in already_processed:
            already_processed.append('dst_port')
            showIndent(outfile, level)
            outfile.write('dst_port = %d,\n' % (self.dst_port,))
        if self.proto is not None and 'proto' not in already_processed:
            already_processed.append('proto')
            showIndent(outfile, level)
            outfile.write('proto = "%s",\n' % (self.proto,))
    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):
        value = find_attr_value_('src_ip', node)
        if value is not None and 'src_ip' not in already_processed:
            already_processed.append('src_ip')
            self.src_ip = value
        value = find_attr_value_('dst_ip', node)
        if value is not None and 'dst_ip' not in already_processed:
            already_processed.append('dst_ip')
            self.dst_ip = value
        value = find_attr_value_('src_port', node)
        if value is not None and 'src_port' not in already_processed:
            already_processed.append('src_port')
            try:
                self.src_port = int(value)
            except ValueError, exp:
                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
        value = find_attr_value_('dst_port', node)
        if value is not None and 'dst_port' not in already_processed:
            already_processed.append('dst_port')
            try:
                self.dst_port = int(value)
            except ValueError, exp:
                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
        value = find_attr_value_('proto', node)
        if value is not None and 'proto' not in already_processed:
            already_processed.append('proto')
            self.proto = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class filter_t


class timestamp_t(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, usec=None, sec=None):
        self.usec = _cast(int, usec)
        self.sec = _cast(int, sec)
        pass
    def factory(*args_, **kwargs_):
        if timestamp_t.subclass:
            return timestamp_t.subclass(*args_, **kwargs_)
        else:
            return timestamp_t(*args_, **kwargs_)
    factory = staticmethod(factory)
    def get_usec(self): return self.usec
    def set_usec(self, usec): self.usec = usec
    def get_sec(self): return self.sec
    def set_sec(self, sec): self.sec = sec
    def export(self, outfile, level, namespace_='admd:', name_='timestamp_t', 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_='timestamp_t')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_, name_, pretty_print=pretty_print)
            outfile.write('</%s%s>%s' % (namespace_, name_, eol_))
        else:
            outfile.write('/>%s' % (eol_, ))
    def exportAttributes(self, outfile, level, already_processed, namespace_='admd:', name_='timestamp_t'):
        if self.usec is not None and 'usec' not in already_processed:
            already_processed.append('usec')
            outfile.write(' usec="%s"' % self.gds_format_integer(self.usec, input_name='usec'))
        if self.sec is not None and 'sec' not in already_processed:
            already_processed.append('sec')
            outfile.write(' sec="%s"' % self.gds_format_integer(self.sec, input_name='sec'))
    def exportChildren(self, outfile, level, namespace_='admd:', name_='timestamp_t', fromsubclass_=False, pretty_print=True):
        pass
    def hasContent_(self):
        if (

            ):
            return True
        else:
            return False
    def exportLiteral(self, outfile, level, name_='timestamp_t'):
        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.usec is not None and 'usec' not in already_processed:
            already_processed.append('usec')
            showIndent(outfile, level)
            outfile.write('usec = %d,\n' % (self.usec,))
        if self.sec is not None and 'sec' not in already_processed:
            already_processed.append('sec')
            showIndent(outfile, level)
            outfile.write('sec = %d,\n' % (self.sec,))
    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):
        value = find_attr_value_('usec', node)
        if value is not None and 'usec' not in already_processed:
            already_processed.append('usec')
            try:
                self.usec = int(value)
            except ValueError, exp:
                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
        value = find_attr_value_('sec', node)
        if value is not None and 'sec' not in already_processed:
            already_processed.append('sec')
            try:
                self.sec = int(value)
            except ValueError, exp:
                raise_parse_error(node, 'Bad integer attribute: %s' % exp)
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class timestamp_t


GDSClassesMapping = {
    'slice': slice_t,
    'from': timestamp_t,
    'algorithm': algorithm_t,
    'analysis': analysis_t,
    'dataset': dataset_t,
    'filter': filter_t,
    'to': timestamp_t,
    'anomaly': anomaly_t,
    'annotation': annotation_t,
}


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 = GDSClassesMapping.get(tag)
    if rootClass is None:
        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 = 'annotation_t'
        rootClass = annotation_t
    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 = 'annotation_t'
        rootClass = annotation_t
    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_="annotation_t",
##         namespacedef_='')
    return rootObj


def parseLiteral(inFileName):
    doc = parsexml_(inFileName)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'annotation_t'
        rootClass = annotation_t
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
##     sys.stdout.write('#from admd2 import *\n\n')
##     sys.stdout.write('from datetime import datetime as datetime_\n\n')
##     sys.stdout.write('import admd2 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__ = [
    "algorithm_t",
    "analysis_t",
    "annotation_t",
    "anomaly_t",
    "dataset_t",
    "filter_t",
    "slice_t",
    "timestamp_t"
    ]
