You can do it like this:
You can't access properties directly, so you pass them in as parameters
to the task. Then in the task you access the parameter like
${paramName}.
In your database.properties you have something similar to this
--------- database.properties --------------
docbase=value
dburl=jdbc:oracle:thin:@db_address:db_port:db_sid
username=myuser
password=secret
--------------------------------------------
Ant build file...
<loadproperties srcFile="database.properties" />
<antcall target="deploy_local">
<param name="docbase" value="${docbase}" />
<param name="dburl" value="${dburl}" />
<param name="username" value="${username}" />
<param name="password" value="${password}" />
</antcall>
<!-- Deploys to local server -->
<target name="deploy_local">
<echo message="${tomcat.home}"/>
<xmltask source="${tomcat.home}/conf/server.xml"
dest="${tomcat.home}/conf/1.xml" report="true">
<insert
path="/Server/Service/Engine/Host/text()[1]" position="before">
<![CDATA[
<Context path="/doceng"
reloadable="true" docBase="${docbase}">
<Resource name="jdbc/docengdb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="${dburl}"
username="${username}"
password="${password}" maxActive="20" maxIdle="10"
maxWait="-1"/>
</Context>
]]>
</insert>
</xmltask>
</target>
Hope this helps.
Mark Coffin
[email protected]
Phone: 905.632.0864
1.800.668.8486
Fax: 905.632.2605
www.aalsolutions.com
-----Original Message-----
From: Cool The Breezer [mailto:[email protected]]
Sent: April 16, 2009 7:57 AM
To: [email protected]
Subject: [Xmltask-users] Insert task
Hi,
Thanks Brian for your help to my earlier mail in ant user list.
I want some advanced stuff on replacing dynamic text with literals while
inserting to target tag in xml.
E.g.
<!-- Deploys to local server -->
<target name="deploy_local">
<echo message="${tomcat.home}"/>
<xmltask source="${tomcat.home}/conf/server.xml"
dest="${tomcat.home}/conf/1.xml" report="true">
<insert
path="/Server/Service/Engine/Host/text()[1]" position="before">
<![CDATA[
<Context path="/doceng"
reloadable="true" docBase="@docbase">
<Resource name="jdbc/docengdb"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="@dburl"
username="@username"
password="@password" maxActive="20" maxIdle="10"
maxWait="-1"/>
</Context>
]]>
</insert>
</xmltask>
</target>
I want to replace @docbase,@dburl,@username etc... with actual value
from property file before inserting into target XML.
Please suggest me how to do it.
- RB
------------------------------------------------------------------------
------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Xmltask-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltask-users
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Xmltask-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xmltask-users