Concatenate xml file in ant script

微笑、不失礼 提交于 2019-12-02 09:39:22

Well, assuming the XSLT 2.0 processor used is Saxon 9 then you can do it along the lines of e.g.

<xsl:param name="folder-uri" select="'file:/root/users/foo/foldername'"/>
<xsl:param name="select-pattern" select="'server*.xml'"/>
<xsl:variable name="docs" select="collection(concat($folder-uri, '?select=', $selectPattern))"/>

<xsl:template name="main" match="/">
  <xsl:element name="{name($docs[1]/*)}" namespace="{namespace-uri($docs[1]/*)}">
    <xsl:copy-of select="$docs/*/node()"/>
  </xsl:element>
</xsl:template>

try this

Concatenate a series of files, update the destination file only if is older that all the source files:

Sample code:

 <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>

avoids root tag:

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!