ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: <macro> and XML NS hell ;-)
Date Tue, 24 Feb 2004 16:45:38 GMT
> From: Peter Reilly [mailto:peter.reilly@corvil.com]
> 
> Ah, I see, you are trying to
> use the contents of "sources" in javc and also in bm:lsync.
> 
> This is indeed XML NS hell!
> 
> The problem is that the ns uri and local name of the Unknown elements
> are given to the elements in the calling macro.
> 
> In ant 1.6.0+, the namespace of elements discovered by reflection take
> the namespace uri of type/task that contains the element (Note this is the
> uri and not the localname).
> 
> The enclosed patch will allow the namespace of nested elements to be
> either the ant uri or the namespace of the containing type/task.

I see this is a two liner, that even puts back in commented out code...
What's the problem with checking it in?
When Ant 1.6.2 being built with it ;-)

> The following then works:
> 
> <project xmlns:bm="some uri or other">
> 
>   <scripttypedef name="lsync" language="beanshell"
>                  uri="some uri or other">
>     import org.apache.tools.ant.taskdefs.MatchingTask;
>     public class LSync extends MatchingTask {
>        public void execute() {}
>     }
>   </scripttypedef>
> 
>   <macrodef name="compile">
>     <element name="sources"/>
>     <sequential>
>       <javac destdir="classes" srcdir="src">
>         <sources/>
>       </javac>
>       <bm:lsync>
>         <sources/>
>       </bm:lsync>
>     </sequential>
>   </macrodef>
> 
>   <compile>
>     <sources>
>       <include name="**/*.java"/>
>     </sources>
>   </compile>
> </project>

Man, were you born with innate XML and Ant knowledge? This is too clever.

> Another solution would be to modify lsync to use the fileset type:
> lsync -> void add(FileSet fs) { .. }
> Then one can do:
> 
> <bm:lsync>
>    <bm:fileset dir="x"/> <!-- fileset is the nested addFileSet(Fileset fs)
> method -->
>    <fileset dir="x">  <!-- fileset is the nested add(FileSet fs) using the
> "fileset" type
>                            in the ant core uri. -->
>       <include name="**/*.java"/>
>     </fileset>
> </bm:lsync>

I'll have to see. Thanks for the alternative fix, which I could put to use
waiting for Ant 1.6.2.

Why am I the one always falling in the XML NS traps :-( --DD

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


Mime
View raw message