1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add a note about the limitations of a namespace check

This commit is contained in:
Marko Stanković 2017-09-15 11:00:04 +02:00 committed by Dag Wieers
parent 16ca412bd7
commit 85649876d0

View file

@ -546,6 +546,8 @@ def set_target_inner(module, tree, xpath, namespaces, attribute, value):
changed = check_or_make_target(module, tree, xpath, namespaces) changed = check_or_make_target(module, tree, xpath, namespaces)
except Exception as e: except Exception as e:
missing_namespace = "" missing_namespace = ""
# NOTE: This checks only the namespaces defined in root element!
# TODO: Implement a more robust check to check for child namespaces' existance
if len(tree.getroot().nsmap) > 0 and ":" not in xpath: if len(tree.getroot().nsmap) > 0 and ":" not in xpath:
missing_namespace = "XML document has namespace(s) defined, but no namespace prefix(es) used in xpath!\n" missing_namespace = "XML document has namespace(s) defined, but no namespace prefix(es) used in xpath!\n"
module.fail_json(msg="%sXpath %s causes a failure: %s\n -- tree is %s" % module.fail_json(msg="%sXpath %s causes a failure: %s\n -- tree is %s" %