title: Ant Script Loop through property file and replace values dynamically
body: <p>I got a requirement to loop through some XML files, replace the environment specific values in it and create new set of XML files. The environment specific values are to be taken from property file. I am able to loop through a directory to read all the files and replace some specific value using xmltask as below.</p>
  
  <pre><code>    &lt;target name="updateConfig" description="update the configuration" depends="init"&gt;      
  &lt;xmltask todir="${ConfigDestDirectory}" report="false" failwithoutmatch="true"&gt;
         &lt;fileset dir="${ConfigSourceDirectory}"&gt;
              &lt;include name="*.xml"/&gt;    
         &lt;/fileset&gt;               
        &lt;replace path="/:application/:NVPairs/:NameValuePair[:name='Connections/HTTP/HostName']/:value/text()" withXml="localhost"/&gt;          
          &lt;/xmltask&gt;
       &lt;echo&gt;Replaced Successfully&lt;/echo&gt;
      &lt;/target&gt;
  </code></pre>
  
  <p>But I would like to read through a property file and get the path/value from it.
  I tried using property selector,property,var as different options for this case and manage to get the path but not the value. Below are the snippet of property file and the target that I am using.</p>
  
  <pre><code>#DEV.properties
  HostName.xpath=/:application/:NVPairs/:NameValuePair[:name='Connections/HTTP/HostName']/:value/text()
  HostName.value=localhost
  
  &lt;project name="TestBuild" default="ReadPropertyFile" basedir="."&gt;
      &lt;target name="init"&gt;        
              &lt;property file="DEV.properties"/&gt;
              &lt;taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" classpath="${xmltaskPath}"/&gt;
              &lt;taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${antcontribPath}"/&gt;
              &lt;taskdef resource="net/sf/antcontrib/antcontrib.properties"/&gt;
          &lt;/target&gt;
  
      &lt;target name="ReadPropertyFile" description="update the configuration" depends="init"&gt;      
                  &lt;property file="DEV.properties" prefix="x"/&gt;        
                  &lt;propertyselector property="propertyList" delimiter="," select="\0" match="([^\.]*)\.xpath" casesensitive="true" distinct="true"/&gt;      
                  &lt;for list="${propertyList}" param="sequence"&gt;               
                  &lt;sequential&gt;
                      &lt;propertyregex property="destproperty" input="@{sequence}" regexp="([^\.]*)\." select="\1" /&gt;                   
                      &lt;property name="tempname" value="${destproperty}.value" /&gt;      
                      &lt;var name="localprop" value="${tempname}"/&gt;
                      &lt;echo&gt; @{sequence} &lt;/echo&gt;  
                      &lt;echo&gt; ${x.@{sequence}} &lt;/echo&gt;
                      &lt;echo&gt;destproperty --&gt; ${destproperty}&lt;/echo&gt;
                      &lt;echo&gt;tempname --&gt; ${tempname}&lt;/echo&gt;
                      &lt;echo&gt; localprop --&gt; ${localprop}&lt;/echo&gt;    
                      &lt;echo&gt;${x.${localprop}} &lt;/echo&gt; &lt;!--This is not working --&gt;
                  &lt;/sequential&gt;               
                  &lt;/for&gt;          
              &lt;/target&gt; 
  </code></pre>
  
  <p>It would be really helpful if you guys can throw some light.</p>
  
  <p>Thanks,
  Venkat</p>