I'm working with multiple XSD class bindings using PyXB 1.2.6. I want to get the order of sub-element names of an arbitrary element type definition. So far I came up with this code:
from pyxb.binding.basis import element
def get_sub_elements(type_definition):
"""Returns an ordered list of the respective
sub-elements of the given PyXB element.
"""
if isinstance(type_definition, element):
type_definition = type_definition._element__typeDefinition()
element_map = type_definition._ElementMap
return tuple(name.localName() for name in element_map.keys())
However, since the _ElementMap
is a dict
, it yields the keys in random order. I however need the order of the elements, as it is defined in the corresponding XSD. How can I achieve that?