Using the Ansible module community.general.xml, I am attempting to add a child node to the following XML data: (saved into namespace-test.xml)
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq:core ">
</core>
</configuration>
The data I would like to add, under the core node, is:
<xi:include href="/conf/xmlconfig-to-include.xml"/>
The Ansible task I am running is:
- name: include modular XML configuration file
community.general.xml:
path: namespace-test.xml
xpath: /conf:configuration/core:core
input_type: xml
add_children:
- '<xi:include href="/conf/xmlconfig-to-include.xml"/>'
namespaces:
conf: urn:activemq
core: urn:activemq:core
xi: "http://www.w3.org/2001/XInclude"
pretty_print: yes
I am expecting to get this result:
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq:core ">
<xi:include href="/conf/xmlconfig-to-include.xml"/>
</core>
</configuration>
But I am getting the following error message, instead:
Error while parsing child element: Namespace prefix xi on include is not defined
More information after the very usefull options suggested by β.εηοιτ.βε.
The idempotent option did not meet the additionnal requirements (non-specified initially) that I need more than one include in the XML block.
This is really what I was aiming for:
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq:core ">
<xi:include href="/conf/addresses.xml"/>
<xi:include href="/conf/address-settings.xml"/>
<xi:include href="/conf/security-settings.xml"/>
</core>
</configuration>