[Xmltask-users] how to update/append to xml file using xmltask
Brought to you by:
bagnew
From: Neha B. <nbh...@ya...> - 2009-04-29 20:03:57
|
Per new requirement, I'm using xmltask to read deployfile.xml to get owner of project/projectname. I need to write into build status xml file which gets generated during our build. When running the following code, it needs to add new child (projectowner) in build status xml file, but this adds project owner for the last project only as I'm using the same dest file in xmltask during the xmltask-insert for each project. Is there a way to update build_status.xml.cp for each project using xmltask? Please assist! The below code is to read xml file and call ant task - update_bld_status to update build_status file <xmltask source="deployfile.xml"> <call path="/applications[@group='xyz']/application/profile" target="update_bld_status"> <param name="projectOwner" path="@projectowner"/> <param name="projectName" path="@projectname"/> </call> </xmltask> <target name="update_bld_status"> <if> <available file="build_status.xml" type="file"/> <then> <property name="addNewElement" value="<projectowner>${projectOwner}</projectowner>"/> <property name="nameProject" value="${projectName}.jpr"/> <echo message="projectowner : ${addNewElement}"/> <echo message="projectname : ${projectName}"/> <echo message="nameProject : ${nameProject}"/> <xmltask source="build_status.xml" dest="build_status.xml.cp"> <insert path="/log/deploy-task/target/project[text()='${nameProject}']" xml="${addNewElement}" position="after"/> </xmltask> </then> </if> </target> after running the above code, build status gets updated as below (build_status.xml): <log> <deploy-task> <target> <profile>Model-Test</profile> <workspace>Test.jws</workspace> <project>Model-Test.jpr</project> </target> <status exitcode="0">SUCCESS</status> </deploy-task> <deploy-task> <target> <profile>View-Test</profile> <workspace>Test.jws</workspace> <project>ViewController-Test.jpr</project> <projectowner>xy...@ya...</projectowner> </target> <status exitcode="0">SUCCESS</status> </deploy-task> <log> thanks in advance! |