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 file, example.xml.
<main>
<tagList>
<tag>
<file>file1</file>
<machine>machine1</machine>
</tag>
<tag>
<file>file2</file>
<machine>machine2</machine>
</tag>
</tagList>
</main>
In the buildfile, there is a task which can be simplified to the following for this example:
<xmlproperty file="example.xml" prefix="PREFIX" />
As I understand it, if there was only one <tag>
element, I could get the contents of <file>
with ${PREFIX.main.tagList.tag.file}
because it is roughly equivalent to writing this:
<property name="PREFIX.main.tagList.tag.file" value="file1"/>
But as there are two <tag>
s, what is the value of ${PREFIX.main.tagList.tag.file}
in this case? If it is some sort of list, how do I iterate through both <file>
values?
I am using ant 1.6.2.
When multiple elements have the same name,
<xmlproperty>
creates a property with comma-separated values:The result:
To process the comma-separated values, consider using the
<for>
task from the third-party Ant-Contrib library:The result: