Hey Nik,

Good question.  Looking at the ant source it looks like the property value is 
overwritten with the new value concatenated onto the old value with a comma in 
between.  So the old value is lost.

This is probably not the answer you are looking for but you could use ant 
contrib's foreach task to iterate over the list of values in 
temp.properties.entry.

It would be nice if there were a way for the xmlproperty task to create props 
with an XPath like syntax.  Something like:

temp.properties.entry(key="appName")  would return Name

or even a simple array index, something like:

temp.properties.entry(0)  would return Name as well

But I don't see such a thing.  Maybe we are just missing it.

--ryano




> ----- Original Message -----
> From: [EMAIL PROTECTED]
> To: [email protected]
> Subject: Using Java xml properties file with Ant
> Date: Fri, 20 Jul 2007 16:05:19 +0200 (CEST)
> 
> 
> We are building a piece of software which has a number of Java
> properties files in xml format (the kind which are read with
> Properties.loadFromXML).  An example:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd";>
> 
> <properties>
>    <entry key="appName">Name</entry>
>    <entry key="startBean">Something</entry>
>    <entry key="versionNumber">2.5</entry>
> </properties>
> 
> I would like to be able to read these files and use their properties from
> within ant.  The property task doesn't seem to handle properties files
> in xml so I have been trying to use the xmlproperty task:
> 
> <xmlproperty file="temp.properties.xml" prefix="temp" />
> 
> But then all the values get thrown into the temp.properties.entry
> property:
> 
> <echo> using Prop=${temp.properties.entry} </echo>
> 
> gives:
> 
>       [echo]  using Prop=Name,Something,2.5
> 
> I assume that this should be trivial but I can't find a good solution to
> get it to do the obvious thing (load three separate properties).
> Suggestions?
> 
> Second question, since the Sun dtd specifies SYSTEM (not a publicid), is
> it possible to use xmlcatalog?
> 
> Thanks,
> 
> Nik
> ____________________________________________________
> 
> Conversation, n.:
>       A vocal competition in which the one who is catching his breath
>       is called the listener.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to