def dict2xmlsubmission(submission_dict, xform, instance_id, submission_date): """Creates and xml submission from an appropriate dict (& other data) :param dict submission_dict: A dict containing form submission data. :param onadata.apps.logger.models.XForm xfrom: The submission's XForm. :param string instance_id: The submission/instance `uuid`. :param string submission_date: An isoformatted datetime string. :return: An xml submission string :rtype: string """ return (u'<?xml version="1.0" ?>' '<{0} id="{1}" instanceID="uuid:{2}" submissionDate="{3}">{4}' '</{0}>'.format( json.loads(xform.json).get('name', xform.id_string), xform.id_string, instance_id, submission_date, dict2xml(submission_dict).replace('\n', ''))).encode('utf-8')
def dict2xmlsubmission(submission_dict, xform, instance_id, submission_date): """Creates and xml submission from an appropriate dict (& other data) :param dict submission_dict: A dict containing form submission data. :param onadata.apps.logger.models.XForm xfrom: The submission's XForm. :param string instance_id: The submission/instance `uuid`. :param string submission_date: An isoformatted datetime string. :return: An xml submission string :rtype: string """ return (u'<?xml version="1.0" ?>' '<{0} id="{1}" instanceID="uuid:{2}" submissionDate="{3}" ' 'xmlns="http://opendatakit.org/submissions">{4}' '</{0}>'.format( json.loads(xform.json).get('name', xform.id_string), xform.id_string, instance_id, submission_date, dict2xml(submission_dict).replace('\n', ''))).encode('utf-8')