ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alec Fernandez <Alec.Fernan...@sas.com>
Subject RE: AW: Modify xml file
Date Wed, 21 Jan 2009 14:22:48 GMT
You should exercise caution when using replace to substitute tokens in xml files and property
files because some chars &<>'" need to be escaped in xml files.

You need to be sure that the string that you are inserting into the xml will never have such
characters, or you must escape yourself.

Similarly there are chars (\ and non-Latin 1 chars) that need escaping in .properties files.
 

If someone knows of an elegant solution to inserting such strings into files using ant, I
would be grateful for the input.

>> -----Original Message-----
>> From: Brian Stephenson [mailto:bstephenson@thortech-solutions.com]
>> Sent: Wednesday, January 21, 2009 2:36 PM
>> To: Ant Users List
>> Subject: Re: AW: Modify xml file
>> 
>> Just as a followup, I do a similar thing as #3 in a project I am
>> ANT'ing, and if you are not replacing in the XML file using regular
>> expressions (e.g., you are just replacing 'password="foo"' with
>> 'password="bar"'), you may be able to accomplish what you need to do
>> with the much simpler-to-use command REPLACE, which does straight
>> string replacement without regular expressions. Best thing about
>> REPLACE is that you can replace characters that are considered escape
>> characters in regular expressions (*, /. etc.). I refer you to
>> apache.org's ANT manual for the syntax of the REPLACE command, but if
>> you want to use an external config file to manipulate, I think this
>> might be the way to do it.
>> 
>> Brian Stephenson
>> ThorTech Solutions
>> www.thortech-solutions.com
>> 
>> 
>> 
>> On Jan 21, 2009, at 7:49 AM, <Jan.Materne@rzf.fin-nrw.de> wrote:
>> 
>> > There are multiple options:
>> > 1. create two hibernate files and select only one of them while
>> > copying using conditional patternset <include if>.
>> > 2. create a template and fill in the the values
>> > <copy><filterchain><expandproperties>
>> > 3. modify the config file with <replaceregexp>
>> > 4. modify the config file with <xmltask> (external task)
>> >
>> >
>> > Jan
>> >
>> >> -----Urspr√ľngliche Nachricht-----
>> >> Von: jeusdi [mailto:cabrejcr@terra.es]
>> >> Gesendet: Mittwoch, 21. Januar 2009 13:43
>> >> An: user@ant.apache.org
>> >> Betreff: Modify xml file
>> >>
>> >>
>> >> Hello list.
>> >>
>> >> I'm using Hibernate in my web project. I've created an Ant
>> >> file in order to
>> >> create a war and deploy it to my remote tomcat. The problem is
>> >> locally I
>> >> test my database access with a user/password database. So,
>> >> Hibernate has a
>> >> hibernate.cfg.xml, in order to set the user and password to access
>> to
>> >> database with. So, I need to change these fileds previously to
>> >> war task. How
>> >> Can I to it?
>> >>
>> >> Thanks.
>> >> I will appreciate your help a lot.
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Modify-xml-file-tp21582407p21582407.html
>> >> Sent from the Ant - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >> -------------------------------------------------------------------
>> --
>> >> 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
>> >
>> 
>> 
>> 


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


Mime
View raw message