'Read data from a <resource> element
@param element: the element
@param table: the DB table
@param tree: the import tree
@param files: uploaded files
@return: True if successful, False if not (sets self.error)'

def parse(self, element, original=None, table=None, tree=None, files=None):

    s3db = current.s3db
    xml = current.xml
    ERROR = xml.ATTRIBUTE['error']
    self.element = element
    if (table is None):
        tablename = element.get(xml.ATTRIBUTE['name'])
        table = s3db.table(tablename)
        if (table is None):
            self.error = current.ERROR.BAD_RESOURCE
            element.set(ERROR, s3_unicode(self.error))
            return False
    else:
        tablename = table._tablename
    self.table = table
    self.tablename = tablename
    UID = xml.UID
    if (original is None):
        original = S3Resource.original(table, element, mandatory=self._mandatory_fields())
    elif (isinstance(original, basestring) and (UID in table.fields)):
        query = (table[UID] == original)
        pkeys = set((fname for fname in table.fields if table[fname].unique))
        fields = S3Resource.import_fields(table, pkeys, mandatory=self._mandatory_fields())
        original = current.db(query).select(limitby=(0, 1), *fields).first()
    else:
        original = None
    postprocess = s3db.get_config(tablename, 'xml_post_parse')
    data = xml.record(table, element, files=files, original=original, postprocess=postprocess)
    if (data is None):
        self.error = current.ERROR.VALIDATION_ERROR
        self.accepted = False
        if (not element.get(ERROR, False)):
            element.set(ERROR, s3_unicode(self.error))
        return False
    self.data = data
    MCI = xml.MCI
    MTIME = xml.MTIME
    self.uid = data.get(UID)
    if (original is not None):
        self.original = original
        self.id = original[table._id.name]
        if ((not current.response.s3.synchronise_uuids) and (UID in original)):
            self.uid = self.data[UID] = original[UID]
    if (MTIME in data):
        self.mtime = data[MTIME]
    if (MCI in data):
        self.mci = data[MCI]
    return True
