I am trying to follow a large ant buildfile that I have been given, and I am having trouble understanding the functionality of xmlproperty in this case. Consider this xml fi
When multiple elements have the same name, <xmlproperty>
creates a property with comma-separated values:
<project name="ant-xmlproperty-with-multiple-matching-elements" default="run" basedir=".">
<target name="run">
<xmlproperty file="example.xml" prefix="PREFIX" />
<echo>${PREFIX.main.tagList.tag.file}</echo>
</target>
</project>
The result:
run:
[echo] file1,file2
To process the comma-separated values, consider using the <for> task from the third-party Ant-Contrib library:
<project
name="ant-xmlproperty-with-multiple-matching-elements"
default="run"
basedir="."
xmlns:ac="antlib:net.sf.antcontrib"
>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<target name="run">
<xmlproperty file="example.xml" prefix="PREFIX" />
<ac:for list="${PREFIX.main.tagList.tag.file}" param="file">
<sequential>
<echo>@{file}</echo>
</sequential>
</ac:for>
</target>
</project>
The result:
run:
[echo] file1
[echo] file2