ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gaz Smith <topqualityban...@yahoo.co.uk>
Subject RE: replace section of file, loadFile, replaceregex, filterchain
Date Thu, 20 Jul 2006 15:50:40 GMT
Excellent!! Thanks a lot :-)

After a bit of learning about XPath I've managed to
achieve the same in a much more elegant way,



--- "Rebhan, Gilbert" <Gilbert.Rebhan@huk-coburg.de>
wrote:

> Hi,
> 
> when working (replace ...) with xml files i would go
> with the xml task =
> 
> http://www.oopsconsultancy.com/software/xmltask/
> 
> then you can select the specific nodes via xpath
> 
>  
> Regards, Gilbert
> 
> -----Original Message-----
> From: Gaz Smith
> [mailto:topqualitybanter@yahoo.co.uk] 
> Sent: Thursday, July 20, 2006 10:43 AM
> To: user@ant.apache.org
> Subject: replace section of file, loadFile,
> replaceregex, filterchain
> 
> Hey, wonder if you guys can help me? I'm trying to
> use
> ant to copy a portion of one text file
> in to another text file. I have specific markers
> that
> I can use for this.
> 
> 
> The source file has the format shown below,
> 
> // ----- src file start
> 
> a few
> 
> lines of text
> 
> <service name="ServiceName" ... >
> 
>    One or more
>    lines of stuff
>    
> </service>
> 
> more stuff I don't want.
> 
> // ----- src file end
> 
> 
> In the destination file I want to replace the
> existing
> entry between (and including the service tags)
> with the one extracted from the above file. 
> 
> // ----- dest file start
> 
> a few lines of
> some text 
> 
> <service name="ServiceName" .... >
> 
>    the old copy of the
>    service definition
>    that i want to replace
>    
> </service>
> 
> more stuff to be ignored
> 
> // ----- dest file end
> 
> 
> 
> Now I believe I can achieve the above using
> something
> like the following,
> 
> <loadfile property="wsdd" srcfile="srcFile.txt">
>     <filterchain>
>         <tokenfilter>
>             <filetokenizer/>
>             <replaceregex pattern="^.*<service
> name="ServerName"" replace=""
> flags="s"/>
>             <replaceregex pattern="service>.*$"
> replace="" flags="s"/>
>         </tokenfilter>
>      </filterchain>
> </loadfile>
> 
> <replace file="destFile.txt" token="@SPECIAL_TOKEN@"
> value="${wsdd}"/>
> 
> 
> 1. The regex isn't up to scratch. What I really want
> to do it extract the bit between the tags and 
> ignore the rest. Any suggestions?
> 
> 2. The replace file will only work if the token is
> in
> the file (obviously). The problem here is that
> I can run the task over and over again replacing the
> old value in destFile. What I really want to do
> on each replace is replace the portion between
> <service name="ServiceName"..> and the next
> </service>
> tag.
> 
> Many thanks for your time,
> gaz.
> 
> 
> 		
>
___________________________________________________________
> 
> The all-new Yahoo! Mail goes wherever you go - free
> your email address
> from your Internet provider.
> http://uk.docs.yahoo.com/nowyoucan.html
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



		
___________________________________________________________ 
Try the all-new Yahoo! Mail. "The New Version is radically easier to use" – The Wall Street
Journal 
http://uk.docs.yahoo.com/nowyoucan.html

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


Mime
View raw message