# Path: xtuml/meta.py
# def navigate_any(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
# 
#     The resulting query will return an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_any(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
# 
#     The resulting query will return an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_many(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
#     
#     The resulting query will return a set of instances.
#     '''
#     return NavChain(instance_or_set)
# 
# Path: bridgepoint/ooaofooa.py
# class OoaOfOoaException(Exception):
# class Domain(xtuml.MetaModel):
# class ModelLoader(xtuml.ModelLoader):
#     def __init__(self, id_generator=None):
#     def add_symbol(self, name, handle):
#     def find_symbol(self, name):
# def is_contained_in(pe_pe, root):
# def is_global(pe_pe):
# def get_defining_component(pe_pe):
# def get_attribute_type(o_attr):
# def _get_data_type_name(s_dt):
# def _get_related_attributes(r_rgo, r_rto):
# def mk_enum(s_edt):
# def mk_bridge(metamodel, s_brg):
# def mk_external_entity(metamodel, s_ee):
# def mk_function(metamodel, s_sync):
# def mk_constant(cnst_syc):
# def mk_operation(metaclass, o_tfr):
# def mk_derived_attribute(metaclass, o_dbattr):
# def mk_class(m, o_obj, derived_attributes=False):
# def mk_simple_association(m, r_simp):
# def mk_linked_association(m, r_assoc):
#     def _mk_assoc(side1, side2):
# def mk_subsuper_association(m, r_subsup):
# def mk_derived_association(m, r_comp):
# def mk_association(m, r_rel):
# def mk_component(bp_model, c_c=None, derived_attributes=False):
#     def __init__(self, load_globals=True):
#     def filename_input(self, path_or_filename):
#     def build_component(self, name=None, derived_attributes=False):
# def _mk_loader(resource, load_globals):
# def load_metamodel(resource=None, load_globals=True):
# def load_component(resource, name=None, load_globals=True):
# def delete_globals(m, disconnect=False):
#     EE = collections.namedtuple(s_ee.Key_Lett, names)


import sys
import optparse
import logging
import xtuml
import xml.etree.ElementTree as ET
import xml.dom.minidom
from xtuml import navigate_any as nav_any
from xtuml import navigate_any as nav_one
from xtuml import navigate_many as nav_many
from bridgepoint import ooaofooa
        return mapped_type


def build_enum_type(s_edt):
    '''
    Build an xsd simpleType out of a S_EDT.
    '''
    s_dt = nav_one(s_edt).S_DT[17]()
    enum = ET.Element('xs:simpleType', name=s_dt.name)
    enum_list = ET.SubElement(enum, 'xs:restriction', base='xs:string')
    
    first_filter = lambda selected: not nav_one(selected).S_ENUM[56, 'succeeds']()
    
    s_enum = nav_any(s_edt).S_ENUM[27](first_filter)
    while s_enum:
        ET.SubElement(enum_list, 'xs:enumeration', value=s_enum.name)
        s_enum = nav_one(s_enum).S_ENUM[56, 'precedes']()
    
    return enum


def build_struct_type(s_sdt):
    '''
    Build an xsd complexType out of a S_SDT.
    '''
    s_dt = nav_one(s_sdt).S_DT[17]()
    struct = ET.Element('xs:complexType', name=s_dt.name)
    
    first_filter = lambda selected: not nav_one(selected).S_MBR[46, 'succeeds']()
    

# Path: xtuml/meta.py
# def navigate_any(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
# 
#     The resulting query will return an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_any(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
# 
#     The resulting query will return an instance or None.
#     '''
#     return NavOneChain(instance_or_set)
# 
# Path: xtuml/meta.py
# def navigate_many(instance_or_set):
#     '''
#     Initialize a navigation from an instance, or a set of instances, to 
#     associated instances across a one-to-many or many-to-many association.
#     
#     The resulting query will return a set of instances.
#     '''
#     return NavChain(instance_or_set)
# 
# Path: bridgepoint/ooaofooa.py
# class OoaOfOoaException(Exception):
# class Domain(xtuml.MetaModel):
# class ModelLoader(xtuml.ModelLoader):
#     def __init__(self, id_generator=None):
#     def add_symbol(self, name, handle):
#     def find_symbol(self, name):
# def is_contained_in(pe_pe, root):
# def is_global(pe_pe):
# def get_defining_component(pe_pe):
# def get_attribute_type(o_attr):
# def _get_data_type_name(s_dt):
# def _get_related_attributes(r_rgo, r_rto):
# def mk_enum(s_edt):
# def mk_bridge(metamodel, s_brg):
# def mk_external_entity(metamodel, s_ee):
# def mk_function(metamodel, s_sync):
# def mk_constant(cnst_syc):
# def mk_operation(metaclass, o_tfr):
# def mk_derived_attribute(metaclass, o_dbattr):
# def mk_class(m, o_obj, derived_attributes=False):
# def mk_simple_association(m, r_simp):
# def mk_linked_association(m, r_assoc):
#     def _mk_assoc(side1, side2):
# def mk_subsuper_association(m, r_subsup):
# def mk_derived_association(m, r_comp):
# def mk_association(m, r_rel):
# def mk_component(bp_model, c_c=None, derived_attributes=False):
#     def __init__(self, load_globals=True):
#     def filename_input(self, path_or_filename):
#     def build_component(self, name=None, derived_attributes=False):
# def _mk_loader(resource, load_globals):
# def load_metamodel(resource=None, load_globals=True):
# def load_component(resource, name=None, load_globals=True):
# def delete_globals(m, disconnect=False):
#     EE = collections.namedtuple(s_ee.Key_Lett, names)


# Path: bridgepoint/gen_xsd_schema.py
import sys
import optparse
import logging
import xtuml
import xml.etree.ElementTree as ET
import xml.dom.minidom
from xtuml import navigate_any as nav_any
from xtuml import navigate_any as nav_one
from xtuml import navigate_many as nav_many
from bridgepoint import ooaofooa

        return mapped_type


def build_enum_type(s_edt):
    '''
    Build an xsd simpleType out of a S_EDT.
    '''
    s_dt = nav_one(s_edt).S_DT[17]()
    enum = ET.Element('xs:simpleType', name=s_dt.name)
    enum_list = ET.SubElement(enum, 'xs:restriction', base='xs:string')
    
    first_filter = lambda selected: not nav_one(selected).S_ENUM[56, 'succeeds']()
    
    s_enum = nav_any(s_edt).S_ENUM[27](first_filter)
    while s_enum:
        ET.SubElement(enum_list, 'xs:enumeration', value=s_enum.name)
        s_enum = nav_one(s_enum).S_ENUM[56, 'precedes']()
    
    return enum


def build_struct_type(s_sdt):
    '''
    Build an xsd complexType out of a S_SDT.
    '''
    s_dt = nav_one(s_sdt).S_DT[17]()
    struct = ET.Element('xs:complexType', name=s_dt.name)
    
    first_filter = lambda selected: not nav_one(selected).S_MBR[46, 'succeeds']()
    

    s_mbr = nav_any(s_sdt).S_MBR[44](first_filter)