'Add details of the item element
@param data: the list of data elements in the item element
@param table: the table for the data
@param details: the existing details rows list (to append to)'

@staticmethod
def _add_item_details(data, table, details=None, prefix=False):

    tablename = table._tablename
    if (details is None):
        details = []
    first = None
    firstString = None
    header = None
    for child in data:
        f = child.get('field', None)
        if (f not in table.fields):
            continue
        elif (f == 'wkt'):
            continue
        field = table[f]
        ftype = str(field.type)
        value = child.get('value', None)
        if (not value):
            value = S3XML.xml_decode(child.text)
        try:
            value = S3Importer._decode_data(field, value)
        except:
            pass
        if value:
            value = s3_unicode(value)
        else:
            value = ''
        if ((f != None) and (value != None)):
            headerText = P(B(('%s:    ' % f)), value)
            if (not first):
                first = headerText
            if ((ftype == 'string') and (not firstString)):
                firstString = headerText
            if (f == 'name'):
                header = headerText
            if prefix:
                details.append(TR(TH(('%s.%s:' % (tablename, f))), TD(value)))
            else:
                details.append(TR(TH(('%s:' % f)), TD(value)))
    if (not header):
        if firstString:
            header = firstString
        else:
            header = first
    return (header, details)
