Hi I am new at AWS and python. I am trying to do a post lambda function in AWS that receives the the next json:
{
"xsd_name": "file.xsd",
"service_type": "E",
"version":"1",
"xml_body": "<Mensagge...>"
}
I have the next lambda handler:
def lambda_handler(event, context):
xml_body = BytesIO(event['xml_body'].encode())
xsd_name = event['xsd_name']
service_type = event['service_type']
version = event['version']
print(xml_body)
print(xsd_name)
print(service_type)
print(version)
result = validate('folder/'+ service_type + "/" + version + "/" + xsd_name, xml_body)
return {
'result': str(result)
}
and a validate function:
def validate(xsd_path, xml_body):
print(xsd_path)
s3 = boto3.resource('s3')
for obj in s3.Bucket(name='BucketFather').objects.filter(Prefix=xsd_path):
filename = obj.key.split('/')[-1]
print(filename)
xmlschema = etree.XMLSchema(filename)
xml_doc = etree.parse(xml_body)
result = xmlschema.validate(xml_doc)
if not result:
result = xmlschema.error_log
return result
the problem is that I have to go to the budget and get the xsd file name and compare with the xmlbody. But I dont know how to compare them. Could anybody help me? Thanks