You don't need to tag the property inside a function call, you need to pass
the name as a string literal.  Try:

        <if test="${property::exists('x')}">

You probably also want to check for the existence of 'y' before you do
anything, as in an INI file, the section lines will generate a value for x,
but not for y.

Also, I had a bit of a problem with boot.ini (which I was just trying out
against) in that it worked for one section, but on the other, I got a
spurious line with the section name as the 'x' property, and the first part
of the next line as the 'y' value.  This was followed by the line correctly
split on the '=' character.

I still think therefore you may be better to copy the file through a filter
chain and remove the section definitions and just leave the name/value
pairs.

HTH,

Bill



-----Original Message-----
From: Joel Gwynn [mailto:[EMAIL PROTECTED]
Sent: 07 November 2005 22:20
To: Bill Martin
Cc: nant-users@lists.sourceforge.net
Subject: Re: [Nant-users] Getting properties from an INI

Interesting.  Seems like I should be able to do something like this:

<foreach item="Line" in="${config}" delim="=" property="x,y">
        <if test="${property::exists( ${x} )}">
                <echo message="Read pair ${x}=${y}" />
        </if>
</foreach>

But I'm getting an error on the property::exists syntax.  Is it
possible to check for the existence of a variable like this?

On 11/7/05, Bill Martin <[EMAIL PROTECTED]> wrote:
> Joel,
>
> You may be able to do this with the <foreach> task.  You could use
something
> like:
>
> <foreach item="Line" in="myfile.ini" delim="=" property="prop,val">
>         <property name="${prop}" value="${val}" />
> </foreach>
> Not sure how easily you could cope with the blank sections though.  You
may
> need to use a filter chain first to delete the section markers.
>
> HTH,
>
> Bill
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Joel Gwynn
> Sent: 07 November 2005 16:32
> To: nant-users@lists.sourceforge.net
> Subject: [Nant-users] Getting properties from an INI
>
> I'd like to import name/value pairs from an ini without regard to
> sections.  So for every line with a "this=that", I'd like to end up
> with
> <property name="this" value="that" />
>
> I've currently got a little perl snippet that reads the file and spits
> out xml, which I then include, but I thought there might be a more
> elegant way.
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Nant-users mailing list
> Nant-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nant-users
>
>



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to