'Split the readable fields in the resource table into
reference and non-reference fields.
@param skip: list of field names to skip
@param data: data fields to include (None for all)
@param references: foreign key fields to include (None for all)'

def split_fields(self, skip=[], data=None, references=None):

    rfields = self.rfields
    dfields = self.dfields
    if ((rfields is None) or (dfields is None)):
        if (self.tablename == 'gis_location'):
            if (('wkt' not in skip) and (current.auth.permission.format != 'cap')):
                skip.append('wkt')
            if (current.deployment_settings.get_gis_spatialdb() and ('the_geom' not in skip)):
                skip.append('the_geom')
        xml = current.xml
        UID = xml.UID
        IGNORE_FIELDS = xml.IGNORE_FIELDS
        FIELDS_TO_ATTRIBUTES = xml.FIELDS_TO_ATTRIBUTES
        show_ids = current.xml.show_ids
        rfields = []
        dfields = []
        table = self.table
        pkey = table._id.name
        for f in table.fields:
            if ((f == UID) or (f in skip) or (f in IGNORE_FIELDS)):
                if ((f != pkey) or (not show_ids)):
                    continue
            if (s3_has_foreign_key(table[f]) and (f not in FIELDS_TO_ATTRIBUTES) and ((references is None) or (f in references))):
                rfields.append(f)
            elif ((data is None) or (f in data) or (f in FIELDS_TO_ATTRIBUTES)):
                dfields.append(f)
        self.rfields = rfields
        self.dfields = dfields
    return (rfields, dfields)
