ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wascally Wabbit <>
Subject Re: AntX: $map example from guide fails when key is missing?
Date Mon, 15 Dec 2008 15:37:41 GMT
Hi Sagi,

A couple of things:
  1) Try using ${$prop:p1->@(key)} inside the loop instead of $map:
     Less overhead and a bit clearer.
  2) In AntXtras 0.5.x you cannot assign an empty string to a var
     (this is fixed in AntXtras 2.0.0 but that's still in alpha)
     So if the key does not exist in p2, you need a dummy marker
     string like 'MISSING' or something.

I don't completely understand what you're trying to do...but here
is some reworked example script for AntX 0.5.1:

<t:foreach i="key" list="${$map:p1?keys}" mode="local">
   ${key}: p1='${$prop:p1->@(key)}'; p2='${$prop:p2->@(key)?}'"
   <t:assign var="existing" value="${$prop:p2->@(key)?MISSING}"/>
   <t:domatch variable="existing">
     <t:equals value="MISSING"/>
       [Do you processing here...]

The Wabbit

Sagi Mann wrote:
> Hi all,
> I'm trying to adopt example #2 from the $map URI guide:
> like so:
> For each property in the 'p1' set, I print the value of the same property in
> set 'p2'. For testing purposes, I print this TWICE: once by directly
> echoing:
> ${$map:xxx?@(key)} 
> and second by assigning the values to variables first, then echo the
> variables:
> <ax:foreach i="key" list="${$map:p1?keys}" mode="local">
> 		<echo message="prop ${key}: expected=${$map:p1?@(key)}
> existing=${$map:p2?@(key)}"/>
> 		<ax:assign name="expected" value="${$map:p1?@(key)}"/>
> 		<ax:assign name="existing" value="${$map:p2?@(key)}"/>
> 		<echo message="prop ${key} values: expected=${$var:expected}
> existing=${$var:existing}"/>
> </ax:foreach>
> If p1 and p2 contain the same property keys, all is ok. If p1 contains a
> property that does NOT exist in p2, the first echo is ok and displays (as it
> should):
> prop myprop: expected=1 existing=${$map:p2?@(key)}
> But the second assign fails with the error:
> Syntax error in property: ${key
> I need to be able to assign the result to variables (or use it in a domatch
> value attribute, which generates the same error). Does someone has any idea
> why this does not work properly?
> thanks.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message