Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 27510 invoked from network); 14 Dec 2000 08:22:48 -0000 Received: from bodewig.bost.de (root@195.227.98.11) by locus.apache.org with SMTP; 14 Dec 2000 08:22:48 -0000 Received: (from bodewig@localhost) by bodewig.bost.de (8.9.3/8.9.3) id JAA02059; Thu, 14 Dec 2000 09:17:07 +0100 X-Authentication-Warning: bodewig.bost.de: bodewig set sender to bodewig@apache.org using -f To: ant-dev@jakarta.apache.org Subject: Re: Expanding ${} constructs for all attributes References: <0ce601c064e1$f906de50$020a0a0a@alsatian> <0d2301c064fa$ed6143b0$020a0a0a@alsatian> <0dcd01c06536$1ab765c0$020a0a0a@alsatian> From: Stefan Bodewig Date: 14 Dec 2000 09:17:07 +0100 In-Reply-To: "Jason Rosenberg"'s message of "Wed, 13 Dec 2000 13:52:33 -0500" Message-ID: Lines: 79 User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N 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? No. Entities are things like HTML's ä which will be interpreted as � by your browser - the parser of the browser is doing this. Likewise if you embed " 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 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 ProjectHelper.RootHandler. > Where is the ProjectHelper.RootHandler code located, It's the inner class RootHandler in org.apache.tools.ant.ProjectHelper 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. Stefan