ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Expanding ${} constructs for all attributes
Date Thu, 14 Dec 2000 08:17:07 GMT
Jason Rosenberg <> wrote:

> But, I am not clear on what I should look into exactly
> based on your suggestions there.  Is this something
> I alternately configure with respect to the sax parser
> jars I am using?


Entities are things like HTML's &auml; which will be interpreted as รค
by your browser - the parser of the browser is doing this. 

Likewise if you embed &quot; into a build file, the XML parser will
translate it into " before the text is passed to Ant. Ant doesn't
parse the build file itself, it uses an external parser (JAXP
reference implementation from Sun or Xerces depending on your setup -
probably Sun's). All Ant sees is the ", it doesn't even know there has
been an entity before.

When you define

<!ENTITY shared SYSTEM "someurl">

the parser - not Ant - will read the content of someurl and wherever
it finds &shared; insert the content. Again, Ant doesn't even know
there has been an entity, it just sees the result.

Ant communicates with the parser via SAX (Simple Api for Xml) - see
<>. This API allows
applications using an XML parser to help the parser interpreting what
"someurl" means - this is the job of an EntityResolver.

The EntityResolver's primary use would be for custom URL schemes, say
you've invented a sql protocol that reads documents from a database
and "someurl" was "sql://host/database;query=SELECT content FROM
Documents WHERE id='foo'" than EntityResolver would magically retrieve
the content from the database and hand it (or a Reader/Stream to that
content) back to the parser.

Ant hands an EntityResolver of its own to the parser to handle URLs
starting with "file:" and referencing relative file names - because
the default behavior of the parser is not what Ant's users
expected. This EntityResolver is implemented in

> Where is the ProjectHelper.RootHandler code located,

It's the inner class RootHandler in
which is located in src/main/...

> and are you suggesting that this would be code that I
> should modify?  Are you talking about modifying Ant
> itself, or are you talking about modifying my use of Ant
> on a configuration level?

Neither nor. My first response was something along the lines of:

Technically it wouldn't be a big problem to expand properties in the
systemIds (the "someurl" from above) of entities. Ant already
implements an EntityResolver and this would be the place to plug in
property substitution.

To rephrase, Ant already gets notified on all external entities and
massages the systemIds - plugging in property expansion there wouldn't
be too difficult.

I think, I also said that I wouldn't like to do that, which means I
was not talking about modifying Ant 8-). 

If you want to see this happen, you have to modify the code in
ProjectHelper, there is nothing you could do from the outside to
achieve what you want - apart from preprocessing your build file and
the preprocessor does the property expansion.

What you need to do if you want to modify Ant's behavior is (1)
sending a patch that does what you want and (2) lobby for it so that
it gets applied.


View raw message