Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ant xmltask复制文件_Xml_Ant - Fatal编程技术网

ant xmltask复制文件

ant xmltask复制文件,xml,ant,Xml,Ant,我有以下xml文件: <?xml version="1.0"?> <job> <files> <file src="file:\C:\tmp\myfile.xml" path="myfile.xml" format="dita"/> <file src="file:\C:\tmp\myfile2.xml" path="myfile2.xml" format="dita"/> </files>

我有以下xml文件:

<?xml version="1.0"?>
<job>
<files>
        <file src="file:\C:\tmp\myfile.xml" path="myfile.xml" format="dita"/>
        <file src="file:\C:\tmp\myfile2.xml" path="myfile2.xml" format="dita"/>
</files>
</job>

我尝试使用ant脚本读取xml文件的内容,然后复制相应的文件。这是我的ant脚本:

<?xml version="1.0" encoding="UTF-8"?>

<project name="TPreProcess" default="start" basedir="." >
<target name="start">
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>

<xmltask source="${basedir}${file.separator}.job.xml" report="false" >  

    <call path="//job/files/file[@format='dita' or @format='ditamap' ]" target="copy-xml"  buffer="abc">
            <param name="copySourcesFile" path="@src"/>
     </call>

</xmltask>
</target>


<target name="copy-xml" depends="" unless="" description="copy xml files">
<copy file="${copySourcesFile}" todir="C:${file.separator}tmp${file.separator}test_dita${file.separator}" failonerror="false" flatten="true"/>
</target>
</project>

ant脚本位于插件文件夹中。在执行的ant文件的日志文件中,始终显示它找不到要复制的文件。你可以看到他总是把插件文件夹放在它前面


复制xml:

[复制]警告:找不到文件Q:\DITA\DITA Open Toolkit\plugins\com.xxxxx.DITA.tran.process\file:\C:\tmp\myfile.txt进行复制



我做错了什么?如何仅获取实际文件路径并找到要复制的文件?

我让它像这样运行:

<xmltask source="${basedir}${file.separator}.job.xml" report="false">

<call path="//job/files/file[@format='dita' or @format='ditamap' ]" target="copy-xml"  buffer="abc"> 
<param name="copySourcesFile" path="@src"/> 

</call>


<target name="copy-xml" depends="" unless="" description="copy xml files" >  

 <property name="copySourcesFile" value="${copySourcesFile}" /> 

 <basename property="file.basename" file="${copySourcesFile}"/>
 <dirname property="path.dirname" file="${copySourcesFile}"/>

 <pathconvert property="file.path.stripped">
        <file file="${path.dirname}" />
        <!-- path convert strips off the leading ${basedir} and "\file\:" -->
        <map from="${basedir}\file:\" to="" />
 </pathconvert>  
<copy todir="C:${file.separator}tmp${file.separator}" failonerror="false">
<fileset dir="${file.path.stripped}">
<include name="${file.basename}" />
</fileset>
</copy>
</target>


但我不确定这是否是一个好的解决方案。对此有何评论?如何更好?

复制
任务可以复制文件。为什么使用xmltask?我尝试使用xmltask,因为我必须读取要从xml文件复制的文件(包括某些属性的过滤器)。存在属性值不应复制的文件节点。或者我可以在没有xmltask的情况下读取xml文件吗?idea?副本始终根据其前面的basedir条目构建路径。当我将basedir条目更改为“.”以外的内容时,它不再占用以前的插件文件夹。通过目标中copySourcesFile的测试输出,我看到要复制的实际文件名正确地到达了目标中。所以复制本身会发生一些事情。但我不知道如何防止这种情况。有什么想法吗?Ant无法处理带有反斜杠的
文件:
协议引用。将源XML更改为
或简单地
file:///C:/tmp/myfile.xml 没有效果。它仍然把插件文件夹放在前面。警告:找不到要复制的文件Q:\DITA\DITA Open Toolkit\plugins\com.xxxxx.DITA.tran.process\file:\C:\tmp\myfile.xml。