在ant脚本中连接xml文件 [英] Concatenate xml file in ant script

查看:31
本文介绍了在ant脚本中连接xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是蚂蚁脚本的新手.我正在寻找如何将文件夹中的所有 xml 文件连接到 ant 脚本中的单个 xml 文件中.

I am new to ant script. I am looking for how to concatenate all the xml file in a folder into a single xml file in ant script.

在我的项目中,将在一个文件夹中动态生成 n 个 xml 文件,例如:server1.xml、manager.xml、server2.xml、server3.xml.我需要将所有在文件名中包含服务器的 xml 文件(server1.xml、server2.xml、server3.xml)合并为一个 xml,例如:server.xml.并且需要在jboss中部署它.

In my project n number of xml files will be generated dynamically in a folder eg: server1.xml, manager.xml, server2.xml, server3.xml. I need to merge all the xml files having server in their filename alone (server1.xml, server2.xml, server3.xml) into a single xml eg: server.xml. and need to deploy it in jboss.

我发现使用 xmltask 将内容从一个 xml 文件复制到另一个文件.我不确定如何将文件夹中的所有 xml 文件内容复制到 ant 脚本中的单个 xml 文件中.

I have found that copying content from one xml file to another using xmltask. I am not sure how to copy all the xml files content in a folder into a single xml file in ant script.

感谢任何帮助.

推荐答案

试试这个

连接一系列文件,仅当目标文件比所有源文件更旧时才更新目标文件:

示例代码:

 <concat destfile="${docbook.dir}/all-sections.xml"
          force="no">
    <filelist dir="${docbook.dir}/sections"
         files="introduction.xml,overview.xml"/>
    <fileset dir="${docbook.dir}"
         includes="sections/*.xml"
         excludes="introduction.xml,overview.xml"/>
  </concat>

避免根标记:

<concat destfile="${docbook.dir}/all-sections.xml" force="no">       
    <fileset dir="${docbook.dir}" includes="sections/*.xml"/>
    <filterchain>
        <linecontainsregexp negate="true">
            <regexp pattern="&lt;\?xml version"/>
        </linecontainsregexp>
    </filterchain>  
 </concat>

这篇关于在ant脚本中连接xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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