You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Brent Bain <Br...@marketlive.com> on 2005/04/01 18:35:05 UTC

Append References? (refid question)

Hello:

I think I've come up with a better way to ask my last question in a much
more generic "how do I" type way.
Is there a way to update a reference id within a loop?
For example (not working code below but it shows more or less what I'm
trying to do):
<for list="a,b,c" param="example">
    <sequential>
        <path id="exampleID">
            <pathelement path="@{example}" />
        </path>
    </sequential>
</for>
The above does NOT work because each time it loops through it resets the
refid.  Unless I am missing something...
 
What I'm hoping for is a way so that when the loop was all finished the
refID would then return all the values that were handled in the loop.
My goal is a little more complex -- looping over an xml file to read in lib
files/paths -- I just don't want to read in the xml file each time I need to
use the libs if at all possible.  Storing the lib references in an xml
property file allows me to only have one file to reference from several sub
projects.
 
Any tips would be greatly appreciated!!!
Thanks,
Brent

Re: Append References? (refid question)

Posted by Antoine Levy-Lambert <an...@gmx.de>.
It sounds like you want to append to paths, which you denote using
references. Appending references does not make sense (to me at least).
You could probably append to your path using JavaScript, not with pure Ant
means.
<project name="appendpath">
<path id="exampleID"/>
 <for list="a,b,c" param="example">
     <sequential>
  <script language="javascript"> <![CDATA[
         // appendpath is the project object
         // get a pointer to the path as a reference
         exampleIDref=appendpath.getReference("exampledID");
         exampleIDpath=exampleIDref.getReferencedObject(appendpath);
         newpe=exampleIDpath.createPathElement();
         newpe.setLocation(appendpath.getProperty("example")); 
    ]]> </script>
     </sequential>
 </for>
</project>


> Hello:
> 
> I think I've come up with a better way to ask my last question in a much
> more generic "how do I" type way.
> Is there a way to update a reference id within a loop?
> For example (not working code below but it shows more or less what I'm
> trying to do):
> <for list="a,b,c" param="example">
>     <sequential>
>         <path id="exampleID">
>             <pathelement path="@{example}" />
>         </path>
>     </sequential>
> </for>
> The above does NOT work because each time it loops through it resets the
> refid.  Unless I am missing something...
>  
> What I'm hoping for is a way so that when the loop was all finished the
> refID would then return all the values that were handled in the loop.
> My goal is a little more complex -- looping over an xml file to read in
> lib
> files/paths -- I just don't want to read in the xml file each time I need
> to
> use the libs if at all possible.  Storing the lib references in an xml
> property file allows me to only have one file to reference from several
> sub
> projects.
>  
> Any tips would be greatly appreciated!!!
> Thanks,
> Brent
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org