ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barclay <>
Subject idea: subelements in addition to attributes to allow using entities
Date Tue, 01 May 2001 15:41:25 GMT
For Ant2, have you all considered allowing using subelements (in addition 
to attributes) to specify scalar task options?

I wanted to define a group of javac options in one place and use the group
in multiple javac tasks. 

(I wanted to be able to define one group that contained various options, 
so that an additional option could be added to the group without having 
to edit all the task instances.  I didn't really want to have a set of 
properties, one property per option, and have to edit all the task instances 
if I added a new option to the set.)

I can't use properties like this:

  someProp=debug="off" deprecation="on"

  <javac ${someprop} ... />

since property substitution happens way after XML parsing.

I thought about using an XML entity, but I can't do this:

  <!DOCTYPE whatever [
    <!ENTITY myOptions 'debug="off" deprecation="on"'>
  <javac &myOptions; ... />

because entity references are not allowed at that level in tags. 

If javac task options could be configured with subelements, then
I could do this:

  <!DOCTYPE whatever [
    <!ENTITY myOptions '<debug>off<debug> </deprecation>on</deprecation>'>
  <javac ...>

Unfortunately, I can't do that for most task options, because they can
be set only via attributes.

In your redesign for Ant2, could you consider automatically allowing
nested elements as an alternative for any attributes defined for a 

At a higher level (requirements vs. a particular solution), could
you think about how to support bundled options?

This main options I can think of are:
- allowing nested elements whose names match already-defined attribute 
- having a special attribute whose XML string value is a list of
  attribute names and values e.g. (<javac ... special='${myOptions}' ... />)

Nested elements might also allow for defaulting and overriding, something
like this:

  <javac ...>
    &projectJavacMiscFlags;		<!-- apply any misc. flags ... -->
    <debug>on<\debug>			<!-- ... but force debugging on,
                                             even if previously set -->

(Such nested elements that are just alternatives for attribute could be
grouped under some other element if segregated nested elements would be 
better, e.g.:

  <javac ...>
    ...currently-defined nested elements...


(By the way, can Ant's XML parser process DTDs enough to apply DTD-defined 
default attribute values without doing full validation?)

Daniel Barclay
Digital Focus

View raw message