ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: how to copy and edit a section of a text file
Date Thu, 16 Oct 2008 15:22:50 GMT


-----Original Message-----
From: ca_iancu [mailto:ca_iancu@hotmail.com]
Sent: Friday, October 10, 2008 2:11 AM
To: user@ant.apache.org
Subject: Re: how to copy and edit a section of a text file

/*
No, I mean copy the entire section as written down before: from <device name
.... to </device>. I keep the old section, then I append the new one which
is almost identical but not quite. If you look again at the code, you will
see that the second xml file (the one I would like to get) is different than
the first one. Here's another attempt, where device1 is duplicated and it
becomes device2.They are independent entities now. Thank you.
*/

Sorry for the late reponse, had been off some days.
Here a quick shot with xmltask =

<project name="test" default="main" basedir=".">
<!-- // Taskdefs -->
<!-- Import XMLTask -->
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />
<!-- Taskdefs // -->
<!-- // Properties -->
 <property name="old.source.device" value="some_device"/>
 <property name="new.source.device" value="some_other_device"/>
<!-- Properties // -->

<target name="depends">
 <xmltask source="File.xml" report="true" dest="File.xml">
  <copy path="//device[@name='${old.source.device}']/." buffer="foobar" />
  <insert path="//device[@name='some_device']/." buffer="foobar" position="after"/>
   <replace path="//device[@name='${old.source.device}'][2]/@name" withText="${new.source.device}"
/>
 </xmltask>
</target>

<target name="main" depends="depends">
 <xmltask>
  <print buffer="foobar"/>
 </xmltask>
</target>
</project>


Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message