ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <anto...@gmx.de>
Subject Re: loading an xml file into properties
Date Thu, 24 Aug 2006 01:39:33 GMT

Hello EJ,

You can look at the <xmltask/> which has features to select specific  
xpaths and put their value into specific properties.
Another possibility :
if xslt is your friend, you can create a stylesheet which converts  
your XML into a temporary property file, which you can load and then  
delete.
In this case you do not need custom tasks or external tasks.

Something like
<xsl:output method="text"/>
<xsl:template match="properties/*">
    <xsl:value-of select="local-name()"/> <!-- name of the property -->
   <xsl:text>=</xsl:text>
    <xsl:value-of select="."/> <!-- the value of the property -->
    <xsl:text>&#010;</xsl:text> <!-- carriage return -->
</xsl:template>

Antoine



On Aug 23, 2006, at 10:01 PM, EJ Ciramella wrote:

> What's the easiest way (without going to custom ant libs) to load the
> following style xml file into properties?
>
> My problem with the XmlProperty task is it nests appserver.home  
> together
> (with a comma).  Is there a way to keep these as individual  
> properties?
>
> <profiles>
>   <profile>
>     <id>model-base</id>
>     <activation>
>       <activeByDefault/>
>     </activation>
>
>     <properties>
>      <jdbc.driver>oracle.jdbc.driver.OracleDriver</jdbc.driver>
>      <db.server>localhost</db.server>
>      <db.port>1521</db.port>
>      <db.instance>someinstance</db.instance>
>      <db.username>someuser</db.username>
>      <db.password>somepass</db.password>
>      <connection.pool_size>1</connection.pool_size>
>      <dialect>org.hibernate.dialect.Oracle9Dialect</dialect>
>      <show_sql>false</show_sql>
>      <default_entity_mode>pojo</default_entity_mode>
>      <generate_statistics>true</generate_statistics>
>      <autocommit>false</autocommit>
>      <use_query_cache>true</use_query_cache>
>   <lty.sh.location>/bin</lty.sh.location>
>   <lty.vm.heap.opts>-XX:MaxPermSize=128m -ms256m
> -mx256m</lty.vm.heap.opts>
>   <lty.vm.definition>-Xdebug -Xnoagent -Djava.compiler=NONE
> -Xrunjdwp:transport=dt_socket,server=y,address=8787,suspend=n</ 
> lty.vm.de
> finition>
>         <appserver.home>/path/to/another/dev/appserver1</ 
> appserver.home>
>     </properties>
>   </profile>
>
>   <profile>
>     <id>appserverConfig-dev-2</id>
>     <activation>
>       <property>
>         <name>env</name>
>

>         <value>dev-2</value>
>       </property>
>     </activation>
>
>     <properties>
>       <appserver.home>/path/to/another/dev/appserver2</appserver.home>
>     </properties>
>   </profile>
>
>
> </profiles>


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


Mime
View raw message