ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <>
Subject Re: Adding tasks
Date Mon, 30 Apr 2001 23:57:34 GMT

You can't have the same attribute twice in an element in XML. To do what
you want, you will need to create nested elements
   <myAttr value="foo"/>
   <myAttr value="bar"/>

This arrangement is supported by Ant's introspection. You will need a
createMyAttr() method which returns an instance of a class (typically this
could be an innerclass of mytask) which accepts the value attribute (i.e.
setValue(String ) method). The createMyAttr() method would store the nested
element instances as they are created in a vector. When your task is ready
to execute it can pull all of the myAttr values out of the vector and
combine them. Other combinations are also possible such as


for which you would use the addText method in your myAttr class.

Check the createLink method in for an example of this in


----- Original Message -----
From: <>
To: <>
Sent: Tuesday, May 01, 2001 8:57 AM
Subject: Adding tasks

> Howdy,
> Is it possible to do something like this when defining my own task?  If
> so, anyone care to point me in the right direction?
> <mytask myAttr="foo" myAttr="bar" myAttr="blee">
> This gives me an error about "myAttr" already appearing in this tag.
> I'd like to be able to append all these attributes together like this.
> public void getAttr(String attr) {
>    if (this.attr == null)
>       this.attr = "";
>    this.attr += attr;
> }
> Any thoughts, suggestions, places to look, et cetera, would be much
> appreciated.
> /bill

View raw message