(element_xml)
return element_spec
Parses an <element> element in the schema.
Parses an <element> element in the schema.
Parses an <element > element in the schema .
def _parse_element(element_xml):
  """Parses an <element> element in the schema."""
  name = element_xml.get('name')
  if not name:
    raise ValueError('Element must always have a name')
  repeated = _str2bool(element_xml.get('repeated'))
  on_demand = _str2bool(element_xml.get('on_demand'))

  attributes = collections.OrderedDict()
  attributes_xml = element_xml.find('attributes')
  if attributes_xml is not None:
    for attribute_xml in attributes_xml.findall('attribute'):
      attributes[attribute_xml.get('name')] = _parse_attribute(attribute_xml)

  identifier = None
  namespace = None
  for attribute_spec in attributes.values():
    if attribute_spec.type == attribute.Identifier:
      identifier = attribute_spec.name
      namespace = element_xml.get('namespace') or name

  children = collections.OrderedDict()
  children_xml = element_xml.find('children')
  if children_xml is not None:
    for child_xml in children_xml.findall('element'):
      children[child_xml.get('name')] = _parse_element(child_xml)

  element_spec = ElementSpec(
      name, repeated, on_demand, identifier, namespace, attributes, children)

  recursive = _str2bool(element_xml.get('recursive'))
  if recursive:
    element_spec.children[name] = element_spec

  common_keys = set(element_spec.attributes).intersection(element_spec.children)
  if common_keys:
    raise RuntimeError(
        'Element \'{}\' contains the following attributes and children with '
        'the same name: \'{}\'. This violates the design assumptions of '
        'this library. Please file a bug report. Thank you.'
        .format(name, sorted(common_keys)))

  return element_spec
def _parse_element ( element_xml ) : name = element_xml . get ( 'name' ) if not name : raise ValueError ( 'Element must always have a name' ) repeated = _str2bool ( element_xml . get ( 'repeated' ) ) on_demand = _str2bool ( element_xml . get ( 'on_demand' ) ) attributes = collections . OrderedDict ( ) attributes_xml = element_xml . find ( 'attributes' ) if attributes_xml is not None : for attribute_xml in attributes_xml . findall ( 'attribute' ) : attributes [ attribute_xml . get ( 'name' ) ] = _parse_attribute ( attribute_xml ) identifier = None namespace = None for attribute_spec in attributes . values ( ) : if attribute_spec . type == attribute . Identifier : identifier = attribute_spec . name namespace = element_xml . get ( 'namespace' ) or name children = collections . OrderedDict ( ) children_xml = element_xml . find ( 'children' ) if children_xml is not None : for child_xml in children_xml . findall ( 'element' ) : children [ child_xml . get ( 'name' ) ] = _parse_element ( child_xml ) element_spec = ElementSpec ( name , repeated , on_demand , identifier , namespace , attributes , children ) recursive = _str2bool ( element_xml . get ( 'recursive' ) ) if recursive : element_spec . children [ name ] = element_spec common_keys = set ( element_spec . attributes ) . intersection ( element_spec . children ) if common_keys : raise RuntimeError ( 'Element \'{}\' contains the following attributes and children with ' 'the same name: \'{}\'. This violates the design assumptions of ' 'this library. Please file a bug report. Thank you.' . format ( name , sorted ( common_keys ) ) ) return element_spec