[Xmltask-users] Conditional insert based on xpath
Brought to you by:
bagnew
From: Cool T. B. <tec...@ya...> - 2009-05-04 09:01:55
|
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/Context[@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> |