ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 47381] New: XmlProperty doesn' allow propertvalues with only space(s)
Date Wed, 17 Jun 2009 11:28:12 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=47381

           Summary: XmlProperty doesn' allow propertvalues with only
                    space(s)
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Windows Server 2003
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: Gilbert.Rebhan@huk-coburg.de


Created an attachment (id=23823)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23823)
XmlProperty.java.diff.txt

Discovered a difference related to the handling of txtproperties and
xmlproperties after upgrading from ant 1.6.5 to ant 1.7.1

**Test 1**

* props.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <xmlkey></xmlkey>
  <xmlfoo>bar</xmlfoo>
</root>

* props.txt
txtfoo=bar
txtkey=

*TestScript
<project name="foobar" default="main" basedir=".">

  <!-- // Taskdefs -->
  <!-- Import AntContrib -->
  <taskdef resource="net/sf/antcontrib/antlib.xml" />
  <!-- Taskdefs // -->

  <!-- // Properties -->
  <property file="props.txt" />
  <xmlproperty file="props.xml" keeproot="false" />
  <!-- Properties // -->

  <target name="main">

    <echo>${ant.version}</echo>
    <echo>$${xmlkey} == ${xmlkey}</echo>
    <echo>$${txtkey} == ${txtkey}</echo>

    <if>
      <isset property="xmlkey" />
      <then>
        <echo>xmlkey set</echo>
      </then>
      <else>
        <echo>xmlkey not set</echo>
      </else>
    </if>

    <if>
      <isset property="txtkey" />
      <then>
        <echo>txtkey set</echo>
      </then>
      <else>
        <echo>txtkey not set</echo>
      </else>
    </if>

  </target>
</project>


*Output

[echo] Apache Ant version 1.6.5 compiled on June 2 2005
[echo] ${xmlkey} == ${xmlkey}
[echo] ${txtkey} == 
[echo] xmlkey not set
[echo] txtkey set

[echo] Apache Ant version 1.7.0 compiled on December 13 2006
[echo] ${xmlkey} == 
[echo] ${txtkey} == 
[echo] xmlkey set
[echo] txtkey set

[echo] Apache Ant version 1.7.1 compiled on June 27 2008
[echo] ${xmlkey} == 
[echo] ${txtkey} == 
[echo] xmlkey set
[echo] txtkey set

the different handling of empty txt and xml properties seems
to be fixed in conjunction with Bug 26286 - XmlProperty: empty element semantic
problems 

but Test 2 shows another problem when xmlpropertyfile contains a node which has
only
1 or more spaces, which is no problem in a txtpropertyfile

** Test 2 **

* props.xml
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <xmlkey> </xmlkey>
  <xmlfoo>bar</xmlfoo>
</root>

* props.txt
txtfoo=bar
txtkey=*blank*

*Output

[echo] Apache Ant version 1.6.5 compiled on June 2 2005
[echo] ${xmlkey} == ${xmlkey}
[echo] ${txtkey} == 
[echo] xmlkey not set
[echo] txtkey set

[echo] Apache Ant version 1.7.0 compiled on December 13 2006
[echo] ${xmlkey} == ${xmlkey}
[echo] ${txtkey} == 
[echo] xmlkey not set
[echo] txtkey set

[echo] Apache Ant version 1.7.1 compiled on June 27 2008
[echo] ${xmlkey} == ${xmlkey}
[echo] ${txtkey} == 
[echo] xmlkey not set
[echo] txtkey set

which is wrong, as value of xmlkey is also = " " like value of txtkey

Fixed line 469 in org/apache/tools/taskdefs/XmlProperty

<   if (nodeText.trim().length() != 0 || emptyNode) {
---
>   if (nodeText.trim().length() >= 0 || emptyNode) {

and it works as expected =

[echo] Apache Ant version 1.7.1 compiled on June 27 2008
[echo] ${xmlkey} == 
[echo] ${txtkey} == 
[echo] xmlkey set
[echo] txtkey set

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message