 <p>To keep it flexible you may use macrodef with nested element attribute for 1-n filesets, f.e.<br> a macrodef that creates a dirlisting in xmlformat for nested filesets :<br></p> <pre><code>&lt;macrodef name="dir2xml"&gt; &lt;attribute name="file" description="xmlfile for filelisting"/&gt; &lt;attribute name="roottag" description="xml root tag"/&gt; &lt;attribute name="entrytag" description="xml tag for entry"/&gt; &lt;element name="fs" description="nested filesets for listing"/&gt; &lt;sequential&gt; &lt;pathconvert property="files.xml" dirsep="/" pathsep="&amp;lt;/@{entrytag}&amp;gt;${line.separator} &amp;lt;@{entrytag}&amp;gt;" &gt; &lt;!-- 1-n nested fileset(s) --&gt; &lt;fs/&gt; &lt;/pathconvert&gt; &lt;!-- create xmlfile --&gt; &lt;echo message="&amp;lt;@{roottag}&amp;gt;${line.separator} &amp;lt;@{entrytag}&amp;gt;${files.xml}&amp;lt;/@{entrytag}&amp;gt;${line.separator}&amp;lt;/@{roottag}&amp;gt;" file="@{file}"/&gt; &lt;/sequential&gt; &lt;/macrodef&gt; </code></pre> <p>Usage :<br></p> <pre><code>&lt;dir2xml file="filelistant.xml" entrytag="antfile" roottag="antfilelist"&gt; &lt;fs&gt; &lt;fileset dir="." includes="**/*.xml"/&gt; &lt;fileset dir="../ant_xml" includes="**/*.xml"/&gt; &lt;/fs&gt; &lt;/dir2xml&gt; </code></pre>