In that advice, he's using the <if> command from the AntContrib project.
<insert> in <xmltask> will take an 'if' or 'unless' attribute, to
perform the action if a property is set, or if it's not. That may be easier.
e.g. <insert path="..." if="property"/>
will insert if the property 'property' is set.
Brian
On 13/08/2009 12:10, Adithya V.S.S wrote:
Hi Gabriel,
Can you please help me out . I am stuck on - Conditional based insert
on xpath- I used the same way that you adviced cool the breezer .. but
it didnt work out for me...
I am reading the weblogic log4j configuration file,
a portion of the weblogic.home.cfgfile ( log4j configuration file ) -
<category additivity="true" name="com.bea.wli.event">
<priority value="info"/>
<appender-ref ref="RDBMS_EG_LOGFILE"/>
</category>
I am reading the name of the category from build -configuration file -
if the category already exists in the weblogic.home.cfgfile then it
shouldnt add else it should add ...
in build-configuration file -
<category>
<name>com.bea.wli.event</name>
</category>
in my build.xml file -
<target name="roottest" >
<xmltask source="${weblogic.home.cfgfile}">
<copy
path="boolean(/log4j:configuration/catego...@name='com.bea.wli.event'])"
property="is.path.available" />
</xmltask>
<if>
<isfalse value="${is.path.available}"/>
<then>
<xmltask source="${weblogic.home.cfgfile}"
dest="${weblogic.home.cfgfile}" failWithoutMatch="true">
<insert path="/log4j:configuration/root" position="after">
<![CDATA[ <category name="com.bea.wli.event">
<priority value="debug" />
<appender-ref ref="RDBMS_EG_LOGFILE_DEBUG"/>
</category> ]]>
</insert>
</xmltask>
</then>
</if>
</target>
when i run my build .xml .. the build fails ... with the following
error..
*C:\XML Task _ Test\build.xml:75: Problem: failed to create task or
type if*
*Cause: The name is undefined.*
*Action: Check the spelling.*
*Action: Check that any custom tasks/types have been declared.*
*Action: Check that any <presetdef>/<macrodef> declarations have taken
place.*
Can you please tell me where i am wrong,
Thanks
On Mon, May 4, 2009 at 11:17 AM, Lukacs, Gabriel
<gabriel.luk...@siemens.com <mailto:gabriel.luk...@siemens.com>> wrote:
Hello,
maybe it exists other solutions, but in such I am using the
following 2 step code:
<xmltask source="${tomcat.home}/conf/server.xml">
<copy
path="boolean(/Server/Service/Engine/Host/conte...@path='/doceng'])"
property="is.path.available" />
</xmltask>
<if> (this if task is from antcontrib)
<isfalse value="${is.path.available}"/>
<then>
....your insert....
</then>
</if>
-----Original Message-----
From: Cool The Breezer [mailto:techcool.ku...@yahoo.com
<mailto:techcool.ku...@yahoo.com>]
Sent: Monday, May 04, 2009 11:02 AM
To: xmltask-users@lists.sourceforge.net
<mailto:xmltask-users@lists.sourceforge.net>
Subject: [Xmltask-users] Conditional insert based on xpath
Hi,
I am currently using <insert> task for deploying my webapp. However
sometimes, the context is inserted more than once and I have to
perform
conditional insert in target. Before inserting, I have to check
whether
path="/Server/Service/Engine/Host/conte...@path='/doceng'] exists or
not. If exists then dont insert otherwise insert. I was looking into
"if" subtask but could not able to find any examples. Please find my
code below and would appreciate your help.
<target name="deploy_local">
<echo message="(INFO): Please ensure that server is
down, while deploying to localhost"/>
<xmltask source="${tomcat.home}/conf/server.xml"
dest="${tomcat.home}/conf/server.xml">
<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="${driverclassName}"
url="${dburl}"
username="${dbusername}"
password="${dbpassword}"
maxActive="${maxactive}"
maxIdle="${maxidle}"
maxWait="${maxwait}"/>
</Context>
]]>
</insert>
</xmltask>
</target>
------------------------------------------------------------------------
------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code
vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
<mailto:Xmltask-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/xmltask-users
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code
vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
<mailto:Xmltask-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/xmltask-users
--
Adithya V.S.S
------------------------------------------------------------------------
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
------------------------------------------------------------------------
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users