'Loads the proper filter by the type attribute of elem'

@classmethod
def from_element(cls, elem):

    rval = ToolParameterSanitizer()
    rval._invalid_char = elem.get('invalid_char', cls.DEFAULT_INVALID_CHAR)
    rval.sanitize = galaxy.util.string_as_bool(elem.get('sanitize', 'True'))
    for valid_elem in elem.findall('valid'):
        rval._valid_chars = rval.get_valid_by_name(valid_elem.get('initial', 'default'))
        for action_elem in valid_elem:
            preset = rval.get_valid_by_name(action_elem.get('preset', 'none'))
            valid_value = [val for val in action_elem.get('value', [])]
            if (action_elem.tag.lower() == 'add'):
                for val in (preset + valid_value):
                    if (val not in rval._valid_chars):
                        rval._valid_chars.append(val)
            elif (action_elem.tag.lower() == 'remove'):
                for val in (preset + valid_value):
                    while (val in rval._valid_chars):
                        rval._valid_chars.remove(val)
            else:
                log.debug(('Invalid    action    tag    in    valid:    %s' % action_elem.tag))
    for mapping_elem in elem.findall('mapping'):
        rval._mapped_chars = rval.get_mapping_by_name(mapping_elem.get('initial', 'default'))
        for action_elem in mapping_elem:
            map_source = action_elem.get('source', None)
            map_target = action_elem.get('target', None)
            preset = rval.get_mapping_by_name(action_elem.get('preset', 'none'))
            if (action_elem.tag.lower() == 'add'):
                rval._mapped_chars.update(preset)
                if (None not in [map_source, map_target]):
                    rval._mapped_chars[map_source] = map_target
            elif (action_elem.tag.lower() == 'remove'):
                for map_key in preset.keys():
                    if (map_key in rval._mapped_chars):
                        del rval._mapped_chars[map_key]
                if ((map_source is not None) and (map_key in rval._mapped_chars)):
                    del rval._mapped_chars[map_key]
            else:
                log.debug(('Invalid    action    tag    in    mapping:    %s' % action_elem.tag))
    return rval
