docs: def make_valid_xml_name(key, attr):
      """Tests an XML name and fixes it if invalid"""
      LOG.info('Inside make_valid_xml_name(). Testing key "%s" with attr "%s"' % (
          unicode_me(key), unicode_me(attr))
      )
      key = escape_xml(key)
      attr = escape_xml(attr)
      
      # pass through if key is already valid
      if key_is_valid_xml(key):
          return key, attr
          
      # prepend a lowercase n if the key is numeric
      if key.isdigit():
          return 'n%s' % (key), attr
          
      # replace spaces with underscores if that fixes the problem
      if key_is_valid_xml(key.replace(' ', '_')):
          return key.replace(' ', '_'), attr
          
      # key is still invalid - move it into a name attribute
      attr['name'] = key
      key = 'key'
      return key, attr