Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 95446 invoked from network); 6 Sep 2007 16:33:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Sep 2007 16:33:21 -0000 Received: (qmail 864 invoked by uid 500); 6 Sep 2007 16:33:11 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 837 invoked by uid 500); 6 Sep 2007 16:33:10 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 826 invoked by uid 99); 6 Sep 2007 16:33:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 09:33:10 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [24.71.223.10] (HELO pd2mo1so.prod.shaw.ca) (24.71.223.10) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2007 16:34:26 +0000 Received: from pd4mr3so.prod.shaw.ca (pd4mr3so-qfe3.prod.shaw.ca [10.0.141.214]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JNY00DVFGK9F2E0@l-daemon> for user@ant.apache.org; Thu, 06 Sep 2007 10:31:21 -0600 (MDT) Received: from pn2ml1so.prod.shaw.ca ([10.0.121.145]) by pd4mr3so.prod.shaw.ca (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0JNY003DIGK86X90@pd4mr3so.prod.shaw.ca> for user@ant.apache.org; Thu, 06 Sep 2007 10:31:21 -0600 (MDT) Received: from [192.168.168.34] ([24.68.237.216]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JNY00IDJGK8OM16@l-daemon> for user@ant.apache.org; Thu, 06 Sep 2007 10:31:20 -0600 (MDT) Date: Thu, 06 Sep 2007 09:31:21 -0700 From: Bruce Atherton Subject: Re: extract properties from file and corresponding template In-reply-to: To: Ant Users List Message-id: <46E02B59.7060900@callenish.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 8BIT References: User-Agent: Thunderbird 2.0.0.6 (X11/20070728) X-Virus-Checked: Checked by ClamAV on apache.org Actually, if you wanted to do it programatically in code and you could guarantee that each line had no more than one token, you could probably make it work by creating regular expressions. Here is some pseudocode: for each line in the template file pull out the token name from the line create a regular expression from the line that anchors both ends and replaces the @token@ with a "(.*)" read equivalent line from the resulting file run regular expression on line if no match error out, this file was not generated from the template value of token is group 1 register token name, token value in a Properties object (or equivalent dict or hash construct) write Properties object to disk So in your example, the regular expression would be "^this (.*) file$" and the group 1 match would give you "is a sample". Translated into Java, this could be a custom task. Or it could be done with some script in an ant build file. You could even make it work with multiple tokens on a line so long as enough characters showed up between the tokens that would not also show up in the substitution values. Jan.Materne@rzf.fin-nrw.de wrote: > No there isnt. > > And I think this cant be done: > If you combine the template with the property values you doesnt have any markers where a property value starts and where it ends (if your template doesnt provide these). Therefore you cant parse the resulting file. > > Example: > > template > this @value@ file > property > value=is a sample > result > this is a sample file > > How you would parse the "this is a sample file" string? > > > Jan > > >> -----Urspr�ngliche Nachricht----- >> Von: Patrick Martin [mailto:antuser@gmail.com] >> Gesendet: Donnerstag, 6. September 2007 10:18 >> An: Ant User >> Betreff: extract properties from file and corresponding template >> >> Hello, >> >> I have a file that was generated from a template and a set of >> properties using ant filters. >> Basically, the template contained tokens like @my.property@ which >> where replaced by the corresponding value of ${my.property}. >> template + properties >>> file >> >> Now, I'd like to be able to get the set of properties back from this >> file and the corresponding template. >> file + template >>> properties >> >> Is there any task out there that already exists for that? >> >> Thank you, >> >> Patrick >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org >> For additional commands, e-mail: user-help@ant.apache.org >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org