ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "david" <da...@davidwbrown.name>
Subject Re: Modify xml based on a configuration file
Date Tue, 25 Sep 2007 17:20:42 GMT
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


Mime
View raw message