ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peter.rei...@corvil.com>
Subject Re: Implicit element for macrodef
Date Wed, 26 May 2004 08:16:09 GMT
Dominique Devienne wrote:

>>From: Peter Reilly [mailto:peter.reilly@corvil.com]
>>
>>I am looking into an implementation of implicit nested elements for
>>macrodef:
>>    
>>
>
>Cool.
>
>  
>
>>    <showfiles property="x">
>>      <fileset dir="." includes="*.xml"/>
>>    </showfiles>
>>  </target>
>>
>>The implementation does however involve a small Backward Incompatible
>>change to the implementation of MacroInstance.
>>    
>>
>
>I'd say this is young enough that the benefits outweigh the drawbacks.
>
>Own would implicit elements interact with nested macros, each having
>an implicit element?
>  
>
If a macrodef has an implicit element, it is the only element allowed,
so there is no problem with nested macro calls.

<macrodef name="show2">
   <element name="files" implicit="yes"/>
   <sequential>
      <showfiles property="not-set-yet">
          <files/>
      </showfiles>
   </sequential>
</macrodef>

<show2>
   <fileset  dir="." includes="*.xml"/>
</show2>

 

>I personally have one request for <macrodef>: Is it possible to
>determine whether an element or attribute was set in the macro
>instance? Here is my use case: I have a macro that performs several
>tasks, each of them using a different element of the macro. If one
>of those elements is not specified in a macro instance, I'd like
>to completely skip the corresponding macro task (use <ac:if> or a
>builtin condition on that task). Currently, I have to define on
>additional attribute on the macro to turn ON the execution of a
>task, when the mere presence of the element for that task is enough
>to determine whether it should run or not. Maybe something like:
>
><macrodef name="...">
>  <element name="schemas" optional="yes" />
>  <attribute name="jaxb" default="@?schemas?" />
>  ...
>  <sequential>
>    <jaxb ... ifTrue="@{jaxb}">
>      <schemas>
>    </jaxb>
>    ...
>  </sequential>
></macrodef>
>
>The @?element? is purely arbitrary, and just to illustrate my point.
>I guess I can get by with the attribute/element twins, but I'm just
>wondering if there's a way to basically discover info on the macro
>instance itself, and put it to some use, as above.
>

This sounds like it should be an attribute to the <element> nested 
element of <macrodef>.
However there is a number of problems.
If the nested schemas element is not set, what should "jaxb" be set to - 
"false" ?
Also it is only usefull for tasks that have the iftrue/iffalse 
attribute, or if used
in conjunction with ant-contrib.

Peter

>
>Thanks, --DD
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>For additional commands, e-mail: dev-help@ant.apache.org
>
>
>
>  
>


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


Mime
View raw message