diff --git a/src/pyff/builtins.py b/src/pyff/builtins.py index a3a69ae2..89b623fb 100644 --- a/src/pyff/builtins.py +++ b/src/pyff/builtins.py @@ -552,10 +552,6 @@ def _nop(x): out = output_file data = req.t - # clean unused namespaces - the working document isn't always XML (eg discojson* produce JSON) - if isinstance(data, (etree._Element, etree._ElementTree)): - etree.cleanup_namespaces(data) - if not req.args.get('raw'): data = dumptree(req.t, pretty_print=req.args.get('pretty_print')) diff --git a/src/pyff/samlmd.py b/src/pyff/samlmd.py index b23f41b4..ae00ce6b 100644 --- a/src/pyff/samlmd.py +++ b/src/pyff/samlmd.py @@ -488,6 +488,12 @@ def entitiesdescriptor( ent_insert = deepcopy(ent_insert) t.append(ent_insert) + # clean unused namespaces + # Keep xs: and xsi:, as these are crucial - and xs: is used only + # in attribute values, so may appear as unused. + keep_ns_prefixes = ['xs', 'xsi'] + etree.cleanup_namespaces(t, keep_ns_prefixes=keep_ns_prefixes) + if config.devel_write_xml_to_file: import os