xml替换 xml 文件中的节点时出现任务错误
xmltask error when replacing node in xml file
运行目标 replace
到 xmltask
时出现错误:
C:\Tools\build.xml:432: The following error occurred while executing this line:
C:\Tools\build.xml:408: Failed to specify text in replace
问题是我的同事在他的计算机上没有问题 运行 相同的代码。我不明白为什么我得到了错误而我的同事却没有。
build.xml部分如下:
<target name="replace" depends="init" description="replace node.">
<xmltask source="${my-file}" dest="${my-file}">
<replace path=
"/*[local-name()='server']
/*[local-name()='profile']
/*[local-name() = 'subsystem'][1]"
withFile="${devlogfile}"/>
</xmltask>
</target>
<target name="init">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${ant.lib.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
<classpath>
<pathelement path="${ant.lib.dir}/xmltask.jar"/>
</classpath>
</taskdef>
</target>
属性文件部分如下:
my-file=c:/old.xml
devlogfile=c:/new.xml
[转自评论区]
您是否比较了您同事和您自己的 jdk 和类路径?到目前为止提供的信息无法判断,但您可能使用了不同的解析器。
错误消息表明 Ant 没有找到 devlogfile 文件本身。
您确定属性文件已正确传递给您的 ant 运行时吗?你过得怎么样?
运行目标 replace
到 xmltask
时出现错误:
C:\Tools\build.xml:432: The following error occurred while executing this line:
C:\Tools\build.xml:408: Failed to specify text in replace
问题是我的同事在他的计算机上没有问题 运行 相同的代码。我不明白为什么我得到了错误而我的同事却没有。
build.xml部分如下:
<target name="replace" depends="init" description="replace node.">
<xmltask source="${my-file}" dest="${my-file}">
<replace path=
"/*[local-name()='server']
/*[local-name()='profile']
/*[local-name() = 'subsystem'][1]"
withFile="${devlogfile}"/>
</xmltask>
</target>
<target name="init">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${ant.lib.dir}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
<classpath>
<pathelement path="${ant.lib.dir}/xmltask.jar"/>
</classpath>
</taskdef>
</target>
属性文件部分如下:
my-file=c:/old.xml
devlogfile=c:/new.xml
[转自评论区]
您是否比较了您同事和您自己的 jdk 和类路径?到目前为止提供的信息无法判断,但您可能使用了不同的解析器。
错误消息表明 Ant 没有找到 devlogfile 文件本身。 您确定属性文件已正确传递给您的 ant 运行时吗?你过得怎么样?