ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41080] New: - XmlProperty overrides previously set property value when handling duplicate elements
Date Thu, 30 Nov 2006 12:19:56 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41080>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41080

           Summary: XmlProperty overrides previously set property value when
                    handling duplicate elements
           Product: Ant
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: andy.wood@yoomedia.com


When using the xmlproperty task to read in an external XML file such as:
<root>
   <element value="a" />
   <element value="b" />
</root>

after previously setting a property value in the ant file such as:
<property name="root.element.value" value="c" />

will cause ${root.element.value} to change from c to a,b.  This doesn't happen 
if there aren't duplicate elements in the XML file.  The behaviour is present 
in 1.6.5 and looks unchanged in the latest version of 1.7 on the trunk in SVN.

Suggested fix is to modify
private void addProperty (String name, String value, String id)
in src/main/org/apache/tools/ant/taskdefs/XmlProperty.java to:

         if (addedAttributes.containsKey(name)) {
            // If this attribute was added by this task, then
            // we append this value to the existing value.
            // We use the setProperty method which will
            // forcibly override the property if it already exists.
            // We need to put these properties into the project
            // when we read them, though (instead of keeping them
            // outside of the project and batch adding them at the end)
            // to allow other properties to reference them.
            value = (String) addedAttributes.get(name) + "," + value;
        }
        if (getProject().getProperty(name) == null) {
            getProject().setProperty(name, value);
            addedAttributes.put(name, value);
        }
        else {
            log("Override ignored for property " + name, Project.MSG_VERBOSE);
        }
        if (id != null) {
            getProject().addReference(id, value);
        }

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message