<target name="openAssetXMLFile">
<for list="${LogOfCurrentAssetChanges}" delimiter="${line.separator}" param="paths">
<sequential>
<xmltask source="${basedir}@{paths}">
<copy path="/x/id/text()" attrValue="true" property="type"/>
<copy path="/x/attribute[9]/data/stringValue/text()" attrValue="true" property="uid"/>
</xmltask>
<echo> ${type}</echo>
<echo> ${basedir}@{paths}</echo>
<echo> ${uid}</echo>
</sequential>
</for>
</target>
I am fairly helpless here and would like any assistance. So I have the above buildfile snippet which uses sequential, which uses macrodefinitions so a string should be referred with the @ sign as opposed to the usual $ sign.
I have a logofcurrentassetchanges file which contains a relative reference to some xml files. Now I need to concatenate this with the current directory to produce the absolute reference name. When I echo the concatenated string its perfect - by which I mean for each for loop iteration it prints a different xml string as expected. However when I use it in an xmltask as shown above, it uses the very first source for all iterations? Do I need to refresh/cleanup or do something to flush the xmltask source attribute off its original old values? Or is there anything I can do to fix this problem. A sample output from the echo statements:
[echo] CSElement:1242615155986
[echo] /y/z/t/u/11/67/MFootsfgsgfser(e7e105ef-660f-4363-8018-638f87ba06be).main.xml
[echo] 7d454a57-fe1a-48c1-994c-bbcbbf9f78e4
[echo] CSElement:1242615155986
[echo] /a/b/c/MORegistsfgsfgfsgerLogsfgshinLinsgsfgks.jsp.main.xml
[echo] 7d454a57-fe1a-48c1-994c-bbcbbf9f78e4
here the type and uid keep repeating, but the path looks right when printed.
(At least part of) the problem is that the xmltask
copies assign to Ant properties (named type
and uid
). Ant properties - unlike the ant-contrib @
variables are normally immutable, so once you set a value for them, they don't change. This is what you're seeing.
There is a task - as of Ant version 1.8 - called local
which can be used to scope a property to the current 'block', so that you can have a different value in each for
iteration. It would look like this:
<sequential>
<local name="type" />
<local name="uid" />
<xmltask source="${basedir}@{paths}">
... etc.