Below is the complete ant target which I am running to insert the driver to my wildfly standalone.xml:
<target name="xmlrewrite" >
<!--Driver-->
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
<xmltask source="standalone.xml" dest="standalone.xml" report="true">
<copy path="//driver[@module='com.oracle.ojdbc6']/text()" property="modelexists"/>
<insert
path="*[local-name()='server']/*[local-name()='profile']/*[local-name()='subsystem'][3]/*[local-name()='datasources']/*[local-name()='drivers']"
unless="modelexists">
<![CDATA[
<driver name="oracle" module="com.oracle.ojdbc6">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
]]>
</insert>
</xmltask>
</target>
As per my understanding, the entry should be made in the standalone.xml only if it is not already present, since i am using unless="modelexists".
But apparently it is making a new entry for oracle driver with an additional xmlns="", which makes two entries of oracle and this causes my build to fail.
Please let me know if you would need any more info.
I'm guessing the
standalone.xmlfile is related to JBoss. The XML elements in a JBossstandalone.xmlare in XML namespaces. So, the<copy>element nested under<xmltask>will need to be namespace-aware: