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

#
# Generated Fri Jan 22 16:44:29 2016 by generateDS.py version 2.17a.
#
# Command line options:
#   ('-f', '')
#   ('-q', '')
#   ('--use-getter-setter', 'none')
#   ('-o', 'D:\\GitRepo\\emgui\\src\\dao\\initital.py')
#
# Command line arguments:
#   D:\GitRepo\emgui\src\schema\initital.xsd
#
# Command line:
#   E:\Python27\Scripts\generateDS.py -f -q --use-getter-setter="none" -o "D:\GitRepo\emgui\src\dao\initital.py" D:\GitRepo\emgui\src\schema\initital.xsd
#
# Current working directory (os.getcwd()):
#   Scripts
#

import sys
import re as re_
import base64
import datetime as datetime_
import warnings as warnings_
from lxml import etree as etree_


Validate_simpletypes_ = True


def parsexml_(infile, parser=None, **kwargs):
    if parser is None:
        # Use the lxml ElementTree compatible parser so that, e.g.,
        #   we ignore comments.
        parser = etree_.ETCompatXMLParser()
    doc = etree_.parse(infile, parser=parser, **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 as exp:

    class GeneratedsSuper(object):
        tzoff_pattern = re_.compile(r'(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$')
        class _FixedOffsetTZ(datetime_.tzinfo):
            def __init__(self, offset, name):
                self.__offset = datetime_.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=None, input_name=''):
            if not input_data:
                return ''
            else:
                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=None, 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=None, input_name=''):
            return input_data
        def gds_format_integer_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_integer_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    int(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of integers')
            return values
        def gds_format_float(self, input_data, input_name=''):
            return ('%.15f' % input_data).rstrip('0')
        def gds_validate_float(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_float_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_float_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    float(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of floats')
            return values
        def gds_format_double(self, input_data, input_name=''):
            return '%e' % input_data
        def gds_validate_double(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_double_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_double_list(
                self, input_data, node=None, input_name=''):
            values = input_data.split()
            for value in values:
                try:
                    float(value)
                except (TypeError, ValueError):
                    raise_parse_error(node, 'Requires sequence of doubles')
            return values
        def gds_format_boolean(self, input_data, input_name=''):
            return ('%s' % input_data).lower()
        def gds_validate_boolean(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_boolean_list(self, input_data, input_name=''):
            return '%s' % ' '.join(input_data)
        def gds_validate_boolean_list(
                self, input_data, node=None, 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 values
        def gds_validate_datetime(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_datetime(self, input_data, input_name=''):
            if input_data.microsecond == 0:
                _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % (
                    input_data.year,
                    input_data.month,
                    input_data.day,
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                )
            else:
                _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % (
                    input_data.year,
                    input_data.month,
                    input_data.day,
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                    ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                )
            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
        @classmethod
        def gds_parse_datetime(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                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]
            time_parts = input_data.split('.')
            if len(time_parts) > 1:
                micro_seconds = int(float('0.' + time_parts[1]) * 1000000)
                input_data = '%s.%s' % (time_parts[0], micro_seconds, )
                dt = datetime_.datetime.strptime(
                    input_data, '%Y-%m-%dT%H:%M:%S.%f')
            else:
                dt = datetime_.datetime.strptime(
                    input_data, '%Y-%m-%dT%H:%M:%S')
            dt = dt.replace(tzinfo=tz)
            return dt
        def gds_validate_date(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_date(self, input_data, input_name=''):
            _svalue = '%04d-%02d-%02d' % (
                input_data.year,
                input_data.month,
                input_data.day,
            )
            try:
                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)
            except AttributeError:
                pass
            return _svalue
        @classmethod
        def gds_parse_date(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                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]
            dt = datetime_.datetime.strptime(input_data, '%Y-%m-%d')
            dt = dt.replace(tzinfo=tz)
            return dt.date()
        def gds_validate_time(self, input_data, node=None, input_name=''):
            return input_data
        def gds_format_time(self, input_data, input_name=''):
            if input_data.microsecond == 0:
                _svalue = '%02d:%02d:%02d' % (
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                )
            else:
                _svalue = '%02d:%02d:%02d.%s' % (
                    input_data.hour,
                    input_data.minute,
                    input_data.second,
                    ('%f' % (float(input_data.microsecond) / 1000000))[2:],
                )
            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_validate_simple_patterns(self, patterns, target):
            # pat is a list of lists of strings/patterns.  We should:
            # - AND the outer elements
            # - OR the inner elements
            found1 = True
            for patterns1 in patterns:
                found2 = False
                for patterns2 in patterns1:
                    if re_.search(patterns2, target) is not None:
                        found2 = True
                        break
                if not found2:
                    found1 = False
                    break
            return found1
        @classmethod
        def gds_parse_time(cls, input_data):
            tz = None
            if input_data[-1] == 'Z':
                tz = GeneratedsSuper._FixedOffsetTZ(0, 'UTC')
                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]
            if len(input_data.split('.')) > 1:
                dt = datetime_.datetime.strptime(input_data, '%H:%M:%S.%f')
            else:
                dt = datetime_.datetime.strptime(input_data, '%H:%M:%S')
            dt = dt.replace(tzinfo=tz)
            return dt.time()
        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
        @classmethod
        def gds_reverse_node_mapping(cls, mapping):
            return dict(((v, k) for k, v in mapping.iteritems()))


#
# 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'{(.*)}(.*)')
CDATA_pattern_ = re_.compile(r"<!\[CDATA\[.*?\]\]>", re_.DOTALL)

#
# Support/utility functions.
#


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


def quote_xml(inStr):
    "Escape markup chars, but do not modify CDATA sections."
    if not inStr:
        return ''
    s1 = (isinstance(inStr, basestring) and inStr or
          '%s' % inStr)
    s2 = ''
    pos = 0
    matchobjects = CDATA_pattern_.finditer(s1)
    for mo in matchobjects:
        s3 = s1[pos:mo.start()]
        s2 += quote_xml_aux(s3)
        s2 += s1[mo.start():mo.end()]
        pos = mo.end()
    s3 = s1[pos:]
    s2 += quote_xml_aux(s3)
    return s2


def quote_xml_aux(inStr):
    s1 = inStr.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):
    msg = '%s (element %s/line %d)' % (msg, node.tag, node.sourceline, )
    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 to_etree(self, element):
        if self.category == MixedContainer.CategoryText:
            # Prevent exporting empty content as empty lines.
            if self.value.strip():
                if len(element) > 0:
                    if element[-1].tail is None:
                        element[-1].tail = self.value
                    else:
                        element[-1].tail += self.value
                else:
                    if element.text is None:
                        element.text = self.value
                    else:
                        element.text += self.value
        elif self.category == MixedContainer.CategorySimple:
            subelement = etree_.SubElement(element, '%s' % self.name)
            subelement.text = self.to_etree_simple()
        else:    # category == MixedContainer.CategoryComplex
            self.value.to_etree(element)
    def to_etree_simple(self):
        if self.content_type == MixedContainer.TypeString:
            text = self.value
        elif (self.content_type == MixedContainer.TypeInteger or
                self.content_type == MixedContainer.TypeBoolean):
            text = '%d' % self.value
        elif (self.content_type == MixedContainer.TypeFloat or
                self.content_type == MixedContainer.TypeDecimal):
            text = '%f' % self.value
        elif self.content_type == MixedContainer.TypeDouble:
            text = '%g' % self.value
        elif self.content_type == MixedContainer.TypeBase64:
            text = '%s' % base64.b64encode(self.value)
        return text
    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 Property(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ship_name=None, call_sign=None, imo_number=None, port_registry=None, company_name=None, class_society=None, email=None, telephone=None, fax=None, ship_type=None, international_gross_tonnage=None, international_net_tonnage=None, loa=None, lbp=None, breadth_moulded=None, depth_moulded=None, ecdis_maker=None, ecdis_model=None, captain_name=None, captain_crew_id=None, maintain_paper_chart=None, ME_Particular=None):
        self.original_tagname_ = None
        self.ship_name = ship_name
        self.call_sign = call_sign
        self.imo_number = imo_number
        self.port_registry = port_registry
        self.company_name = company_name
        self.class_society = class_society
        self.email = email
        self.telephone = telephone
        self.fax = fax
        self.ship_type = ship_type
        self.international_gross_tonnage = international_gross_tonnage
        self.international_net_tonnage = international_net_tonnage
        self.loa = loa
        self.lbp = lbp
        self.breadth_moulded = breadth_moulded
        self.depth_moulded = depth_moulded
        self.ecdis_maker = ecdis_maker
        self.ecdis_model = ecdis_model
        self.captain_name = captain_name
        self.captain_crew_id = captain_crew_id
        self.maintain_paper_chart = maintain_paper_chart
        self.ME_Particular = ME_Particular
    def factory(*args_, **kwargs_):
        if Property.subclass:
            return Property.subclass(*args_, **kwargs_)
        else:
            return Property(*args_, **kwargs_)
    factory = staticmethod(factory)
    def hasContent_(self):
        if (
            self.ship_name is not None or
            self.call_sign is not None or
            self.imo_number is not None or
            self.port_registry is not None or
            self.company_name is not None or
            self.class_society is not None or
            self.email is not None or
            self.telephone is not None or
            self.fax is not None or
            self.ship_type is not None or
            self.international_gross_tonnage is not None or
            self.international_net_tonnage is not None or
            self.loa is not None or
            self.lbp is not None or
            self.breadth_moulded is not None or
            self.depth_moulded is not None or
            self.ecdis_maker is not None or
            self.ecdis_model is not None or
            self.captain_name is not None or
            self.captain_crew_id is not None or
            self.maintain_paper_chart is not None or
            self.ME_Particular is not None
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespace_='', name_='Property', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='Property')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_='', name_='Property', 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_='', name_='Property'):
        pass
    def exportChildren(self, outfile, level, namespace_='', name_='Property', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.ship_name is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sship_name>%s</%sship_name>%s' % (namespace_, self.gds_format_string(quote_xml(self.ship_name).encode(ExternalEncoding), input_name='ship_name'), namespace_, eol_))
        if self.call_sign is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scall_sign>%s</%scall_sign>%s' % (namespace_, self.gds_format_string(quote_xml(self.call_sign).encode(ExternalEncoding), input_name='call_sign'), namespace_, eol_))
        if self.imo_number is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%simo_number>%s</%simo_number>%s' % (namespace_, self.gds_format_string(quote_xml(self.imo_number).encode(ExternalEncoding), input_name='imo_number'), namespace_, eol_))
        if self.port_registry is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sport_registry>%s</%sport_registry>%s' % (namespace_, self.gds_format_string(quote_xml(self.port_registry).encode(ExternalEncoding), input_name='port_registry'), namespace_, eol_))
        if self.company_name is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scompany_name>%s</%scompany_name>%s' % (namespace_, self.gds_format_string(quote_xml(self.company_name).encode(ExternalEncoding), input_name='company_name'), namespace_, eol_))
        if self.class_society is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sclass_society>%s</%sclass_society>%s' % (namespace_, self.gds_format_string(quote_xml(self.class_society).encode(ExternalEncoding), input_name='class_society'), namespace_, eol_))
        if self.email is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%semail>%s</%semail>%s' % (namespace_, self.gds_format_string(quote_xml(self.email).encode(ExternalEncoding), input_name='email'), namespace_, eol_))
        if self.telephone is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%stelephone>%s</%stelephone>%s' % (namespace_, self.gds_format_string(quote_xml(self.telephone).encode(ExternalEncoding), input_name='telephone'), namespace_, eol_))
        if self.fax is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sfax>%s</%sfax>%s' % (namespace_, self.gds_format_string(quote_xml(self.fax).encode(ExternalEncoding), input_name='fax'), namespace_, eol_))
        if self.ship_type is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sship_type>%s</%sship_type>%s' % (namespace_, self.gds_format_string(quote_xml(self.ship_type).encode(ExternalEncoding), input_name='ship_type'), namespace_, eol_))
        if self.international_gross_tonnage is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sinternational_gross_tonnage>%s</%sinternational_gross_tonnage>%s' % (namespace_, self.gds_format_string(quote_xml(self.international_gross_tonnage).encode(ExternalEncoding), input_name='international_gross_tonnage'), namespace_, eol_))
        if self.international_net_tonnage is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sinternational_net_tonnage>%s</%sinternational_net_tonnage>%s' % (namespace_, self.gds_format_string(quote_xml(self.international_net_tonnage).encode(ExternalEncoding), input_name='international_net_tonnage'), namespace_, eol_))
        if self.loa is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sloa>%s</%sloa>%s' % (namespace_, self.gds_format_string(quote_xml(self.loa).encode(ExternalEncoding), input_name='loa'), namespace_, eol_))
        if self.lbp is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%slbp>%s</%slbp>%s' % (namespace_, self.gds_format_string(quote_xml(self.lbp).encode(ExternalEncoding), input_name='lbp'), namespace_, eol_))
        if self.breadth_moulded is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sbreadth_moulded>%s</%sbreadth_moulded>%s' % (namespace_, self.gds_format_string(quote_xml(self.breadth_moulded).encode(ExternalEncoding), input_name='breadth_moulded'), namespace_, eol_))
        if self.depth_moulded is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sdepth_moulded>%s</%sdepth_moulded>%s' % (namespace_, self.gds_format_string(quote_xml(self.depth_moulded).encode(ExternalEncoding), input_name='depth_moulded'), namespace_, eol_))
        if self.ecdis_maker is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%secdis_maker>%s</%secdis_maker>%s' % (namespace_, self.gds_format_string(quote_xml(self.ecdis_maker).encode(ExternalEncoding), input_name='ecdis_maker'), namespace_, eol_))
        if self.ecdis_model is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%secdis_model>%s</%secdis_model>%s' % (namespace_, self.gds_format_string(quote_xml(self.ecdis_model).encode(ExternalEncoding), input_name='ecdis_model'), namespace_, eol_))
        if self.captain_name is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scaptain_name>%s</%scaptain_name>%s' % (namespace_, self.gds_format_string(quote_xml(self.captain_name).encode(ExternalEncoding), input_name='captain_name'), namespace_, eol_))
        if self.captain_crew_id is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%scaptain_crew_id>%s</%scaptain_crew_id>%s' % (namespace_, self.gds_format_string(quote_xml(self.captain_crew_id).encode(ExternalEncoding), input_name='captain_crew_id'), namespace_, eol_))
        if self.maintain_paper_chart is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%smaintain_paper_chart>%s</%smaintain_paper_chart>%s' % (namespace_, self.gds_format_boolean(self.maintain_paper_chart, input_name='maintain_paper_chart'), namespace_, eol_))
        if self.ME_Particular is not None:
            self.ME_Particular.export(outfile, level, namespace_, name_='ME_Particular', pretty_print=pretty_print)
    def build(self, node):
        already_processed = set()
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ship_name':
            ship_name_ = child_.text
            ship_name_ = self.gds_validate_string(ship_name_, node, 'ship_name')
            self.ship_name = ship_name_
        elif nodeName_ == 'call_sign':
            call_sign_ = child_.text
            call_sign_ = self.gds_validate_string(call_sign_, node, 'call_sign')
            self.call_sign = call_sign_
        elif nodeName_ == 'imo_number':
            imo_number_ = child_.text
            imo_number_ = self.gds_validate_string(imo_number_, node, 'imo_number')
            self.imo_number = imo_number_
        elif nodeName_ == 'port_registry':
            port_registry_ = child_.text
            port_registry_ = self.gds_validate_string(port_registry_, node, 'port_registry')
            self.port_registry = port_registry_
        elif nodeName_ == 'company_name':
            company_name_ = child_.text
            company_name_ = self.gds_validate_string(company_name_, node, 'company_name')
            self.company_name = company_name_
        elif nodeName_ == 'class_society':
            class_society_ = child_.text
            class_society_ = self.gds_validate_string(class_society_, node, 'class_society')
            self.class_society = class_society_
        elif nodeName_ == 'email':
            email_ = child_.text
            email_ = self.gds_validate_string(email_, node, 'email')
            self.email = email_
        elif nodeName_ == 'telephone':
            telephone_ = child_.text
            telephone_ = self.gds_validate_string(telephone_, node, 'telephone')
            self.telephone = telephone_
        elif nodeName_ == 'fax':
            fax_ = child_.text
            fax_ = self.gds_validate_string(fax_, node, 'fax')
            self.fax = fax_
        elif nodeName_ == 'ship_type':
            ship_type_ = child_.text
            ship_type_ = self.gds_validate_string(ship_type_, node, 'ship_type')
            self.ship_type = ship_type_
        elif nodeName_ == 'international_gross_tonnage':
            international_gross_tonnage_ = child_.text
            international_gross_tonnage_ = self.gds_validate_string(international_gross_tonnage_, node, 'international_gross_tonnage')
            self.international_gross_tonnage = international_gross_tonnage_
        elif nodeName_ == 'international_net_tonnage':
            international_net_tonnage_ = child_.text
            international_net_tonnage_ = self.gds_validate_string(international_net_tonnage_, node, 'international_net_tonnage')
            self.international_net_tonnage = international_net_tonnage_
        elif nodeName_ == 'loa':
            loa_ = child_.text
            loa_ = self.gds_validate_string(loa_, node, 'loa')
            self.loa = loa_
        elif nodeName_ == 'lbp':
            lbp_ = child_.text
            lbp_ = self.gds_validate_string(lbp_, node, 'lbp')
            self.lbp = lbp_
        elif nodeName_ == 'breadth_moulded':
            breadth_moulded_ = child_.text
            breadth_moulded_ = self.gds_validate_string(breadth_moulded_, node, 'breadth_moulded')
            self.breadth_moulded = breadth_moulded_
        elif nodeName_ == 'depth_moulded':
            depth_moulded_ = child_.text
            depth_moulded_ = self.gds_validate_string(depth_moulded_, node, 'depth_moulded')
            self.depth_moulded = depth_moulded_
        elif nodeName_ == 'ecdis_maker':
            ecdis_maker_ = child_.text
            ecdis_maker_ = self.gds_validate_string(ecdis_maker_, node, 'ecdis_maker')
            self.ecdis_maker = ecdis_maker_
        elif nodeName_ == 'ecdis_model':
            ecdis_model_ = child_.text
            ecdis_model_ = self.gds_validate_string(ecdis_model_, node, 'ecdis_model')
            self.ecdis_model = ecdis_model_
        elif nodeName_ == 'captain_name':
            captain_name_ = child_.text
            captain_name_ = self.gds_validate_string(captain_name_, node, 'captain_name')
            self.captain_name = captain_name_
        elif nodeName_ == 'captain_crew_id':
            captain_crew_id_ = child_.text
            captain_crew_id_ = self.gds_validate_string(captain_crew_id_, node, 'captain_crew_id')
            self.captain_crew_id = captain_crew_id_
        elif nodeName_ == 'maintain_paper_chart':
            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, 'maintain_paper_chart')
            self.maintain_paper_chart = ival_
        elif nodeName_ == 'ME_Particular':
            obj_ = ME_Particular.factory()
            obj_.build(child_)
            self.ME_Particular = obj_
            obj_.original_tagname_ = 'ME_Particular'
# end class Property


class ME_Particular(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, ME_Maker=None, ME_Model=None, ME_Table=None):
        self.original_tagname_ = None
        self.ME_Maker = ME_Maker
        self.ME_Model = ME_Model
        self.ME_Table = ME_Table
    def factory(*args_, **kwargs_):
        if ME_Particular.subclass:
            return ME_Particular.subclass(*args_, **kwargs_)
        else:
            return ME_Particular(*args_, **kwargs_)
    factory = staticmethod(factory)
    def hasContent_(self):
        if (
            self.ME_Maker is not None or
            self.ME_Model is not None or
            self.ME_Table is not None
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespace_='', name_='ME_Particular', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ME_Particular')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_='', name_='ME_Particular', 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_='', name_='ME_Particular'):
        pass
    def exportChildren(self, outfile, level, namespace_='', name_='ME_Particular', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.ME_Maker is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sME_Maker>%s</%sME_Maker>%s' % (namespace_, self.gds_format_string(quote_xml(self.ME_Maker).encode(ExternalEncoding), input_name='ME_Maker'), namespace_, eol_))
        if self.ME_Model is not None:
            showIndent(outfile, level, pretty_print)
            outfile.write('<%sME_Model>%s</%sME_Model>%s' % (namespace_, self.gds_format_string(quote_xml(self.ME_Model).encode(ExternalEncoding), input_name='ME_Model'), namespace_, eol_))
        if self.ME_Table is not None:
            self.ME_Table.export(outfile, level, namespace_, name_='ME_Table', pretty_print=pretty_print)
    def build(self, node):
        already_processed = set()
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'ME_Maker':
            ME_Maker_ = child_.text
            ME_Maker_ = self.gds_validate_string(ME_Maker_, node, 'ME_Maker')
            self.ME_Maker = ME_Maker_
        elif nodeName_ == 'ME_Model':
            ME_Model_ = child_.text
            ME_Model_ = self.gds_validate_string(ME_Model_, node, 'ME_Model')
            self.ME_Model = ME_Model_
        elif nodeName_ == 'ME_Table':
            obj_ = ME_Table.factory()
            obj_.build(child_)
            self.ME_Table = obj_
            obj_.original_tagname_ = 'ME_Table'
# end class ME_Particular


class ME_Table(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, cell=None):
        self.original_tagname_ = None
        if cell is None:
            self.cell = []
        else:
            self.cell = cell
    def factory(*args_, **kwargs_):
        if ME_Table.subclass:
            return ME_Table.subclass(*args_, **kwargs_)
        else:
            return ME_Table(*args_, **kwargs_)
    factory = staticmethod(factory)
    def hasContent_(self):
        if (
            self.cell
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespace_='', name_='ME_Table', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='ME_Table')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_='', name_='ME_Table', 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_='', name_='ME_Table'):
        pass
    def exportChildren(self, outfile, level, namespace_='', name_='ME_Table', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        for cell_ in self.cell:
            cell_.export(outfile, level, namespace_, name_='cell', pretty_print=pretty_print)
    def build(self, node):
        already_processed = set()
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'cell':
            obj_ = cell.factory()
            obj_.build(child_)
            self.cell.append(obj_)
            obj_.original_tagname_ = 'cell'
# end class ME_Table


class cell(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, column=None, row=None, valueOf_=None):
        self.original_tagname_ = None
        self.column = _cast(None, column)
        self.row = _cast(None, row)
        self.valueOf_ = valueOf_
    def factory(*args_, **kwargs_):
        if cell.subclass:
            return cell.subclass(*args_, **kwargs_)
        else:
            return cell(*args_, **kwargs_)
    factory = staticmethod(factory)
    def hasContent_(self):
        if (
            self.valueOf_
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespace_='', name_='cell', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='cell')
        if self.hasContent_():
            outfile.write('>')
            outfile.write(str(self.valueOf_).encode(ExternalEncoding))
            self.exportChildren(outfile, level + 1, namespace_='', name_='cell', 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_='', name_='cell'):
        if self.column is not None and 'column' not in already_processed:
            already_processed.add('column')
            outfile.write(' column=%s' % (self.gds_format_string(quote_attrib(self.column).encode(ExternalEncoding), input_name='column'), ))
        if self.row is not None and 'row' not in already_processed:
            already_processed.add('row')
            outfile.write(' row=%s' % (self.gds_format_string(quote_attrib(self.row).encode(ExternalEncoding), input_name='row'), ))
    def exportChildren(self, outfile, level, namespace_='', name_='cell', fromsubclass_=False, pretty_print=True):
        pass
    def build(self, node):
        already_processed = set()
        self.buildAttributes(node, node.attrib, already_processed)
        self.valueOf_ = get_all_text_(node)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        value = find_attr_value_('column', node)
        if value is not None and 'column' not in already_processed:
            already_processed.add('column')
            self.column = value
        value = find_attr_value_('row', node)
        if value is not None and 'row' not in already_processed:
            already_processed.add('row')
            self.row = value
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        pass
# end class cell


class initial_report(GeneratedsSuper):
    subclass = None
    superclass = None
    def __init__(self, Property=None):
        self.original_tagname_ = None
        self.Property = Property
    def factory(*args_, **kwargs_):
        if initial_report.subclass:
            return initial_report.subclass(*args_, **kwargs_)
        else:
            return initial_report(*args_, **kwargs_)
    factory = staticmethod(factory)
    def hasContent_(self):
        if (
            self.Property is not None
        ):
            return True
        else:
            return False
    def export(self, outfile, level, namespace_='', name_='initial_report', namespacedef_='', pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.original_tagname_ is not None:
            name_ = self.original_tagname_
        showIndent(outfile, level, pretty_print)
        outfile.write('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
        already_processed = set()
        self.exportAttributes(outfile, level, already_processed, namespace_, name_='initial_report')
        if self.hasContent_():
            outfile.write('>%s' % (eol_, ))
            self.exportChildren(outfile, level + 1, namespace_='', name_='initial_report', 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_='', name_='initial_report'):
        pass
    def exportChildren(self, outfile, level, namespace_='', name_='initial_report', fromsubclass_=False, pretty_print=True):
        if pretty_print:
            eol_ = '\n'
        else:
            eol_ = ''
        if self.Property is not None:
            self.Property.export(outfile, level, namespace_, name_='Property', pretty_print=pretty_print)
    def build(self, node):
        already_processed = set()
        self.buildAttributes(node, node.attrib, already_processed)
        for child in node:
            nodeName_ = Tag_pattern_.match(child.tag).groups()[-1]
            self.buildChildren(child, node, nodeName_)
        return self
    def buildAttributes(self, node, attrs, already_processed):
        pass
    def buildChildren(self, child_, node, nodeName_, fromsubclass_=False):
        if nodeName_ == 'Property':
            obj_ = Property.factory()
            obj_.build(child_)
            self.Property = obj_
            obj_.original_tagname_ = 'Property'
# end class initial_report


GDSClassesMapping = {
}


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, silence=False):
    parser = None
    doc = parsexml_(inFileName, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Property'
        rootClass = Property
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='',
            pretty_print=True)
    return rootObj


def parseEtree(inFileName, silence=False):
    parser = None
    doc = parsexml_(inFileName, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Property'
        rootClass = Property
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    mapping = {}
    rootElement = rootObj.to_etree(None, name_=rootTag, mapping_=mapping)
    reverse_mapping = rootObj.gds_reverse_node_mapping(mapping)
    if not silence:
        content = etree_.tostring(
            rootElement, pretty_print=True,
            xml_declaration=True, encoding="utf-8")
        sys.stdout.write(content)
        sys.stdout.write('\n')
    return rootObj, rootElement, mapping, reverse_mapping


def parseString(inString, silence=False):
    from StringIO import StringIO
    parser = None
    doc = parsexml_(StringIO(inString), parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Property'
        rootClass = Property
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('<?xml version="1.0" ?>\n')
        rootObj.export(
            sys.stdout, 0, name_=rootTag,
            namespacedef_='')
    return rootObj


def parseLiteral(inFileName, silence=False):
    parser = None
    doc = parsexml_(inFileName, parser)
    rootNode = doc.getroot()
    rootTag, rootClass = get_root_tag(rootNode)
    if rootClass is None:
        rootTag = 'Property'
        rootClass = Property
    rootObj = rootClass.factory()
    rootObj.build(rootNode)
    # Enable Python to collect the space used by the DOM.
    doc = None
    if not silence:
        sys.stdout.write('#from initital import *\n\n')
        sys.stdout.write('import initital as model_\n\n')
        sys.stdout.write('rootObj = model_.rootClass(\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__ = [
    "ME_Particular",
    "ME_Table",
    "Property",
    "cell",
    "initial_report"
]
