ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <peterrei...@apache.org>
Subject Re: stripping cr/lf off the properties from a xmlproperty command
Date Mon, 27 Sep 2004 09:39:42 GMT
1) upgrade ant to 1.6.*
   this trimming issue has been fixed since ant 1.6.0
   probally done by
* <xmlproperty> now handles CDATA sections. BugZilla Report 17195

or
2)  write  a  custom task

public class TrimString  extends Task {
   private String property;
   private String value;
   public void setInput(String input) {
      value = input.trim();
   }
   public void setProperty(String property) {
      this.property = property;
   }
   public void execute() {
      if (property == null) {
         throw new BuildException("Missing attribute 'property'");
      }
      if (value == null) {
         throw new BuildException("Missing attribute 'input'");
      }
      getProject().setNewProperty(property, value);
   }
}

<taskdef name="trimstring" class="TrimString" classpath="classes"/>
<trimstring input="${pnc.build.application" 
property="pnc.build.application.trimmed"/>

3) write a script

<script  language="beanshell">
    project.setNewProperty("pnc.build.application.trimmed",
              project.getProperty("pnc.build.application").trim());
</script>

4) Use the propertyregex task from antcontrib and figure out a regex that
   strips white space.

Peter

mark.russel@pnc.com wrote:

>I have an XML configuration file written by users it looks something like
>this:
><pnc>
>  <build>
>    <applicationname>test</applicationname>
>  </build>
></pnc>
>
>some users enter it like this:
><pnc>
>  <build>
>    <applicationname>
>      test
>    </applicationname>
>  </build>
></pnc>
>
>the white space gets cleared off the command but the line terminators are
>still there.
>the value I get is
>"
>test
>"
>Does anyone know of a way to strip the line terminators and just get the
>value "test"?
>
>I searched the archives but could not find anything on this.
>P.S. I'm not afraid to write a custom task if needed.
>
>Mark Russell
>PNC
>412-768-9603
>
>
>
>-----------------------------------------
>The contents of this email are the property of PNC. If it was not addressed
>to you, you have no legal right to read it. If you think you received it in
>error, please notify the sender. Do not forward or copy without permission
>of the sender.
>
>
>---------------------------------------------------------------------
>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


Mime
View raw message