CHECK THE DOCUMENT AGAINST IT'S SCHEMA
    
    returns: cleaned-up-document, error_list

def schema_rolne_check(doc, schema):
    '''
    CHECK THE DOCUMENT AGAINST IT'S SCHEMA
    
    returns: cleaned-up-document, error_list
    '''
    import standard_types as st
    error_list = []
    #
    # PASS ONE: FORWARD CHECK OF DOC
    #
    # this pass verifies that each entry in the document
    # has a corresponding entry in the schema
    #
    exclusive_flag = True
    if schema.list_names("#!MARDS_schema_en_1.0"):
        if schema["#!MARDS_schema_en_1.0"].get_value("exclusive")=="false":
            exclusive_flag = False
    if exclusive_flag:
        # print "jj", schema
        el = check_schema_coverage(doc, schema)
        error_list.extend(el)
    #
    # PASS TWO: REQUIREMENTS CHECK OF SCHEMA
    #
    # this pass verifies that any 'required' entries in the
    # schema are met. It auto-inserts if allowed. Otherwise,
    # it adds an error.
    el = sub_schema_requirements(doc, schema)
    error_list.extend(el)
    #
    # PASS THREE: TREATMENT CHECKS
    #
    el = sub_schema_treatments(doc, schema)
    error_list.extend(el)
    #
    # PASS FOUR: TYPE CHECKS AND NORMALIZATION
    #
    el = st.apply_schema_types(doc, schema)
    error_list.extend(el)
    #
    #
    # PASS FIVE: RAISE_ERROR CHECKS
    #
    el = sub_schema_raises(doc, schema)
    error_list.extend(el)
    #
    return doc, error_list