首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ant xmltask复制文件

ant xmltask复制文件
EN

Stack Overflow用户
提问于 2017-05-01 13:40:52
回答 1查看 688关注 0票数 0

我有以下xml文件:

代码语言:javascript
复制
<?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文件的内容,然后复制相应的文件。这是我的蚂蚁脚本:

代码语言:javascript
复制
<?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。

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

EN

回答 1

Stack Overflow用户

发布于 2017-05-07 11:36:52

我让它像这样运行:

代码语言:javascript
复制
<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>

但我不确定这是否是一个好的解决办法。对此有什么评论吗?怎样才能更好呢?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43720074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档