I'm new to the ReplaceRegExp function in Ant, and have some questions.
Here is my use case.
I have multiple .xml files, which I need to manipulate in specific ways.
Here is one example of the .xml contents:
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>29.0</apiVersion>
<packageVersions>
<majorNumber>1</majorNumber>
<minorNumber>1228</minorNumber>
<namespace>prefix1__FirstNamespace</namespace>
</packageVersions>
<packageVersions>
<majorNumber>2</majorNumber>
<minorNumber>4</minorNumber>
<namespace>prefix2__TheNextNamespace</namespace>
</packageVersions>
<packageVersions>
<majorNumber>7</majorNumber>
<minorNumber>542</minorNumber>
<namespace>prefix3__AnotherNamespace</namespace>
</packageVersions>
<status>Active</status>
</ApexClass>
How can I update the the & attributes of the only where the attribute contains the prefix "prefix3"?
I've tried this function, hoping to change the attribute to the value specified by ${correctMinorNumber}:
<target name="setminorNumber">
<replaceregexp flags="gis"
match="<minorNumber>?(.*)</minorNumber>?(.+?)<namespace>prefix3__</namespace>"
byline="false"
>
<substitution expression="<minorNumber>${correctMinorNumber}</minorNumber> 		<namespace>prefix3__</namespace>"/>
<fileset dir="${sf.retrieveFolder}">
<include name="**/*.xml"/>
</fileset>
</replaceregexp>
</target>
It worked correct on files where there was only one <packageVersion>
node (with prefix3__ in the namespace), but on files containing multiple <packageVersion>
nodes it replaces all nodes with one prefix3__ node. I'm guessing the problem lies with my use of the wildcard, but I don't know enough about replaceregexp to identify the correct solution.
Any ideas on what I can do to achieve what I need to do?
Any help appreciated.