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: NameSpace & antlib was (Re: polymorphism)
Date Mon, 28 Apr 2003 17:37:19 GMT
On Sunday 27 April 2003 22:14, Wannheden, Knut wrote:
> > Or even:
> >   <antelope:if xmlns:antelope="antlib:${ant-contrib.jar}" />
>
> That syntax abuses the purpose of XML Namespaces, IMO.  Although a
> namespace is identified by an URI, I don't think attaching semantics to it
> is correct.

I am no expert in xml ns usage (my only experiance with xml is ant
and home made configuration files), however I think that attaching sematics
is exactly the purpose of  the xmlns:<name>="" attribute.

>  Also, would ProjectHelper2 (using SAX2) resolve property
> references in namespace declarations?

The (new) NS handling code could do this

> Questionable whether that should be
> allowed, no? IMHO it is cleaner to require explicit loading (maybe even
> unloading) of antlibs using a task like <antlib/>.  That would better
> correspond to how <taskdef/> works.  But nevertheless, I think it's a good
> idea to associate a namespace with every antlib.

This should be left up the to build script author. Usage of antlib should
be backwardly compatible so that:

<antlib file="${ant-contrib.jar}"/>

should be the same as:

<typedef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath path="${ant-contrib.jar}"/>
</typedef>

>  If the antlib defines a
> namespace to use in its descriptor (e.g. "antlib:antelope" for antlib
> "antelope") then loading an antlib could be as simple as:
>
> 	<antlib resource="${antelope.jar}"/>
> 	<if xmlns="antlib:antelope"/>

The problem here is antelope may be "antelope-1.20.jar".
>
> but maybe the buildfile author wants/needs to specify the namespace URI
> (anything really), in which case an additional "ns" attribute could be
> used:
>
> 	<antlib resource="${foo.jar}" ns="urn:antlib:foo"/>
> 	<foo:bar xmlns:foo="urn:antlib:foo"/>

This is fine.
<antlib file="${ant-contrib.jar}" ns="antlib:antcontrib"/>
<antcontrib:if xmlns:antcontrib ="antlib:antcontrib"....>
<target xmlns:antcontrib="antlib:antcontrib" name="compile">
   <antcontrib:propertycopy .../>
</target>

Cheers,

Peter


Mime
View raw message