diff --git a/trans.py b/trans.py index 62e5e7ce079fbd6872415af8c416fdb13d5ce150..7b21703adad1f8a865e00a3549b2acc2bbc0792a 100644 --- a/trans.py +++ b/trans.py @@ -21,9 +21,11 @@ def cert_to_xml(cert_doc): } cert_doc['DCC']['administrativeData']['dccSoftware'].append(s) try: - xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils) - xml = etree.canonicalize(prettify_xml(xml, indent=2, debug=False)) - + xml = render_template(dcc_template, doc=cert_doc['DCC'], utils=utils) + xml = etree.canonicalize(xml, with_comments=True, strip_text=True) + # Bad side-effect: adds XML declaration again + xml = prettify_xml(xml, indent=2, debug=False) + xml = etree.canonicalize(xml, with_comments=True) except Exception as error: xml = '<error>' + str(error) + '</error>\n'