蚂蚁xmltask添加一个空白的xmlns ="" [英] Ant xmltask adding a blank xmlns=""

查看:89
本文介绍了蚂蚁xmltask添加一个空白的xmlns =""的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我正在运行的用于将驱动程序插入到我的wildfly standalone.xml中的完整ant目标:

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>

据我了解,该条目仅应在standalone.xml中输入,因为我正在使用 unless ="modelexists" .

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".

但是显然,它正在为Oracle驱动程序添加一个新的 xmlns =" 条目,这会导致两个oracle条目,这会导致我的构建失败.

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.

推荐答案

要解决带有新的 xmlns =" 的oracle驱动程序新条目的问题,您必须提供名称空间(找到在CDATA部分中的节点 driver 中位于xml的根元素中:

To solve the problem with the new entry for oracle driver with an additional xmlns="" you have to provide the namespace (found at the root element in the xml) for the node driver in the CDATA section:

<driver xmlns="namespace_for_this_xml" name="oracle" module="com.oracle.ojdbc6">
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>

源文件在XML文档中插入XML元素

这篇关于蚂蚁xmltask添加一个空白的xmlns =""的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆