'convert data generated from ocr parser to a dictionary
@param s3dataxml: output of S3OCRImageParser
@return: python dictionary equalant to the input xml'

def __temp_ocrdataxml_parser(self, s3ocrdataxml):

    s3ocrdataxml_etree = etree.fromstring(s3ocrdataxml)
    s3ocrdatadict = Storage()
    s3xml_root = s3ocrdataxml_etree
    resource_element = s3xml_root.getchildren()[0]
    s3ocr_root = etree.Element('s3ocr')
    if self.r.component:
        s3ocr_root.append(resource_element)
    else:
        componentetrees = []
        mres = etree.Element('resource')
        for attr in resource_element.attrib.keys():
            mres.set(attr, resource_element.attrib.get(attr))
        for field_element in resource_element:
            if (field_element.tag in ['data', 'reference']):
                mres.append(field_element)
            elif (field_element.tag == 'resource'):
                componentetrees.append(field_element)
        serialised_component_etrees = componentetrees
        s3ocr_root.append(mres)
        for res in serialised_component_etrees:
            s3ocr_root.append(res)
    for resource in s3ocr_root:
        resourcename = resource.attrib.get('name')
        s3ocrdatadict[resourcename] = Storage()
        for field in resource:
            if (field.tag == 'reference'):
                fieldname = field.attrib.get('field')
                ref_res_field = field.getchildren()[0]
                datafield = ref_res_field.getchildren()[0]
                value = datafield.text
            else:
                fieldname = field.attrib.get('field')
                value = field.attrib.get('value')
                text = field.text
                if (not value):
                    value = text
            s3ocrdatadict[resourcename][fieldname] = value
    return s3ocrdatadict
