Let's say I have a macrodef like so
<macrodef name="Test">
<element name="someName"/>
<sequential>
<java classname="path_to_Test">
<classpath> blah </classpath>
<arg value="someText and {valueOfsomeName}"/>
</java>
</sequential>
</macrodef>
Then further down I have a target which uses this macrodef, like
<target name="testMacrodef">
<Test>
<someName value="someValue"/>
</Test>
</target>
My question is, how do I get {valueOfsomeName} to be exactly the string someValue? I can't seem to get it to work at all.
Also, just for a bit of context, I can't just use an attribute tag instead of an element tag, as I need it to be an optional argument.
I've Googled for ages trying to find a solution for this; maybe there isn't one. But as far as I can see no one has asked this, and it doesn't seem to be covered well in the Ant documentation either, so if it's not possible is there a way of having an optional attribute?
EDIT: spelling
Use a simple echo if element has only text content, f.e. :
output :
otherwise for nested xml content use echoxml, f.e. :
output :
If you need the element values for further processing use echo / echoxml to file and loadfile afterwards.
--EDIT after comment --
Echo to file :
or
and use loadfile afterwards => creates property (= string) with content.
When using echoxml strip of the xml header with filterchain :
Adapt the value of headfilter lines attribute to your needs.
Property whatever will have the value :