You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Vogel <pv...@arsin.com> on 2000/12/14 02:32:24 UTC

Extensible Attributes

Hi all,
 
A fairly common thing in large development projects is the idea that there
are certain people who "own" a section of the code, any build problems in
that code should be brought to the attention of that owner/those owners.
 
When I've solved this in the past, with a non-ant driven build, I've parsed
the
output of gnumake and had an associative array (PERL) I slurp in on the side
to 
indicate who "owns" or should be notified about various directories within
the tree.
 
I was about to do the same thing today with an ant-based (but still PERL
driven 
at the top) build, when I thought:  "Wait!  This is XML, we'll maintain the
owner info
in the same place as the rest of the build!" so I proceeded to add an
"owner" attribute
to targets, and my perl script uses XML::Parser to snag that information
from build.xml
before calling ant and parsing its output.
 
Cool!  Except for some reason, which this XML neophyte does not understand,
ANT is
very strict about the attributes that it will allow on the tags it handles.
So I went and 
hacked ProjectHelper.java to have it recognize and ignore the "owner"
attribute in 
TargetHandler's init interface.
 
So, I have two primary questions:
 
1.  Why be so strict about attributes on tags, such that you throw an
exception for 
     any unrecognized tag?  Why not just silently ignore (or warn, if you
must) unrecognized
     tags?  Isn't that the whole point of XML?, to allow disparate tools to
communicate more
     efficiently?  Isn't it the case that some tools will look at some
tags/attributes and not
     others and vice versa?  If anyone else agrees, perhaps the
            }else { throw SAXParseException("unknown attribute ..."); } 
     should be eliminated from ProjectHelper.java?
 
2.  If there *is* a good reason (and remember, I'm an XML neophyte, so what
do I know?) for
     this stringency, can we add the following code to TargetHandler::init?:
 
        } else if {key.equals("owner")) {
            /* ignore me */
        ...
 
Thanks!
-Peter
Manager, Configuration Management
Arsin Corporation
4800 Great America Parkway, Suite 425
Santa Clara, CA 95054
 

Re: Extensible Attributes

Posted by James Duncan Davidson <du...@x180.net>.
On 12/14/00 12:44 AM, "Stefan Bodewig" <bo...@apache.org> wrote:

> The solution to this problem would be to use namespaces IMHO. Ant
> doesn't handle namespaces ATM but as Ant2 will use SAX2 we could make
> Ant ignore everything that's not in its namespace. So you'd define
> your owner attribute in a namespace owners and make that

Actually the more I think about this, the more that I'm okay that
information that is meaningless to Ant or a task gets dropped on the floor
but is preserved for other tools to use.

This keeps in with the principle that we use XML as a data vehicle, but
aren't subject to all of its rules. For example, no DTD can be written for
all of Ant+Optional tasks. A DTD could be made for core tasks, but Ant
doesn't use it. 

-- 
James Duncan Davidson                                        duncan@x180.net
                                                                  !try; do()


Re: Extensible Attributes

Posted by Stefan Bodewig <bo...@apache.org>.
Peter Vogel <pv...@arsin.com> wrote:

> 1.  Why be so strict about attributes on tags, such that you throw
> an exception for any unrecognized tag?

Because Ant doesn't expect to see anything that has meaning to
something else but not Ant in a build file. We had a similar
discussion a while back when we talked about adding documentation to
build files.

The solution to this problem would be to use namespaces IMHO. Ant
doesn't handle namespaces ATM but as Ant2 will use SAX2 we could make
Ant ignore everything that's not in its namespace. So you'd define
your owner attribute in a namespace owners and make that

<target name="main" owners:owner="fred">

No short term solution though.

> 2.  If there *is* a good reason (and remember, I'm an XML neophyte,
> so what do I know?) for this stringency, can we add the following
> code to TargetHandler::init?:
>  
>         } else if {key.equals("owner")) {
>             /* ignore me */
>         ...

You mean with the opening brace before key translated to a paren?

Don't think so, sorry. If we'd start this, we'd be adding exceptions
for anybody else as well.

Stefan

RE: Extensible Attributes

Posted by Chris Todd <ch...@christophertodd.com>.
Peter-

This doesn't address your question, and I'm not sure it would help you
directly, but I know that Jeff Martin has written an Ant task called
ChangeLog as part of the Alexandria project
(http://java.apache.org/alexandria) that helps attribute file ownership.

Re: Extensible Attributes

Posted by James Duncan Davidson <du...@x180.net>.
On 12/13/00 5:32 PM, "Peter Vogel" <pv...@arsin.com> wrote:

> 1.  Why be so strict about attributes on tags, such that you throw an
> exception for any unrecognized tag?  Why not just silently ignore (or warn,
> if you must) unrecognized tags?  Isn't that the whole point of XML?, to
> allow disparate tools to communicate more efficiently?  Isn't it the case
> that some tools will look at some tags/attributes and not others and vice
> versa?  If anyone else agrees, perhaps the }else { throw
> SAXParseException("unknown attribute ..."); } should be eliminated from
> ProjectHelper.java?

Since there is no set DTD for Ant build files, I'm neutral on allowing extra
info and letting Ant ignore it. In fact, in your case, you give a good
argument for it.

In fact, AntEater as set up right now only scopes out attributes it knows it
needs to look for in Project/Target/Task/Property. In task it'll reflect it
in, but if the task doesn't use it, it doesn't get used.

-- 
James Duncan Davidson                                        duncan@x180.net
                                                                  !try; do()