ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicola Ken Barozzi <nicola...@apache.org>
Subject Re: xml namespace support in ant2
Date Thu, 05 Sep 2002 11:29:31 GMT

Wannheden, Knut wrote:
> I know this topic has been brought up before (e.g. in "Optional tasks"
> thread of last december [1]), but I still wonder what is the actual plan for
> the accepted requirement for Ant2.
> 
> At one point it was argued that using namespaces would yield to verbose
> buildfiles.  But this all depends on what the namespaces would be used for.
> In [1] it was suggested that there should be a defined namespace for Ant
> (including <project>, <target>, core and optional tasks and datatypes) and
> external tasks and datatypes would have to be declared in a separate
> namespace.  With a namespace enabled <taskdef> a buildfile could look
> something like this:
> 
> <project xmlns="http://jakarta.apache.org/Ant/v2"
>          xmlns:my="urn:my-ant-tasks"
>          default="test">
> 
>  <taskdef qname="my:foo" classname="org.bar.FooTask"/>
>  <taskdef name="baz" ns="urn:my-ant-tasks" classname="org.bar.BazTask"/>
> 
>  <target name="test">
>   <echo message="test"/>
>   <my:foo/>
>   <whatever:baz xmlns:whatever="urn:my-ant-tasks"/>
>  </target>
> 
> </project>
> 
> (Note the two different uses of <taskdef>.)

There is a "namespace" feature working on properties in /proposal/embed, 
and also a SAX2 ProjectHelper.
What needs to be still defined is just how to use namespaces; good you 
brought the point to the attention :-)

> So for all those people not using custom tasks and datatypes the only
> difference would be the default namespace declaration (or a prefixed one if
> preferred).
> 
> I was just thinking that if there were a namespace for all core Ant XML
> elements it shouldn't be very hard to write up a RELAX NG grammar to
> validate buildfiles, even with custom tasks and datatypes in it.  And the
> gain of that in turn is probably quite obvious (although the RNG grammar
> would require maintainance):
>  - the task implementation would be guarded against wrong usage (validation)
>  - the user wouldn't be surprised by different behaviour of tasks with just
> swapped attribute order
>  - and maybe a consistent documentation could be generated out of an
> annotated grammar
> 
> Are namespaces intended for this kind of purpose in Ant2?

Can be, I'm personally still musing about the best purpose.

> [1] http://www.mail-archive.com/ant-dev@jakarta.apache.org/msg10233.html

the same afromentioned proposal code has support for overriding the lib 
dir of Ant; an antlib support (ie automatic taskdefs) is planned, making 
use of Commons discovery.

In this case, the namespace would be applied to the tasks, so that 
taskdeffing a jar will yield the tasks with the specified namespace, to 
prevent clashing.

Also, we could define a namespace to be used for every "import", so that 
   targets imported there do not have problems with name clashes. (see 
the embed proposal for this tag)

Is this what you advocate?

Other ideas?

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


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


Mime
View raw message