You can do the whole thing with xmltask
using the replace
option with a slightly more specific XPath expression:
<xmltask outputter="simple" source="${tmp.file}" dest="${tmp.file}">
<replace withText="${PASSWD_DBLINK}"
path="/oc4j-connector-factories/connector-factory[
config-property[@name='username'][@value = 'username1']
]/config-property[@name='password']/@value"/>
</xmltask>
Here I'm using a predicate at the connector-factory
level to select only the connector-factory
with username "username1", and then modifying its password property.
Alternatively with XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- to pass in the new password value from Ant -->
<xsl:param name="newPassword" />
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- replace the password value for username1 only -->
<xsl:template match="connector-factory[
config-property[@name = 'username'][@value = 'username1']
]/config-property[@name = 'password']/@value">
<xsl:attribute name="value">
<xsl:value-of select="$newPassword" />
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
and call it from Ant with
<xslt in="oc4j-ra.xml" out="${tmp.file}" style="JmsServer-oc4j-ra.xsl">
<param name="newPassword" expression="${PASSWD_DBLINK}"/>
</xslt>