ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Lenz <>
Subject Re: Ant 1.6 and namespace
Date Mon, 17 Nov 2003 16:27:08 GMT
Matt Benson wrote:
> --- peter reilly <> wrote:
>>For example:
>><project xmlns:antcontrib="antlib:net.sf.antcontrib"
>>         xmlns:acme="antlib:org.acme.anttasks">
>>  <target name="show">
>>    <antcontrib:if>
>>        <antcontrib:or>
>>	    <antcontrib:equals arg1="yes" arg2="${prop}"/>
>>            <acme:fileready file="${file}"/>
>>        </antcontrib:or>
>>        <antcontrib:then>
>>           <echo>The arguments are equal</echo>
>>        </antcontrib:then>
>>    </antcontrib:if>
>>  </target>
> Okay, how about redoing the same example with:
>     <antcontrib:if xmlns="antlib:net.sf.antcontrib">
> ...
>     </antcontrib:if>
> or will that syntax be available at all?

That should be:

   <if xmlns="antlib:net.sf.antcontrib">

because the prefix mapping applies to the element it is defined on, in 
addition to all child elements (as long as not overridden).

If you want child elements from the Ant core namespace, you'd need to map 
that to a prefix, so the complete example would look like this:

<project xmlns:acme="antlib:org.acme.anttasks">
   <target name="show">
     <if xmlns="antlib:net.sf.antcontrib"
	    <equals arg1="yes" arg2="${prop}"/>
             <acme:fileready file="${file}"/>
            <ant:echo>The arguments are equal</ant:echo>

Of course using a shorter prefix like 'ac' instead of 'antcontrib' also 
helps to reduce verbosity ;-)

BTW, my non-binding +1 to option b).


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

View raw message