ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: xmlproperty - clarification please
Date Wed, 09 Oct 2002 12:44:50 GMT

Simon Baker wrote:
> thanks rob - i'd thought of this but wanted to avoid many prop files - i'll
> stick with a java prop file.

In the proposal/embed dir of the Ant CVS there is an Ant extension that 
makes it possible to read xml properties via jxpath without xmlproperty:

...

>>file. The xml properties are as follows ....
>>
>><environments>
>>
>><env name="u03">
>><server.app.hostname>caix01</server.app.hostname>
>><server.app.username>root</server.app.username>
>><server.app.password>root</server.app.password>
>><server.app.rootdir>/clearstage/env/u03</server.app.rootdir>
>>
>>
> <billers>amexc,barcc,brgas,brtel,gfish,mbnac,mnsfs,morst,jlpac,onetl,orang,t
> 
>>elew,tmobl,virgc,virge,vodaf</billers>
>><debug>on</debug>
>></env>
>>
>><env name="u02">
>><server.app.hostname>caix01</server.app.hostname>
>><server.app.username>root</server.app.username>
>><server.app.password>root</server.app.password>
>><server.app.rootdir>/clearstage/env/u02</server.app.rootdir>
>>
>>
> <billers>amexc,barcc,brgas,brtel,gfish,mbnac,mnsfs,morst,jlpac,onetl,orang,t
> 
>>elew,tmobl,virgc,virge,vodaf</billers>
>><debug>on</debug>
>></env>
>>
>></environments>
>>
>>My ant code looks like:
>>
>><project name="play" default="init" basedir=".">
>>
>>    <target name="init">
>>
>><property name="env" value="u02"/>
>>
>><xmlproperty file="${basedir}/env.xml"
>>keeproot="false"/>
>>
>>        <echo>server.app.hostname=${env.server.app.hostname}</echo>
>>        <echo>server.app.username=${env.server.app.username}</echo>
>>        <echo>server.app.password=${env.server.app.password}</echo>
>>        <echo>server.app.rootdir=${env.server.app.rootdir}</echo>
>>        <echo>billers=${env.billers}</echo>
>>        <echo>debug=${env.debug}</echo>
>>
>>    </target>
>>
>></project>
>>

     <taskdef classname="org.apache.tools.ant.taskdefs.optional.JXPath"
              name="jxpath" />
     <typedef name="xmldom"
              classname="org.apache.tools.ant.types.XMLDOM"/>

     <jxpath/>
     <xmldom id="conf.xml" file="conf.xml"/>

     <property name="myenv" value="u02"/>

<echo>
server.app.hostname= 
${jxpath:/references/conf.xml/root/environments/env[@name=$myenv]/server/app/hostname}} 

</echo>

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


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


Mime
View raw message