SCHEMA mini-recompile for:

      each SEARCH then MATCH function
      each TYPE then CHOICE function
    
    given the doc, it returns a schema copy that implements the match

def schema_match_up(doc, schema):
    '''
    SCHEMA mini-recompile for:

      each SEARCH then MATCH function
      each TYPE then CHOICE function
    
    given the doc, it returns a schema copy that implements the match
    '''
    copy = schema.copy(seq_prefix="", seq_suffix="")
    copy = _schema_match_up_search(doc, copy)
    copy = _schema_match_up_type_choice(doc, copy)
    return copy