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

查看:14
本文介绍了Ant 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.

推荐答案

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

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>

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

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