Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Looping XML property file in ant script

Balaji RadhakrishnanJul 29 2014 — edited Jul 31 2014

Hi All,

     I was trying to search and replace values in the OSB customization file for each environment. I was able to do that with simple and direct search of tokens and replacing them with property file properties. But when I try to create a separate xml property file (attached) and try to loop through the contents in the build.xml, (using the below code snippet) am not able to get individual search tokens nor individual replace values. Am getting the entire search and replace values from file.


<xmlproperty file="../properties/${targetserver}/replaceProperties.xml"/>

<foreach list="${properties.searchReplace(name)}" param="token"

target="searchReplace" inheritall="true"

inheritrefs="false"/>

..

.

..

<target name="searchReplace">

        <echo>token: ${token}</echo>

        <echo>SearchReplace: ${properties.searchReplace(name)}</echo>

        <echo>Search: ${properties.searchReplace.search}</echo>

        <echo>Replace: ${properties.searchReplace.replace}</echo>

        <echo>Search: ${properties.searchReplace(@name=${token}).search}</echo>

        <echo>Replace: ${properties.searchReplace[1].replace}</echo>

        <replace file="${osb.deploy.dir}/${config.subprojects}_ALSBCustomizationFile.xml"

token="${properties.searchReplace.search}"

value="${properties.searchReplace.replace}"/>

    </target>

Log Print:

searchReplace:

     [echo] token: SOAHost

     [echo] SearchReplace: SOAHost,SOAPort

     [echo] Search: localhost,7001

     [echo] Replace: inc-soa-uap01.local,7001

     [echo] Search: ${properties.searchReplace(@name=${token}).search}

     [echo] Replace: ${properties.searchReplace[1].replace}

searchReplace:

     [echo] token: SOAPort

     [echo] SearchReplace: SOAHost,SOAPort

     [echo] Search: localhost,7001

     [echo] Replace: inc-soa-uap01.local,7001

     [echo] Search: ${properties.searchReplace(@name=${token}).search}

     [echo] Replace: ${properties.searchReplace[1].replace}


XML Property File:

                         <?xml version="1.0" encoding="UTF-8"?>

                         <properties>

                               <searchReplace name='SOAHost'>

                                <search>localhost</search>

                                <replace>inc-soa-uap01.local</replace>

                               </searchReplace>

                           <searchReplace name='SOAPort'>

                          <search>7001</search>

                      <replace>7001</replace>

                      </searchReplace>

                    </properties>


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2014
Added on Jul 29 2014
3 comments
2,383 views