You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Karsten Kousgaard <ks...@inbox.com> on 2007/09/21 21:42:26 UTC
Modify xml based on a configuration file
Hello
I'm doing my first ANT project, but have faced a problem that I'm not able to solve. I have a xml file, which I want to change using a dynamic configuration file of some kind. The configuration file could look like this:
<replace path="an xpath" value="the new value" />
<replace path="an xpath" value="the new value" />
..
That fits perfect together with the external task, xmltask. Now the problem for me is, how do I parse and iterate the configuration file, to give the correct values to xmltask?
I also thought about using xslt, but I don't know how to do that either. My xslt knowledge is not good enought for this problem.
Another challenge is that the configuration file could have properties that I would like to resolve, e.g. <replace path="an xpath" value="${myProperty}" />.
But this is more a nice-to-have than a must-have. Any help about solving this? Thank you very much
____________________________________________________________
GET FREE 5GB ONLINE STORAGE - Safely store your documents, photos and music online!
Visit http://www.inbox.com/storage to find out more!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Modify xml based on a configuration file
Posted by Brian Agnew <br...@oopsconsultancy.com>.
I would use xmltask to insert the below into a dynamically built
build.xml, and then execute a new Ant task to run that.
Brian
On Fri, September 21, 2007 20:42, Karsten Kousgaard wrote:
> Hello
>
> I'm doing my first ANT project, but have faced a problem that I'm not able
> to solve. I have a xml file, which I want to change using a dynamic
> configuration file of some kind. The configuration file could look like
> this:
> <replace path="an xpath" value="the new value" />
> <replace path="an xpath" value="the new value" />
> ..
>
> That fits perfect together with the external task, xmltask. Now the
> problem for me is, how do I parse and iterate the configuration file, to
> give the correct values to xmltask?
>
> I also thought about using xslt, but I don't know how to do that either.
> My xslt knowledge is not good enought for this problem.
> Another challenge is that the configuration file could have properties
> that I would like to resolve, e.g. <replace path="an xpath"
> value="${myProperty}" />.
> But this is more a nice-to-have than a must-have. Any help about solving
> this? Thank you very much
>
> ____________________________________________________________
> GET FREE 5GB ONLINE STORAGE - Safely store your documents, photos and
> music online!
> Visit http://www.inbox.com/storage to find out more!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Modify xml based on a configuration file
Posted by david <da...@davidwbrown.name>.
Hello Karsten, it appears you have not gotten an answer and you may have already resolved the issue. But, for-whatever-it's-worth here is a custom xml configuration file that is processed during the build and jar targets. for the following XML elements found in my XML config file:
<password>
@DBPASSWORD@
</password>
<connectUrl>
@JDBCURL@
</connectUrl>
I used the following ant target task elements in my target named: compile.src:
<copy toDir="${classes}/META-INF" failonerror="false">
<fileset dir="${resources}">
<include name="*.xml" />
</fileset>
<filterset>
<filter token="JDBCURL" value="${jdbcurl}" />
<filter token="DBPASSWORD" value="${dbpassword}" />
</filterset>
</copy>
The properties jdbcurl and dbpassword are defined in my build.properties file. The filterset replaces all instances of @JDBCURL@ and @DBPASSWORD@ with the actual string values.
HTH, David.
Karsten Kousgaard wrote ..
> Hello
>
> I'm doing my first ANT project, but have faced a problem that I'm not able
> to solve. I have a xml file, which I want to change using a dynamic configuration
> file of some kind. The configuration file could look like this:
> <replace path="an xpath" value="the new value" />
> <replace path="an xpath" value="the new value" />
> ..
>
> That fits perfect together with the external task, xmltask. Now the problem
> for me is, how do I parse and iterate the configuration file, to give the
> correct values to xmltask?
>
> I also thought about using xslt, but I don't know how to do that either.
> My xslt knowledge is not good enought for this problem.
> Another challenge is that the configuration file could have properties
> that I would like to resolve, e.g. <replace path="an xpath" value="${myProperty}"
> />.
> But this is more a nice-to-have than a must-have. Any help about solving
> this? Thank you very much
>
> ____________________________________________________________
> GET FREE 5GB ONLINE STORAGE - Safely store your documents, photos and music
> online!
> Visit http://www.inbox.com/storage to find out more!
>
> ---------------------------------------------------------------------
> 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